Skip to content

Commit

Permalink
Copy wheel as-is to destination if no external dependencies are needed
Browse files Browse the repository at this point in the history
This better matches the behavior of auditwheel and delocate when run
with cibuildwheel.
  • Loading branch information
adang1345 committed Aug 10, 2023
1 parent 25ffd4a commit 87864a4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
3 changes: 3 additions & 0 deletions delvewheel/_wheel_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,9 @@ def repair(self, target: str, no_mangles: set, no_mangle_all: bool, strip: bool,
raise FileNotFoundError(f'{dll_name} not found')
if not dependency_paths and not extra_dependency_paths:
print('no external dependencies are needed')
os.makedirs(target, exist_ok=True)
shutil.copy2(self._whl_path, target)
print(f'wheel copied to {os.path.abspath(os.path.join(target, self._whl_name))}')
return

# Warn if namespace package does not exist
Expand Down
35 changes: 24 additions & 11 deletions tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,21 +642,34 @@ def test_already_repaired(self):
remove('wheelhouse/simpleext-0.0.1-cp310-cp310-win_amd64.whl')

def test_pure_python(self):
"""Repair is canceled if wheel is pure Python."""
output = subprocess.check_output(['delvewheel', 'repair', 'no_dependencies/more_itertools-9.0.0-py3-none-any.whl'], text=True)
self.assertIn('no external dependencies are needed', output)
"""If wheel is pure Python, no repair happens, and the wheel is copied
as-is."""
try:
output = subprocess.check_output(['delvewheel', 'repair', 'no_dependencies/more_itertools-9.0.0-py3-none-any.whl'], text=True)
self.assertIn('no external dependencies are needed', output)
self.assertTrue(os.path.isfile('wheelhouse/more_itertools-9.0.0-py3-none-any.whl'))
finally:
remove('wheelhouse/more_itertools-9.0.0-py3-none-any.whl')

def test_no_external(self):
"""Repair is canceled if wheel has an extension module that has no
external dependencies."""
output = subprocess.check_output(['delvewheel', 'repair', 'no_dependencies/h3ronpy-0.16.0-cp38-abi3-win_amd64.whl'], text=True)
self.assertIn('no external dependencies are needed', output)
"""If wheel has an extension module that has no external dependencies,
no repair happens, and the wheel is copied as-is."""
try:
output = subprocess.check_output(['delvewheel', 'repair', 'no_dependencies/h3ronpy-0.16.0-cp38-abi3-win_amd64.whl'], text=True)
self.assertIn('no external dependencies are needed', output)
self.assertTrue(os.path.isfile('wheelhouse/h3ronpy-0.16.0-cp38-abi3-win_amd64.whl'))
finally:
remove('wheelhouse/h3ronpy-0.16.0-cp38-abi3-win_amd64.whl')

def test_wrong_platform(self):
"""Repair is canceled if wheel has an extension module that is not for
Windows."""
output = subprocess.check_output(['delvewheel', 'repair', 'no_dependencies/h3ronpy-0.16.0-cp38-abi3-macosx_10_7_x86_64.whl'], text=True)
self.assertIn('no external dependencies are needed', output)
"""If wheel has an extension module that is not for Windows, no repair
happens, and the wheel is copied as-is."""
try:
output = subprocess.check_output(['delvewheel', 'repair', 'no_dependencies/h3ronpy-0.16.0-cp38-abi3-macosx_10_7_x86_64.whl'], text=True)
self.assertIn('no external dependencies are needed', output)
self.assertTrue(os.path.isfile('wheelhouse/h3ronpy-0.16.0-cp38-abi3-macosx_10_7_x86_64.whl'))
finally:
remove('wheelhouse/h3ronpy-0.16.0-cp38-abi3-macosx_10_7_x86_64.whl')

def test_header_space(self):
"""PE header space is added correctly in name-mangling step."""
Expand Down

0 comments on commit 87864a4

Please sign in to comment.