Skip to content

Commit

Permalink
Ignore .pyd files in .data directory outside of .data/purelib and .da…
Browse files Browse the repository at this point in the history
…ta/platlib

Outside of the purelib and platlib directores, .pyd files should be
treated as data rather than modules.
  • Loading branch information
adang1345 committed Aug 2, 2023
1 parent f8e5b7d commit 0dd8978
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
12 changes: 9 additions & 3 deletions delvewheel/_wheel_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@ def __init__(self,
# determine the CPU architecture of the wheel
self._arch = _dll_list.MachineType.platform_tag_to_type(platform_tag)
if not self._arch:
for root, _, filenames in os.walk(self._extract_dir):
for root, dirnames, filenames in os.walk(self._extract_dir):
if root == self._data_dir:
dirnames[:] = set(dirnames) & {'platlib', 'purelib'}
for filename in filenames:
if filename.lower().endswith('.pyd'):
arch = _dll_utils.get_arch(os.path.join(root, filename))
Expand Down Expand Up @@ -553,7 +555,9 @@ def show(self) -> None:
ignored_dll_names = set()
not_found_dll_names = set()
extension_module_paths = []
for root, _, filenames in os.walk(self._extract_dir):
for root, dirnames, filenames in os.walk(self._extract_dir):
if root == self._data_dir:
dirnames[:] = set(dirnames) & {'platlib', 'purelib'}
for filename in filenames:
if filename.lower().endswith('.pyd'):
extension_module_path = os.path.join(root, filename)
Expand Down Expand Up @@ -642,7 +646,9 @@ def repair(self, target: str, no_mangles: set, no_mangle_all: bool, strip: bool,
ignored_dll_names = set()
extension_module_paths = []
has_top_level_ext_module = False
for root, _, filenames in os.walk(self._extract_dir):
for root, dirnames, filenames in os.walk(self._extract_dir):
if root == self._data_dir:
dirnames[:] = set(dirnames) & {'platlib', 'purelib'}
for filename in filenames:
if filename.lower().endswith('.pyd'):
extension_module_path = os.path.join(root, filename)
Expand Down
9 changes: 9 additions & 0 deletions tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ def test_wrong_platform(self):
output = subprocess.check_output(['delvewheel', 'show', 'no_dependencies/h3ronpy-0.16.0-cp38-abi3-macosx_10_7_x86_64.whl'], text=True)
self.assertIn('will be copied into the wheel.\n None', output)

def test_ignore_data(self):
"""Ignore .pyd file in .data/data directory."""
output = subprocess.check_output(['delvewheel', 'show', 'simpleext/simpleext-0.0.1-0ignore-cp310-cp310-win_amd64.whl'], text=True)
self.assertIn('will be copied into the wheel.\n None', output)

class RepairTestCase(TestCase):
"""Tests for delvewheel repair"""
Expand Down Expand Up @@ -987,6 +991,11 @@ def test_namespace10(self):
],
)

def test_ignore_data(self):
"""Ignore .pyd file in .data/data directory."""
check_call(['delvewheel', 'repair', 'simpleext/simpleext-0.0.1-0ignore-cp310-cp310-win_amd64.whl'])
self.assertFalse(os.path.exists('wheelhouse/simpleext-0.0.1-0ignore-cp310-cp310-win_amd64.whl'))


class NeededTestCase(unittest.TestCase):
"""Tests for delvewheel needed"""
Expand Down
Binary file not shown.

0 comments on commit 0dd8978

Please sign in to comment.