@@ -32,33 +32,22 @@ def prepare_distribution_metadata(
32
32
# Set up the build isolation, if this requirement should be isolated
33
33
should_isolate = self .req .use_pep517 and build_isolation
34
34
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. This cannot be done earlier because we need
40
+ # to setup the build backend to verify it supports build_editable, nor can
41
+ # it be done later, because we want to avoid installing build requirements
42
+ # needlessly. Doing it here also works around setuptools generating
43
+ # UNKNOWN.egg-info when running get_requires_for_build_wheel on a directory
44
+ # without setup.py nor setup.cfg.
45
+ self .req .isolated_editable_sanity_check ()
46
+ # Install the dynamic build requirements.
47
+ self ._install_build_reqs (finder )
36
48
37
49
self .req .prepare_metadata ()
38
50
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 or has a
42
- # setup.py or a setup.cfg. This cannot be done earlier because we need to setup
43
- # the build backend to verify it supports build_editable, nor can it be done
44
- # later, because we want to avoid installing build requirements needlessly.
45
- # Doing it here also works around setuptools generating UNKNOWN.egg-info when
46
- # running get_requires_for_build_wheel on a directory without setup.py nor
47
- # setup.cfg.
48
- self .req .isolated_editable_sanity_check ()
49
- # Install any extra build dependencies that the backend requests.
50
- # This must be done in a second pass, as the pyproject.toml
51
- # dependencies must be installed before we can call the backend.
52
- if (
53
- self .req .editable
54
- and self .req .permit_editable_wheels
55
- and self .req .supports_pyproject_editable ()
56
- ):
57
- build_reqs = self ._get_build_requires_editable ()
58
- else :
59
- build_reqs = self ._get_build_requires_wheel ()
60
- self ._install_build_reqs (finder , build_reqs )
61
-
62
51
def _prepare_build_backend (self , finder : PackageFinder ) -> None :
63
52
# Isolate in a BuildEnvironment and install the build-time
64
53
# requirements.
@@ -103,8 +92,19 @@ def _get_build_requires_editable(self) -> Iterable[str]:
103
92
with backend .subprocess_runner (runner ):
104
93
return backend .get_requires_for_build_editable ()
105
94
106
- def _install_build_reqs (self , finder : PackageFinder , reqs : Iterable [str ]) -> None :
107
- conflicting , missing = self .req .build_env .check_requirements (reqs )
95
+ def _install_build_reqs (self , finder : PackageFinder ) -> None :
96
+ # Install any extra build dependencies that the backend requests.
97
+ # This must be done in a second pass, as the pyproject.toml
98
+ # dependencies must be installed before we can call the backend.
99
+ if (
100
+ self .req .editable
101
+ and self .req .permit_editable_wheels
102
+ and self .req .supports_pyproject_editable ()
103
+ ):
104
+ build_reqs = self ._get_build_requires_editable ()
105
+ else :
106
+ build_reqs = self ._get_build_requires_wheel ()
107
+ conflicting , missing = self .req .build_env .check_requirements (build_reqs )
108
108
if conflicting :
109
109
self ._raise_conflicts ("the backend dependencies" , conflicting )
110
110
self .req .build_env .install_requirements (
0 commit comments