Skip to content

Commit 0befe7d

Browse files
committed
Fix and expand PEP 660 detection
Since there is no 'setup.py develop' fallback anymore, this check needs to be updated, and also needs to run when not using build isolation.
1 parent 32ec3f0 commit 0befe7d

File tree

2 files changed

+14
-26
lines changed

2 files changed

+14
-26
lines changed

src/pip/_internal/distributions/sdist.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,17 @@ def prepare_distribution_metadata(
4646
# Setup an isolated environment and install the build backend static
4747
# requirements in it.
4848
self._prepare_build_backend(build_env_installer)
49-
# Check that if the requirement is editable, it either supports PEP 660 or
50-
# has a setup.py or a setup.cfg. This cannot be done earlier because we need
51-
# to setup the build backend to verify it supports build_editable, nor can
52-
# it be done later, because we want to avoid installing build requirements
53-
# needlessly. Doing it here also works around setuptools generating
54-
# UNKNOWN.egg-info when running get_requires_for_build_wheel on a directory
55-
# without setup.py nor setup.cfg.
56-
self.req.isolated_editable_sanity_check()
49+
# Check that the build backend supports PEP 660. This cannot be done
50+
# earlier because we need to setup the build backend to verify it
51+
# supports build_editable, nor can it be done later, because we want
52+
# to avoid installing build requirements needlessly.
53+
self.req.editable_sanity_check()
5754
# Install the dynamic build requirements.
5855
self._install_build_reqs(build_env_installer)
56+
else:
57+
# When not using build isolation, we still need to check that
58+
# the build backend supports PEP 660.
59+
self.req.editable_sanity_check()
5960
# Check if the current environment provides build dependencies
6061
if check_build_deps:
6162
pyproject_requires = self.req.pyproject_requires

src/pip/_internal/req/req_install.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -464,13 +464,6 @@ def setup_py_path(self) -> str:
464464

465465
return setup_py
466466

467-
@property
468-
def setup_cfg_path(self) -> str:
469-
assert self.source_dir, f"No source dir for {self}"
470-
setup_cfg = os.path.join(self.unpacked_source_directory, "setup.cfg")
471-
472-
return setup_cfg
473-
474467
@property
475468
def pyproject_toml_path(self) -> str:
476469
assert self.source_dir, f"No source dir for {self}"
@@ -496,21 +489,15 @@ def load_pyproject_toml(self) -> None:
496489
backend_path=backend_path,
497490
)
498491

499-
def isolated_editable_sanity_check(self) -> None:
492+
def editable_sanity_check(self) -> None:
500493
"""Check that an editable requirement if valid for use with PEP 517/518.
501494
502-
This verifies that an editable that has a pyproject.toml either supports PEP 660
503-
or as a setup.py or a setup.cfg
495+
This verifies that an editable has a build backend that supports PEP 660.
504496
"""
505-
if (
506-
self.editable
507-
and not self.supports_pyproject_editable
508-
and not os.path.isfile(self.setup_py_path)
509-
and not os.path.isfile(self.setup_cfg_path)
510-
):
497+
if self.editable and not self.supports_pyproject_editable:
511498
raise InstallationError(
512-
f"Project {self} has a 'pyproject.toml' and its build "
513-
f"backend is missing the 'build_editable' hook, so "
499+
f"Project {self} uses a build backend"
500+
f"that is missing the 'build_editable' hook, so "
514501
f"it cannot be installed in editable mode. "
515502
f"Consider using a build backend that supports PEP 660."
516503
)

0 commit comments

Comments
 (0)