Skip to content

Commit 473a6f0

Browse files
committed
BUG: distutils: use correct top-level package name
Here, we align the extra-dll name to the one that auditwheel uses, and we handle the case where 1) there is more than one root package and 2) the root package name is different than the distribution name
1 parent 986268b commit 473a6f0

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

numpy/distutils/command/build_ext.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def run(self):
120120
self.compiler.show_customization()
121121

122122
# Setup directory for storing generated extra DLL files on Windows
123-
self.extra_dll_dir = os.path.join(self.build_temp, 'extra-dll')
123+
self.extra_dll_dir = os.path.join(self.build_temp, '.libs')
124124
if not os.path.isdir(self.extra_dll_dir):
125125
os.makedirs(self.extra_dll_dir)
126126

@@ -262,15 +262,25 @@ def run(self):
262262
self.build_extensions()
263263

264264
# Copy over any extra DLL files
265-
runtime_lib_dir = os.path.join(
266-
self.build_lib, self.distribution.get_name(), 'extra-dll')
267-
for fn in os.listdir(self.extra_dll_dir):
268-
if not fn.lower().endswith('.dll'):
269-
continue
270-
if not os.path.isdir(runtime_lib_dir):
271-
os.makedirs(runtime_lib_dir)
272-
runtime_lib = os.path.join(self.extra_dll_dir, fn)
273-
copy_file(runtime_lib, runtime_lib_dir)
265+
# FIXME: In the case where there are more than two packages,
266+
# we blindly assume that both packages need all of the libraries,
267+
# resulting in a larger wheel than is required. This should be fixed,
268+
# but it's so rare that I won't bother to handle it.
269+
pkg_roots = set(
270+
self.get_ext_fullname(ext.name).split('.')[0]
271+
for ext in self.extensions
272+
)
273+
for pkg_root in pkg_roots:
274+
shared_lib_dir = os.path.join(pkg_root, '.libs')
275+
if not self.inplace:
276+
shared_lib_dir = os.path.join(self.build_lib, shared_lib_dir)
277+
if not os.path.isdir(shared_lib_dir):
278+
os.makedirs(shared_lib_dir)
279+
for fn in os.listdir(self.extra_dll_dir):
280+
if not fn.lower().endswith('.dll'):
281+
continue
282+
runtime_lib = os.path.join(self.extra_dll_dir, fn)
283+
copy_file(runtime_lib, shared_lib_dir)
274284

275285
def swig_sources(self, sources):
276286
# Do nothing. Swig sources have beed handled in build_src command.

numpy/distutils/misc_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2290,7 +2290,7 @@ def generate_config_py(target):
22902290
# For gfortran+msvc combination, extra shared libraries may exist
22912291
f.write("""
22922292
import os
2293-
extra_dll_dir = os.path.join(os.path.dirname(__file__), 'extra-dll')
2293+
extra_dll_dir = os.path.join(os.path.dirname(__file__), '.libs')
22942294
if os.path.isdir(extra_dll_dir):
22952295
os.environ["PATH"] += os.pathsep + extra_dll_dir
22962296
""")

0 commit comments

Comments
 (0)