Skip to content

Commit c0d05dc

Browse files
committed
Make _collect_buildset a standalone function
1 parent b9faa61 commit c0d05dc

File tree

1 file changed

+36
-31
lines changed

1 file changed

+36
-31
lines changed

src/pip/_internal/wheel_builder.py

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,37 @@ def _build_wheel_pep517(
263263
return os.path.join(tempd, wheel_name)
264264

265265

266+
def _collect_buildset(
267+
requirements, # type: Iterable[InstallRequirement]
268+
wheel_cache, # type: WheelCache
269+
check_binary_allowed, # type: BinaryAllowedPredicate
270+
need_wheel, # type: bool
271+
):
272+
# type: (...) -> List[Tuple[InstallRequirement, str]]
273+
"""Return the list of InstallRequirement that need to be built,
274+
with the persistent or temporary cache directory where the built
275+
wheel needs to be stored.
276+
"""
277+
buildset = []
278+
cache_available = bool(wheel_cache.cache_dir)
279+
for req in requirements:
280+
if not should_build(
281+
req,
282+
need_wheel=need_wheel,
283+
check_binary_allowed=check_binary_allowed,
284+
):
285+
continue
286+
if (
287+
cache_available and
288+
should_cache(req, check_binary_allowed)
289+
):
290+
cache_dir = wheel_cache.get_path_for_link(req.link)
291+
else:
292+
cache_dir = wheel_cache.get_ephem_path_for_link(req.link)
293+
buildset.append((req, cache_dir))
294+
return buildset
295+
296+
266297
def _always_true(_):
267298
# type: (Any) -> bool
268299
return True
@@ -367,35 +398,6 @@ def _clean_one(self, req):
367398
logger.error('Failed cleaning build dir for %s', req.name)
368399
return False
369400

370-
def _collect_buildset(
371-
self,
372-
requirements, # type: Iterable[InstallRequirement]
373-
need_wheel, # type: bool
374-
):
375-
# type: (...) -> List[Tuple[InstallRequirement, str]]
376-
"""Return the list of InstallRequirement that need to be built,
377-
with the persistent or temporary cache directory where the built
378-
wheel needs to be stored.
379-
"""
380-
buildset = []
381-
cache_available = bool(self.wheel_cache.cache_dir)
382-
for req in requirements:
383-
if not should_build(
384-
req,
385-
need_wheel=need_wheel,
386-
check_binary_allowed=self.check_binary_allowed,
387-
):
388-
continue
389-
if (
390-
cache_available and
391-
should_cache(req, self.check_binary_allowed)
392-
):
393-
cache_dir = self.wheel_cache.get_path_for_link(req.link)
394-
else:
395-
cache_dir = self.wheel_cache.get_ephem_path_for_link(req.link)
396-
buildset.append((req, cache_dir))
397-
return buildset
398-
399401
def build(
400402
self,
401403
requirements, # type: Iterable[InstallRequirement]
@@ -418,8 +420,11 @@ def build(
418420
(not should_unpack and self._wheel_dir)
419421
)
420422

421-
buildset = self._collect_buildset(
422-
requirements, need_wheel=not should_unpack
423+
buildset = _collect_buildset(
424+
requirements,
425+
wheel_cache=self.wheel_cache,
426+
check_binary_allowed=self.check_binary_allowed,
427+
need_wheel=not should_unpack,
423428
)
424429
if not buildset:
425430
return []

0 commit comments

Comments
 (0)