Skip to content

Commit 9909b40

Browse files
committed
Move final copy operation from wheel_builder to wheel command
1 parent cf21401 commit 9909b40

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

src/pip/_internal/commands/wheel.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77

88
import logging
99
import os
10+
import shutil
1011

1112
from pip._internal.cache import WheelCache
1213
from pip._internal.cli import cmdoptions
1314
from pip._internal.cli.req_command import RequirementCommand
1415
from pip._internal.exceptions import CommandError, PreviousBuildDirError
1516
from pip._internal.req import RequirementSet
1617
from pip._internal.req.req_tracker import get_requirement_tracker
18+
from pip._internal.utils.misc import ensure_dir
1719
from pip._internal.utils.temp_dir import TempDirectory
1820
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
1921
from pip._internal.wheel_builder import WheelBuilder
@@ -161,10 +163,23 @@ def run(self, options, args):
161163
build_options=options.build_options or [],
162164
global_options=options.global_options or [],
163165
)
164-
_, build_failures = wb.build(
166+
build_successes, build_failures = wb.build(
165167
requirement_set.requirements.values(),
166168
should_unpack=False,
167169
)
170+
for req in build_successes:
171+
assert req.link and req.link.is_wheel
172+
assert req.local_file_path
173+
# copy from cache to target directory
174+
try:
175+
ensure_dir(options.wheel_dir)
176+
shutil.copy(req.local_file_path, options.wheel_dir)
177+
except OSError as e:
178+
logger.warning(
179+
"Building wheel for %s failed: %s",
180+
req.name, e,
181+
)
182+
build_failures.append(req)
168183
if len(build_failures) != 0:
169184
raise CommandError(
170185
"Failed to build one or more wheels"

src/pip/_internal/wheel_builder.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -479,18 +479,6 @@ def build(
479479
)
480480
# extract the wheel into the dir
481481
unpack_file(req.link.file_path, req.source_dir)
482-
else:
483-
# copy from cache to target directory
484-
try:
485-
ensure_dir(self._wheel_dir)
486-
shutil.copy(wheel_file, self._wheel_dir)
487-
except OSError as e:
488-
logger.warning(
489-
"Building wheel for %s failed: %s",
490-
req.name, e,
491-
)
492-
build_failures.append(req)
493-
continue
494482
build_successes.append(req)
495483
else:
496484
build_failures.append(req)

0 commit comments

Comments
 (0)