Skip to content

Commit 9e73da5

Browse files
committed
fix: include generated Python bindings in repo for reliable wheel builds
1 parent b000b04 commit 9e73da5

File tree

3 files changed

+4345
-7
lines changed

3 files changed

+4345
-7
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ env/
2020
.env
2121
.venv/
2222
# Generated Python bindings (keep __init__.py but ignore generated files)
23-
python/isomdl_uniffi/isomdl_uniffi.py
2423
python/isomdl_uniffi/*.so
2524
python/isomdl_uniffi/*.dylib
2625
python/isomdl_uniffi/*.dll

python/isomdl_uniffi/__init__.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,30 @@
1414

1515
__version__ = "0.1.0"
1616

17-
# Import the main module
18-
try:
19-
from .isomdl_uniffi import *
20-
except ImportError as e:
17+
# Import the main module - try multiple paths to handle different wheel structures
18+
_imported = False
19+
_import_error = None
20+
21+
# Try: isomdl_uniffi/isomdl_uniffi.py (generated by maturin for mixed projects)
22+
if not _imported:
23+
try:
24+
from .isomdl_uniffi import *
25+
_imported = True
26+
except ImportError as e:
27+
_import_error = e
28+
29+
# Try: isomdl_uniffi/isomdl_uniffi/isomdl_uniffi.py (nested structure)
30+
if not _imported:
31+
try:
32+
from .isomdl_uniffi.isomdl_uniffi import *
33+
_imported = True
34+
except ImportError:
35+
pass
36+
37+
if not _imported:
2138
raise ImportError(
2239
"Failed to import isomdl_uniffi bindings. "
2340
"This usually means the Rust library hasn't been built yet. "
2441
f"Please run './python/precommit/build-bindings.sh' first. "
25-
f"Original error: {e}"
26-
) from e
42+
f"Original error: {_import_error}"
43+
)

0 commit comments

Comments
 (0)