Skip to content

Commit c95d8b2

Browse files
committed
Let --config-settings imply PEP 517
1 parent 5efa3e8 commit c95d8b2

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

news/11915.feature.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Automatically use the setuptools PEP 517 build backend when ``--config-settings`` is
2+
used for projects without ``pyproject.toml``.

src/pip/_internal/req/req_install.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,16 @@ def __init__(
181181
# but after loading this flag should be treated as read only.
182182
self.use_pep517 = use_pep517
183183

184+
# If config settings are provided, enforce PEP 517.
185+
if self.config_settings:
186+
if self.use_pep517 is False:
187+
raise InstallationError(
188+
f"Disabling PEP 517 processing is not allowed for {self} "
189+
f"when --config-settings are specified."
190+
)
191+
else:
192+
self.use_pep517 = True
193+
184194
# This requirement needs more preparation before it can be built
185195
self.needs_more_preparation = False
186196

@@ -508,15 +518,7 @@ def load_pyproject_toml(self) -> None:
508518
)
509519

510520
if pyproject_toml_data is None:
511-
if self.config_settings:
512-
deprecated(
513-
reason=f"Config settings are ignored for project {self}.",
514-
replacement=(
515-
"to use --use-pep517 or add a "
516-
"pyproject.toml file to the project"
517-
),
518-
gone_in="24.0",
519-
)
521+
assert not self.config_settings
520522
self.use_pep517 = False
521523
return
522524

tests/functional/test_config_settings.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,26 @@ def make_project(
107107
return name, version, project_dir
108108

109109

110+
def test_config_settings_implies_pep517(
111+
script: PipTestEnvironment, tmp_path: Path
112+
) -> None:
113+
"""Test that setup.py bdist_wheel is not used when config settings are."""
114+
pkg_path = tmp_path / "pkga"
115+
pkg_path.mkdir()
116+
pkg_path.joinpath("setup.py").write_text(
117+
"from setuptools import setup; setup(name='pkga')\n"
118+
)
119+
result = script.pip(
120+
"wheel",
121+
"--config-settings",
122+
"FOO=Hello",
123+
pkg_path,
124+
cwd=tmp_path,
125+
)
126+
assert "Successfully built pkga" in result.stdout
127+
assert "Preparing metadata (pyproject.toml)" in result.stdout
128+
129+
110130
def test_backend_sees_config(script: PipTestEnvironment) -> None:
111131
name, version, project_dir = make_project(script.scratch_path)
112132
script.pip(

0 commit comments

Comments
 (0)