Skip to content

Commit 04ddd5c

Browse files
committed
[bug] fixed critical errors for linux dependendancy handling
1 parent ff837cc commit 04ddd5c

6 files changed

Lines changed: 26 additions & 16 deletions

File tree

pytron/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .apputils.codegen import CodegenMixin
1111
from .apputils.native import NativeMixin
1212
from .apputils.config import ConfigMixin
13-
from .apputils.windows import WindowMixin
13+
from .apputils.window_mixin import WindowMixin
1414
from .apputils.extras import ExtrasMixin
1515
from .apputils.shell import Shell
1616
from .inspector import Inspector

pytron/commands/engine.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ def cmd_engine(args):
1717
except Exception as e:
1818
log(f"Engine Forge Failed: {e}", style="error")
1919
return 1
20+
elif args.name == "native":
21+
log(f"Building Native Iron Engine from source...", style="info")
22+
try:
23+
from ..engines.native.build import build as build_native
24+
25+
build_native()
26+
log("Native Engine Build Successful!", style="success")
27+
except Exception as e:
28+
log(f"Native Engine Build Failed: {e}", style="error")
29+
return 1
2030
else:
2131
log(f"Unsupported engine: {args.name}", style="error")
2232
return 1

pytron/webview.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@
1212
import base64
1313
from collections import deque
1414

15-
# Import Native Engine
16-
try:
17-
from .dependencies import pytron_native
18-
except ImportError:
19-
# Fallback to check if it's in path
20-
sys.path.append(os.path.join(os.path.dirname(__file__), "dependencies"))
15+
# Import Native Engine via Canonical Resolver
16+
from .utils import resolve_native_module
17+
18+
pytron_native = resolve_native_module()
19+
if not pytron_native:
20+
# Final legacy fallback for simple environments
2121
try:
22-
import pytron_native
22+
from .dependencies import pytron_native
2323
except ImportError:
24-
print("[CRITICAL] Could not load pytron_native engine.")
25-
pytron_native = None
24+
pass
2625

2726
import urllib.parse
2827
from .serializer import pytron_serialize
@@ -37,10 +36,11 @@
3736
class Webview:
3837
def __init__(self, config):
3938
if not pytron_native:
39+
ext = ".pyd" if sys.platform == "win32" else ".so"
4040
raise NativeEngineError(
41-
"Pytron Native Engine binary (pytron_native.pyd/so) is missing or could not be loaded. "
42-
"Ensure it is present in 'pytron/dependencies' or your environment. "
43-
"You may need to run 'pytron engine install native' or check for architecture mismatches."
41+
f"Pytron Native Engine binary (pytron_native{ext}) is missing or could not be loaded. "
42+
"Ensure it is present in 'pytron/dependencies' or your path. "
43+
"Try running 'pytron engine install native' to build it for your current system."
4444
)
4545

4646
self.config = config

tests/test_lifecycle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test_on_exit_sync(self):
1111
app.on_exit(mock_func)
1212

1313
# Simulate app exit
14-
from pytron.apputils.windows import WindowMixin
14+
from pytron.apputils.window_mixin import WindowMixin
1515

1616
# The exit logic usually runs through _on_exit_cleanup which we should verify
1717
# or simulate the callback execution.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33
import pytest
44
from unittest.mock import MagicMock, patch
5-
from pytron.apputils.windows import WindowMixin
5+
from pytron.apputils.window_mixin import WindowMixin
66

77

88
# Mock App class that uses the mixin
@@ -28,7 +28,7 @@ def app():
2828

2929
@pytest.fixture
3030
def mock_webview():
31-
with patch("pytron.apputils.windows.Webview") as mock:
31+
with patch("pytron.apputils.window_mixin.Webview") as mock:
3232
# Setup the mock instance returned by the constructor
3333
instance = mock.return_value
3434
instance.config = {}

0 commit comments

Comments
 (0)