@@ -99,6 +99,36 @@ class IsSDist(DistAbstraction):
99
99
def dist (self ):
100
100
return self .req .get_dist ()
101
101
102
+ def _raise_conflicts (self , conflicting_with , conflicting_reqs ):
103
+ conflict_messages = [
104
+ '%s is incompatible with %s' % (installed , wanted )
105
+ for installed , wanted in sorted (conflicting_reqs )
106
+ ]
107
+ raise InstallationError (
108
+ "Some build dependencies for %s conflict with %s: %s." % (
109
+ self .req , conflicting_with , ', ' .join (conflict_messages ))
110
+ )
111
+
112
+ def install_backend_dependencies (self , finder ):
113
+ # type: (PackageFinder) -> None
114
+ """
115
+ Install any extra build dependencies that the backend requests.
116
+
117
+ :param finder: a PackageFinder object.
118
+ """
119
+ req = self .req
120
+ with req .build_env :
121
+ # We need to have the env active when calling the hook.
122
+ req .spin_message = "Getting requirements to build wheel"
123
+ reqs = req .pep517_backend .get_requires_for_build_wheel ()
124
+ conflicting , missing = req .build_env .check_requirements (reqs )
125
+ if conflicting :
126
+ self ._raise_conflicts ("the backend dependencies" , conflicting )
127
+ req .build_env .install_requirements (
128
+ finder , missing , 'normal' ,
129
+ "Installing backend dependencies"
130
+ )
131
+
102
132
def prep_for_dist (self , finder , build_isolation ):
103
133
# type: (PackageFinder, bool) -> None
104
134
# Prepare for building. We need to:
@@ -108,13 +138,6 @@ def prep_for_dist(self, finder, build_isolation):
108
138
self .req .load_pyproject_toml ()
109
139
should_isolate = self .req .use_pep517 and build_isolation
110
140
111
- def _raise_conflicts (conflicting_with , conflicting_reqs ):
112
- raise InstallationError (
113
- "Some build dependencies for %s conflict with %s: %s." % (
114
- self .req , conflicting_with , ', ' .join (
115
- '%s is incompatible with %s' % (installed , wanted )
116
- for installed , wanted in sorted (conflicting ))))
117
-
118
141
if should_isolate :
119
142
# Isolate in a BuildEnvironment and install the build-time
120
143
# requirements.
@@ -127,8 +150,8 @@ def _raise_conflicts(conflicting_with, conflicting_reqs):
127
150
self .req .requirements_to_check
128
151
)
129
152
if conflicting :
130
- _raise_conflicts ("PEP 517/518 supported requirements" ,
131
- conflicting )
153
+ self . _raise_conflicts ("PEP 517/518 supported requirements" ,
154
+ conflicting )
132
155
if missing :
133
156
logger .warning (
134
157
"Missing build requirements in pyproject.toml for %s." ,
@@ -139,20 +162,11 @@ def _raise_conflicts(conflicting_with, conflicting_reqs):
139
162
"pip cannot fall back to setuptools without %s." ,
140
163
" and " .join (map (repr , sorted (missing )))
141
164
)
165
+
142
166
# Install any extra build dependencies that the backend requests.
143
167
# This must be done in a second pass, as the pyproject.toml
144
168
# dependencies must be installed before we can call the backend.
145
- with self .req .build_env :
146
- # We need to have the env active when calling the hook.
147
- self .req .spin_message = "Getting requirements to build wheel"
148
- reqs = self .req .pep517_backend .get_requires_for_build_wheel ()
149
- conflicting , missing = self .req .build_env .check_requirements (reqs )
150
- if conflicting :
151
- _raise_conflicts ("the backend dependencies" , conflicting )
152
- self .req .build_env .install_requirements (
153
- finder , missing , 'normal' ,
154
- "Installing backend dependencies"
155
- )
169
+ self .install_backend_dependencies (finder = finder )
156
170
157
171
self .req .prepare_metadata ()
158
172
self .req .assert_source_matches_version ()
0 commit comments