Skip to content

Commit

Permalink
Add msvcp140.dll to Windows 64 bit wheels (#24631)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmarmo committed Oct 14, 2022
1 parent 0c8820b commit 5c897f1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions build_tools/github/vendor.py
Expand Up @@ -17,6 +17,7 @@
VCOMP140_SRC_PATH = "C:\\Windows\\System32\\vcomp140.dll"
VCRUNTIME140_SRC_PATH = "C:\\Windows\\System32\\vcruntime140.dll"
VCRUNTIME140_1_SRC_PATH = "C:\\Windows\\System32\\vcruntime140_1.dll"
MSVCP140_SRC_PATH = "C:\\Windows\\System32\\msvcp140.dll"


def make_distributor_init_32_bits(
Expand Down Expand Up @@ -65,12 +66,13 @@ def make_distributor_init_64_bits(
vcomp140_dll_filename,
vcruntime140_dll_filename,
vcruntime140_1_dll_filename,
msvcp140_dll_filename,
):
"""Create a _distributor_init.py file for 64-bit architectures.
This file is imported first when importing the sklearn package
so as to pre-load the vendored vcomp140.dll, vcruntime140.dll
and vcruntime140_1.dll.
so as to pre-load the vendored vcomp140.dll, vcruntime140.dll,
vcruntime140_1.dll and msvcp140.dll.
"""
with open(distributor_init, "wt") as f:
f.write(
Expand All @@ -97,13 +99,16 @@ def make_distributor_init_64_bits(
vcomp140_dll_filename = op.join(libs_path, "{0}")
vcruntime140_dll_filename = op.join(libs_path, "{1}")
vcruntime140_1_dll_filename = op.join(libs_path, "{2}")
msvcp140_dll_filename = op.join(libs_path, "{3}")
WinDLL(op.abspath(vcomp140_dll_filename))
WinDLL(op.abspath(vcruntime140_dll_filename))
WinDLL(op.abspath(vcruntime140_1_dll_filename))
WinDLL(op.abspath(msvcp140_dll_filename))
""".format(
vcomp140_dll_filename,
vcruntime140_dll_filename,
vcruntime140_1_dll_filename,
msvcp140_dll_filename,
)
)
)
Expand All @@ -120,12 +125,16 @@ def main(wheel_dirname, bitness):
if not op.exists(VCRUNTIME140_1_SRC_PATH) and bitness == "64":
raise ValueError(f"Could not find {VCRUNTIME140_1_SRC_PATH}.")

if not op.exists(MSVCP140_SRC_PATH) and bitness == "64":
raise ValueError(f"Could not find {MSVCP140_SRC_PATH}.")

if not op.isdir(wheel_dirname):
raise RuntimeError(f"Could not find {wheel_dirname} file.")

vcomp140_dll_filename = op.basename(VCOMP140_SRC_PATH)
vcruntime140_dll_filename = op.basename(VCRUNTIME140_SRC_PATH)
vcruntime140_1_dll_filename = op.basename(VCRUNTIME140_1_SRC_PATH)
msvcp140_dll_filename = op.basename(MSVCP140_SRC_PATH)

target_folder = op.join(wheel_dirname, TARGET_FOLDER)
distributor_init = op.join(wheel_dirname, DISTRIBUTOR_INIT)
Expand All @@ -144,6 +153,9 @@ def main(wheel_dirname, bitness):
print(f"Copying {VCRUNTIME140_1_SRC_PATH} to {target_folder}.")
shutil.copy2(VCRUNTIME140_1_SRC_PATH, target_folder)

print(f"Copying {MSVCP140_SRC_PATH} to {target_folder}.")
shutil.copy2(MSVCP140_SRC_PATH, target_folder)

# Generate the _distributor_init file in the source tree
print("Generating the '_distributor_init.py' file.")
if bitness == "32":
Expand All @@ -156,6 +168,7 @@ def main(wheel_dirname, bitness):
vcomp140_dll_filename,
vcruntime140_dll_filename,
vcruntime140_1_dll_filename,
msvcp140_dll_filename,
)


Expand Down

0 comments on commit 5c897f1

Please sign in to comment.