feat: make the {project} placeholder available to repair-wheel-command (#2589)

* Make the {project} placeholder available to repair-wheel-command

* Add separate test for {project} placeholder in repair-wheel-command

* Make the {project} placeholder available to repair-wheel-command

* reduce duplicated work in tests

* Use a valid wheel filename for the post-repair name

---------

Co-authored-by: Joe Rickerby <joerick@mac.com>
This commit is contained in:
Alexander Condello
2025-11-10 20:59:32 -05:00
committed by GitHub
co-authored by Joe Rickerby
parent ccbae30b53
commit f6c810852d
7 changed files with 58 additions and 2 deletions
+40
View File
@@ -1,4 +1,5 @@
import subprocess
import textwrap
from contextlib import nullcontext as does_not_raise
import pytest
@@ -56,3 +57,42 @@ def test(tmp_path, capfd):
# We only produced one wheel (perhaps Pyodide)
# check that it has the right name
assert result[0].startswith("spam-0.1.0-py2-none-")
@pytest.mark.parametrize(
"repair_command",
[
"python repair.py {wheel} {dest_dir}",
"python {package}/repair.py {wheel} {dest_dir}",
"python {project}/repair.py {wheel} {dest_dir}",
],
ids=["no-placeholder", "package-placeholder", "project-placeholder"],
)
def test_repair_wheel_command_structure(tmp_path, repair_command):
project_dir = tmp_path / "project"
project = test_projects.new_c_project()
project.files["repair.py"] = textwrap.dedent("""
import shutil
import sys
from pathlib import Path
wheel = Path(sys.argv[1])
dest_dir = Path(sys.argv[2])
dest_dir.mkdir(parents=True, exist_ok=True)
shutil.copy(wheel, dest_dir / "spamrepaired-0.0.1-py-none-any.whl")
""")
# Combined test for repair wheel command formats (plain, {package}, {project})
project.generate(project_dir)
result = utils.cibuildwheel_run(
project_dir,
add_env={
"CIBW_REPAIR_WHEEL_COMMAND": repair_command,
"CIBW_ARCHS": "native",
},
single_python=True,
)
assert result == ["spamrepaired-0.0.1-py-none-any.whl"]