This repository was archived by the owner on Feb 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Include vcomp140.dll in windows wheels #43
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b81dff6
Include vcomp140.dll in windows wheels
ogrisel 95b843d
Try to collect artifacts
ogrisel bbc2fae
New strategy for vcomp140.dll pre-loading
ogrisel 1e3c0c3
Simplify distributor init script
ogrisel 2e91056
Update appveyor/vendor_vcomp140.py
ogrisel 175064a
Update appveyor/vendor_vcomp140.py
ogrisel f4e4846
Update appveyor/vendor_vcomp140.py
ogrisel 6e68a76
Fix indent [ci skip]
ogrisel f42ec46
Target the main repo (master branch for now)
ogrisel 0eea0c9
Test 0.22.1-release branch
ogrisel b592afb
Point back to master branch
ogrisel 1316356
Build release 0.22.1
ogrisel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,81 @@ | ||
"""Embed the vcomp dll before generating the scikit-learn Windows wheel. | ||
|
||
This script should be run from the root of the scikit-learn source tree, | ||
after running the `python setup.py build` command and before running | ||
the `python setup.py bdist_wheel` command. | ||
""" | ||
|
||
import os | ||
import os.path as op | ||
import shutil | ||
from glob import glob | ||
import textwrap | ||
|
||
VCOMP140_SRC_PATH = "C:\\Windows\System32\\vcomp140.dll" | ||
TARGET_FOLDER_GLOB_PATTERN = "build/lib.*/sklearn" | ||
|
||
|
||
def make_distributor_init(sklearn_dirname, dll_filename): | ||
"""Create a _distributor_init.py file for the vcomp dll. | ||
|
||
This file is imported first when importing the sklearn package so as | ||
to pre-load the vendored vcomp dll. | ||
""" | ||
distributor_init = op.join(sklearn_dirname, '_distributor_init.py') | ||
with open(distributor_init, 'wt') as f: | ||
f.write(textwrap.dedent(""" | ||
''' | ||
Helper to preload the OpenMP dll to prevent "dll not found" | ||
errors. | ||
Once a DLL is preloaded, its namespace is made available to any | ||
subsequent DLL. This file originated in the scikit-learn-wheels | ||
github repo, and is created as part of the scripts that build the | ||
wheel. | ||
''' | ||
import os | ||
import os.path as op | ||
from ctypes import WinDLL | ||
|
||
|
||
if os.name == 'nt': | ||
# Pre-load the DLL stored in sklearn/.libs by convention. | ||
dll_path = op.join(op.dirname(__file__), '.libs', '{}') | ||
WinDLL(op.abspath(dll_path)) | ||
|
||
""".format(dll_filename))) | ||
return op.abspath(distributor_init) | ||
|
||
|
||
def main(): | ||
# TODO: use threadpoolctl to dynamically locate the right vcomp dll | ||
# instead? This would require first in-place building scikit-learn | ||
# to make it "importable". | ||
if not op.exists(VCOMP140_SRC_PATH): | ||
raise ValueError("Could not find %r" % VCOMP140_SRC_PATH) | ||
|
||
if not op.isdir("build"): | ||
raise RuntimeError("Could not find ./build/ folder. " | ||
"Run 'python setup.py build' first") | ||
target_folders = glob(TARGET_FOLDER_GLOB_PATTERN) | ||
if len(target_folders) == 0: | ||
raise RuntimeError("Could not find folder matching '%s'" | ||
% TARGET_FOLDER_GLOB_PATTERN) | ||
if len(target_folders) > 1: | ||
raise RuntimeError("Found too many target folders: '%s'" | ||
% "', '".join(target_folders)) | ||
target_folder = op.abspath(op.join(target_folders[0], ".libs")) | ||
|
||
# create the "sklearn/.libs" subfolder | ||
if not op.exists(target_folder): | ||
os.mkdir(target_folder) | ||
|
||
print("Copying '%s' to:\n%s" % (VCOMP140_SRC_PATH, target_folder)) | ||
shutil.copy2(VCOMP140_SRC_PATH, target_folder) | ||
|
||
# Generate the _distributor_init file in the source tree. | ||
print("Generating the '_distributor_init.py' file in:") | ||
print(make_distributor_init("sklearn", op.basename(VCOMP140_SRC_PATH))) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Submodule scikit-learn
updated
1084 files
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.