Skip to content

Commit

Permalink
hooks: fix scipy windows (#2060)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelotduarte committed Sep 21, 2023
1 parent 14878ea commit 71802a2
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions cx_Freeze/hooks/scipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ def load_scipy(finder: ModuleFinder, module: Module) -> None:
Supported pypi and conda-forge versions (lasted tested version is 1.11.2).
"""
replace_delvewheel_patch(module)
source_dir = module.file.parent.parent / f"{module.name}.libs"
if source_dir.exists(): # scipy >= 1.9.2 (windows)
finder.include_files(source_dir, f"lib/{source_dir.name}")
replace_delvewheel_patch(module)
finder.include_package("scipy.integrate")
finder.include_package("scipy._lib")
finder.include_package("scipy.misc")
Expand All @@ -32,19 +35,18 @@ def load_scipy__distributor_init(finder: ModuleFinder, module: Module) -> None:
# patch the code when necessary
code_string = module.file.read_text(encoding="utf_8")

# installed from pypi?
# installed from pypi, scipy < 1.9.2 (windows) or all versions (macOS)
module_dir = module.file.parent
libs_dir = module_dir.joinpath(".dylibs" if IS_MACOS else ".libs")
if libs_dir.is_dir():
# copy any file at site-packages/scipy/.libs
finder.include_files(
libs_dir, f"lib/scipy/{libs_dir.name}", copy_dependent_files=False
)

# do not check dependencies already handled
extension = EXTENSION_SUFFIXES[0]
for file in module_dir.rglob(f"*{extension}"):
finder.exclude_dependent_files(file)
# do not check dependencies already handled
extension = EXTENSION_SUFFIXES[0]
for file in module_dir.rglob(f"*{extension}"):
finder.exclude_dependent_files(file)

if module.in_file_system == 0:
code_string = code_string.replace(
Expand Down

0 comments on commit 71802a2

Please sign in to comment.