diff --git a/build.py b/build.py index 79aee76..4f88215 100644 --- a/build.py +++ b/build.py @@ -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}")