Skip to content

Commit 4154c79

Browse files
author
deeleeramone
committed
no entry-point discovery
1 parent ab98dcf commit 4154c79

4 files changed

Lines changed: 20 additions & 5 deletions

File tree

pywry/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "pywry"
3-
version = "2.0.0rc1"
3+
version = "2.0.0rc2"
44
description = "A lightweight and blazingly fast, cross-platform, WebView rendering engine and desktop UI toolkit for Python."
55
authors = [{ name = "PyWry", email = "pywry2@gmail.com" }]
66
license = { text = "Apache 2.0" }

pywry/pywry/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
# enters the Tauri event loop and exits immediately so the developer's
1111
# application code never runs a second time. It is a complete no-op in
1212
# every other situation (normal Python, frozen parent process, etc.).
13-
from ._freeze import freeze_support
13+
from ._freeze import freeze_support, setup_pytauri_runtime
1414

1515

1616
freeze_support()
17+
setup_pytauri_runtime()
1718

1819
# pylint: disable=wrong-import-position
1920
# Inline notebook module - import functions directly

pywry/pywry/_freeze.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,20 @@ def _setup_pytauri_standalone() -> None:
102102
sys._pytauri_standalone = True # type: ignore[attr-defined]
103103

104104

105+
def setup_pytauri_runtime() -> None:
106+
"""Configure pytauri extension loading for all runtime modes.
107+
108+
Pytauri discovers its native extension via the ``pytauri`` entry-point
109+
group. If both the standalone ``pytauri-wheel`` package and PyWry are
110+
installed, discovery can yield multiple ``ext_mod`` providers and abort.
111+
112+
To keep startup deterministic, pre-register the extension module through
113+
pytauri's standalone mechanism before any ``import pytauri`` happens.
114+
This is safe and idempotent in normal and frozen environments.
115+
"""
116+
_setup_pytauri_standalone()
117+
118+
105119
def freeze_support() -> None:
106120
"""Handle subprocess re-entry in frozen executables.
107121
@@ -123,7 +137,7 @@ def freeze_support() -> None:
123137
# Pre-register pytauri's native extension to bypass entry-point
124138
# discovery, which fails in frozen builds when .dist-info metadata
125139
# is not preserved. This must run BEFORE any ``import pytauri``.
126-
_setup_pytauri_standalone()
140+
setup_pytauri_runtime()
127141

128142
if os.environ.get("PYWRY_IS_SUBPROCESS") != "1":
129143
return

pywry/tests/test_freeze.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ def test_idempotent(self) -> None:
204204
sys.modules.pop("__pytauri_ext_mod__", None)
205205

206206
def test_freeze_support_calls_setup_in_frozen_mode(self) -> None:
207-
"""freeze_support() must call _setup_pytauri_standalone when frozen."""
207+
"""freeze_support() must call setup_pytauri_runtime when frozen."""
208208
source = inspect.getsource(freeze_support)
209-
assert "_setup_pytauri_standalone" in source
209+
assert "setup_pytauri_runtime" in source
210210

211211

212212
# ── PyInstaller hook validation ───────────────────────────────────────

0 commit comments

Comments
 (0)