-
-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hooks: move sklearn hook to a submodule (#1954)
- Loading branch information
1 parent
e906c03
commit d1aaf0e
Showing
2 changed files
with
26 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""A collection of functions which are triggered automatically by finder when | ||
scipy package is included. | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import os | ||
|
||
from ..finder import ModuleFinder | ||
from ..module import Module | ||
|
||
|
||
def load_sklearn__distributor_init( | ||
finder: ModuleFinder, module: Module | ||
) -> None: | ||
"""Fix the location of dependent files in Windows.""" | ||
source_dir = module.parent.path[0] / ".libs" | ||
if source_dir.exists(): | ||
# msvcp140 and vcomp140 dlls should be copied | ||
finder.include_files(source_dir, "lib") | ||
# patch the code to search the correct directory | ||
code_string = module.file.read_text(encoding="utf-8") | ||
code_string = code_string.replace( | ||
"libs_path =", "libs_path = __import__('sys').frozen_dir #" | ||
) | ||
module.code = compile(code_string, os.fspath(module.file), "exec") |