55import os
66import pathlib
77import re
8+ import shlex
89import shutil
910import subprocess
1011import sys
@@ -165,7 +166,7 @@ def test_command_line_overrides_pip_conf(pip_with_index_conf, runner):
165166 ),
166167)
167168def test_command_line_setuptools_read (
168- runner , make_package , install_requires , expected_output
169+ runner , make_package , minimal_wheels_path , install_requires , expected_output
169170):
170171 package_dir = make_package (
171172 name = "fake-setuptools-a" ,
@@ -177,7 +178,7 @@ def test_command_line_setuptools_read(
177178 (
178179 str (package_dir / "setup.py" ),
179180 "--find-links" ,
180- MINIMAL_WHEELS_PATH ,
181+ minimal_wheels_path . as_posix () ,
181182 "--no-build-isolation" ,
182183 ),
183184 )
@@ -1794,6 +1795,41 @@ def test_forwarded_args(PyPIRepository, runner):
17941795 assert set (pip_args ).issubset (set (args [0 ]))
17951796
17961797
1798+ @pytest .mark .parametrize (
1799+ "pip_args" ,
1800+ (
1801+ pytest .param (
1802+ ("--use-pep517" , "--global-option=build_ext" ),
1803+ id = "use-pep517 and global-option" ,
1804+ ),
1805+ pytest .param (
1806+ ("--no-use-pep517" , "--build-option=build_ext" ),
1807+ id = "no-use-pep517 and build-option" ,
1808+ ),
1809+ ),
1810+ )
1811+ @mock .patch ("piptools.scripts.compile.PyPIRepository" )
1812+ def test_forwarded_args_filter_deprecated (PyPIRepository , runner , pip_args ):
1813+ """
1814+ Test the cli args (``--pip-args 'arg...'``) are filtered out if pip no longer supports them.
1815+ """
1816+ pathlib .Path ("requirements.in" ).write_text ("" , encoding = "utf-8" )
1817+
1818+ cli_args = ("--no-annotate" , "--generate-hashes" )
1819+ runner .invoke (cli , [* cli_args , "--pip-args" , shlex .join (pip_args )])
1820+ pip_option_keys = {pip_arg .split ("=" )[0 ] for pip_arg in pip_args }
1821+
1822+ (first_posarg , * _tail_args ), _kwargs = PyPIRepository .call_args
1823+
1824+ pip_current_version = get_pip_version_for_python_executable (sys .executable )
1825+ pip_breaking_version = Version ("25.3" )
1826+
1827+ if pip_current_version >= pip_breaking_version : # pragma: >=3.9 cover
1828+ assert set (first_posarg ) ^ pip_option_keys
1829+ else :
1830+ assert set (first_posarg ) & pip_option_keys
1831+
1832+
17971833@pytest .mark .parametrize (
17981834 ("cli_option" , "infile_option" , "expected_package" ),
17991835 (
@@ -3430,7 +3466,12 @@ def test_pass_pip_cache_to_pip_args(tmpdir, runner, current_resolver):
34303466
34313467
34323468@backtracking_resolver_only
3433- def test_compile_recursive_extras_static (runner , tmp_path , current_resolver ):
3469+ def test_compile_recursive_extras_static (
3470+ runner ,
3471+ tmp_path ,
3472+ minimal_wheels_path ,
3473+ current_resolver ,
3474+ ):
34343475 (tmp_path / "pyproject.toml" ).write_text (
34353476 dedent (
34363477 """
@@ -3454,7 +3495,7 @@ def test_compile_recursive_extras_static(runner, tmp_path, current_resolver):
34543495 "--extra" ,
34553496 "dev" ,
34563497 "--find-links" ,
3457- os . fspath ( MINIMAL_WHEELS_PATH ),
3498+ minimal_wheels_path . as_posix ( ),
34583499 os .fspath (tmp_path / "pyproject.toml" ),
34593500 "--output-file" ,
34603501 "-" ,
@@ -3474,7 +3515,9 @@ def test_compile_recursive_extras_static(runner, tmp_path, current_resolver):
34743515
34753516
34763517@backtracking_resolver_only
3477- def test_compile_recursive_extras_build_targets (runner , tmp_path , current_resolver ):
3518+ def test_compile_recursive_extras_build_targets (
3519+ runner , tmp_path , minimal_wheels_path , current_resolver
3520+ ):
34783521 (tmp_path / "pyproject.toml" ).write_text (
34793522 dedent (
34803523 """
@@ -3500,7 +3543,7 @@ def test_compile_recursive_extras_build_targets(runner, tmp_path, current_resolv
35003543 "--build-deps-for" ,
35013544 "wheel" ,
35023545 "--find-links" ,
3503- os . fspath ( MINIMAL_WHEELS_PATH ),
3546+ minimal_wheels_path . as_posix ( ),
35043547 os .fspath (tmp_path / "pyproject.toml" ),
35053548 "--output-file" ,
35063549 "-" ,
@@ -3526,6 +3569,7 @@ def test_compile_recursive_extras_build_targets(runner, tmp_path, current_resolv
35263569def test_compile_build_targets_setuptools_no_wheel_dep (
35273570 runner ,
35283571 tmp_path ,
3572+ minimal_wheels_path ,
35293573 current_resolver ,
35303574):
35313575 """Check that user requests apply to build dependencies.
@@ -3566,7 +3610,7 @@ def test_compile_build_targets_setuptools_no_wheel_dep(
35663610 "--build-deps-for" ,
35673611 "wheel" ,
35683612 "--find-links" ,
3569- os . fspath ( MINIMAL_WHEELS_PATH ),
3613+ minimal_wheels_path . as_posix ( ),
35703614 os .fspath (tmp_path / "pyproject.toml" ),
35713615 "--constraint" ,
35723616 os .fspath (tmp_path / "constraints.txt" ),
0 commit comments