Repository: pypa/pip

Issue:
Automatically enable PEP 517 when `--config-settings` are used for legacy projects
When using `--config-settings` with a project that does not have a `pyproject.toml`, they are silently ignored.

I see two possibilities:
- warn that config settings are ignored
- automatically enable pep517 (and warn that we are doing this)


Discussion:
Nice catch! My vote is toward auto-enabling pep517 for them.

Resolving patch:
diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py
--- a/src/pip/_internal/req/req_install.py
+++ b/src/pip/_internal/req/req_install.py
@@ -181,6 +181,16 @@ def __init__(
         # but after loading this flag should be treated as read only.
         self.use_pep517 = use_pep517
 
+        # If config settings are provided, enforce PEP 517.
+        if self.config_settings:
+            if self.use_pep517 is False:
+                logger.warning(
+                    "--no-use-pep517 ignored for %s "
+                    "because --config-settings are specified.",
+                    self,
+                )
+            self.use_pep517 = True
+
         # This requirement needs more preparation before it can be built
         self.needs_more_preparation = False
 
@@ -508,15 +518,7 @@ def load_pyproject_toml(self) -> None:
         )
 
         if pyproject_toml_data is None:
-            if self.config_settings:
-                deprecated(
-                    reason=f"Config settings are ignored for project {self}.",
-                    replacement=(
-                        "to use --use-pep517 or add a "
-                        "pyproject.toml file to the project"
-                    ),
-                    gone_in="24.0",
-                )
+            assert not self.config_settings
             self.use_pep517 = False
             return
 
@@ -827,6 +829,13 @@ def install(
         )
 
         if self.editable and not self.is_wheel:
+            if self.config_settings:
+                logger.warning(
+                    "--config-settings ignored for legacy editable install of %s. "
+                    "Consider upgrading to a version of setuptools "
+                    "that supports PEP 660 (>= 64).",
+                    self,
+                )
             install_editable_legacy(
                 global_options=global_options if global_options is not None else [],
                 prefix=prefix,


Test patch:
diff --git a/tests/functional/test_config_settings.py b/tests/functional/test_config_settings.py
--- a/tests/functional/test_config_settings.py
+++ b/tests/functional/test_config_settings.py
@@ -107,6 +107,26 @@ def make_project(
     return name, version, project_dir
 
 
+def test_config_settings_implies_pep517(
+    script: PipTestEnvironment, tmp_path: Path
+) -> None:
+    """Test that setup.py bdist_wheel is not used when config settings are."""
+    pkg_path = tmp_path / "pkga"
+    pkg_path.mkdir()
+    pkg_path.joinpath("setup.py").write_text(
+        "from setuptools import setup; setup(name='pkga')\n"
+    )
+    result = script.pip(
+        "wheel",
+        "--config-settings",
+        "FOO=Hello",
+        pkg_path,
+        cwd=tmp_path,
+    )
+    assert "Successfully built pkga" in result.stdout
+    assert "Preparing metadata (pyproject.toml)" in result.stdout
+
+
 def test_backend_sees_config(script: PipTestEnvironment) -> None:
     name, version, project_dir = make_project(script.scratch_path)
     script.pip(