Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions crates/processing_pyo3/mewnala/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,18 @@
# through an explicit alias rather than the shadowed names.
import builtins as _builtins

# re-export the native submodules as submodules of this module, if they exist
# this allows users to import from `mewnala.math` without needing to know about
# the internal structure of the native module
# re-export native submodules that have no Python counterpart as submodules of
# this module, so users can import from `mewnala.color` without knowing about
# the internal structure of the native module.
import sys as _sys
from . import mewnala as _native

for _name in ("math",):
_sub = getattr(_native, _name, None)
if _sub is not None:
_sys.modules[f"{__name__}.{_name}"] = _sub

_color = getattr(_native, "color", None)
if _color is not None:
_sys.modules[f"{__name__}.color"] = _color

from . import math # noqa: E402 (Python submodule, extends native math)
import importlib as _importlib
math = _importlib.import_module(f"{__name__}.math") # noqa: E402
from .math import * # noqa: E402,F401,F403

# global var handling. for wildcard import of our module, we copy into globals, otherwise
Expand Down Expand Up @@ -111,7 +107,11 @@ def __getattr__(name):
g = _get_graphics()
if g is None:
return 0
x, y = g.surface.position
# offscreen canvases (notebooks, embedding hosts) have no window position
try:
x, y = g.surface.position
except (AttributeError, RuntimeError):
return 0
return x if name == "window_x" else y
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

Expand All @@ -120,7 +120,9 @@ def __dir__():
return sorted(_builtins.set(list(globals().keys()) + list(_DYNAMIC)))

__all__ = sorted(
{n for n in dir(_native) if not n.startswith("_")} | _builtins.set(_DYNAMIC)
{n for n in dir(_native) if not n.startswith("_")}
| {n for n in dir(math) if not n.startswith("_")}
| _builtins.set(_DYNAMIC)
)

del _sys, _name, _sub
del _sys, _importlib
6 changes: 6 additions & 0 deletions crates/processing_pyo3/mewnala/math.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
"""Processing math methods and vector/quaternion types."""
import math as _math
from .mewnala import math as _native_math

# extend native math so glob imports work
for _name in dir(_native_math):
if not _name.startswith("_"):
globals()[_name] = getattr(_native_math, _name)
del _name
from math import (
sin, cos, tan,
atan, atan2,
Expand Down
2 changes: 1 addition & 1 deletion crates/processing_render/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub(crate) const BATCH_INDEX_STEP: f32 = 0.001;
pub struct BelongsToGraphics(pub Entity);

#[derive(Component, Default)]
#[relationship_target(relationship = BelongsToGraphics)]
#[relationship_target(relationship = BelongsToGraphics, linked_spawn)]
pub struct TransientMeshes(Vec<Entity>);

#[derive(SystemParam)]
Expand Down
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,17 @@ fn setup_tracing(log_level: Option<&str>) -> error::Result<()> {
#[cfg(not(target_arch = "wasm32"))]
{
use tracing_subscriber::EnvFilter;
use tracing_subscriber::util::SubscriberInitExt;

let filter = EnvFilter::try_new(log_level.unwrap_or("info"))
.unwrap_or_else(|_| EnvFilter::new("info"));
let subscriber = tracing_subscriber::FmtSubscriber::builder()
.with_env_filter(filter)
.finish();
tracing::subscriber::set_global_default(subscriber)?;
// `try_init` also installs the `log` bridge, so wgpu/naga reach this subscriber.
if subscriber.try_init().is_err() {
tracing::debug!("global tracing subscriber already set by host; keeping it");
}
}
Ok(())
}
Loading