delvewheel
delvewheel copied to clipboard
Option to patch all dlls in wheel ?
Hi !
I noticed that delvewheel
will inspect only *.pyd
files for dependencies while auditwheel
goes through all the *.so
files in the wheel.
Looking at the delvewheel
code it looks like a matter of few lines to extend the search to include also dll
files and I can create a proper MR that also introduces a cli switch if this makes it easier for you.
diff --git a/delvewheel/_wheel_repair.py b/delvewheel/_wheel_repair.py
index 58e4410..cdb625e 100644
--- a/delvewheel/_wheel_repair.py
+++ b/delvewheel/_wheel_repair.py
@@ -502,7 +502,7 @@ class WheelRepair:
item_lower = item.lower()
if item_lower.endswith('.py') and item_lower != '__init__.py':
self._patch_py_file(item_path, libs_dir, load_order_filename, depth)
- elif item_lower.endswith('.pyd'):
+ elif item_lower.endswith('.pyd') or item_lower.endswith('.dll'):
namespace_root_ext_modules.add(item_path)
elif os.path.isdir(item_path) and \
(item not in self._root_level_module_names(package_dir) or self._get_init(item_path)):
@@ -626,7 +626,7 @@ class WheelRepair:
if root == self._data_dir:
dirnames[:] = set(dirnames) & {'platlib', 'purelib'}
for filename in filenames:
- if filename.lower().endswith('.pyd'):
+ if filename.lower().endswith('.pyd') or filename.lower().endswith('.dll'):
extension_module_path = os.path.join(root, filename)
extension_module_paths.append(extension_module_path)
discovered, _, ignored, not_found = _dll_utils.get_all_needed(extension_module_path, self._no_dlls, self._wheel_dirs, 'ignore', False, False, self._verbose)
@@ -731,7 +731,7 @@ class WheelRepair:
if root == self._data_dir:
dirnames[:] = set(dirnames) & {'platlib', 'purelib'}
for filename in filenames:
- if filename.lower().endswith('.pyd'):
+ if filename.lower().endswith('.pyd') or filename.lower().endswith('.dll'):
extension_module_path = os.path.join(root, filename)
dll_arch = _dll_utils.get_arch(extension_module_path)
if dll_arch != self._arch:
Do you see any issues enabling this feature ?
Usecase:
We want to bundle C++ libraries that are loaded upon runtime via python. This results in dlls in the wheel that are not linked by any pyd
file and thus they are not discovered by the method that delvewheel currently employs.
Using --add-dll
does not really help here because we need to add a big number of dependencies manually and we loose the mangling that delvewheel
offers which we require since we are going to bundle 3rd-party libraries.
Thank you !