@@ -32,32 +32,24 @@ def prepare_distribution_metadata(
3232 # Set up the build isolation, if this requirement should be isolated
3333 should_isolate = self .req .use_pep517 and build_isolation
3434 if should_isolate :
35- self ._setup_isolation (finder )
35+ # Setup an isolated environment and install the build backend static
36+ # requirements in it.
37+ self ._prepare_build_backend (finder )
38+ # Check that if the requirement is editable, it either supports PEP 660 or
39+ # has a setup.py or a setup.cfg. For regular requirements such a sanity
40+ # check is done in load_pyproject_toml. For editables this cannot be done
41+ # earlier because we support editable installation of projects with
42+ # pyproject.toml with setup.cfg and no setup.py (sigh). And we need to setup
43+ # the build backend to verify it supports build_editable. It also can not be
44+ # done later, because merely calling get_requires_for_build_wheel() for the
45+ # setuptools __legacy__ backend creates the egg-info directory, including
46+ # UNKNOWN.egg-info if it is misconfigured, and we don't want that.
47+ self .req .isolated_editable_sanity_check ()
48+ # Install the dynamic build requirements.
49+ self ._install_build_reqs (finder )
3650
3751 self .req .prepare_metadata ()
3852
39- def _setup_isolation (self , finder : PackageFinder ) -> None :
40- self ._prepare_build_backend (finder )
41- # Check that if the requirement is editable, it either supports PEP 660
42- # or has a setup.py or a setup.cfg. This cannot be done earlier because
43- # we need to setup the build backend to verify it supports build_editable,
44- # nor can it be done later, because merely calling _get_build_requires_wheel()
45- # for the setuptools __legacy__ backend creates the egg-info directory,
46- # including UNKNOWN.egg-info if it is misconfigured, and we don't want that.
47- self .req .isolated_editable_sanity_check ()
48- # Install any extra build dependencies that the backend requests.
49- # This must be done in a second pass, as the pyproject.toml
50- # dependencies must be installed before we can call the backend.
51- if (
52- self .req .editable
53- and self .req .permit_editable_wheels
54- and self .req .supports_pyproject_editable ()
55- ):
56- build_reqs = self ._get_build_requires_editable ()
57- else :
58- build_reqs = self ._get_build_requires_wheel ()
59- self ._install_build_reqs (finder , build_reqs )
60-
6153 def _prepare_build_backend (self , finder : PackageFinder ) -> None :
6254 # Isolate in a BuildEnvironment and install the build-time
6355 # requirements.
@@ -102,8 +94,19 @@ def _get_build_requires_editable(self) -> Iterable[str]:
10294 with backend .subprocess_runner (runner ):
10395 return backend .get_requires_for_build_editable ()
10496
105- def _install_build_reqs (self , finder : PackageFinder , reqs : Iterable [str ]) -> None :
106- conflicting , missing = self .req .build_env .check_requirements (reqs )
97+ def _install_build_reqs (self , finder : PackageFinder ) -> None :
98+ # Install any extra build dependencies that the backend requests.
99+ # This must be done in a second pass, as the pyproject.toml
100+ # dependencies must be installed before we can call the backend.
101+ if (
102+ self .req .editable
103+ and self .req .permit_editable_wheels
104+ and self .req .supports_pyproject_editable ()
105+ ):
106+ build_reqs = self ._get_build_requires_editable ()
107+ else :
108+ build_reqs = self ._get_build_requires_wheel ()
109+ conflicting , missing = self .req .build_env .check_requirements (build_reqs )
107110 if conflicting :
108111 self ._raise_conflicts ("the backend dependencies" , conflicting )
109112 self .req .build_env .install_requirements (
0 commit comments