include pythonnet package and clr_loader in build process for runtime compatibility

This commit is contained in:
Ross
2025-11-24 12:24:10 +00:00
parent f42c1a1839
commit 5f2bcb81a4
+11
View File
@@ -56,6 +56,17 @@ def build(build: bool = True, copy: bool = True, test: bool = False, dest: str |
for f in runtime_dir.rglob("*.dll"):
# PyInstaller on Windows expects 'src;dest'
add_binary_args += ["--add-binary", f"{str(f)};pythonnet\\runtime"]
# also include the full pythonnet package folder as data so
# package-relative lookups succeed at runtime
add_data_args += ["--add-data", f"{str(pn_path)};pythonnet"]
# try to include clr_loader package as well
try:
spec_clr = importlib.util.find_spec("clr_loader")
if spec_clr and spec_clr.submodule_search_locations:
clr_path = Path(spec_clr.submodule_search_locations[0])
add_data_args += ["--add-data", f"{str(clr_path)};clr_loader"]
except Exception:
pass
except Exception as e:
print(f"Warning: couldn't locate pythonnet runtime: {e}")