mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Use Command context helper to cleanup requirement tracker
The lifetime of the requirement tracker will be essentially the same, but now we have more flexibility on where in the code we create it. In a followup we can do the same thing with build_dir and remove the `with` statement (and its indentation) entirely from these commands.
This commit is contained in:
parent
40523794d8
commit
eb91e8ca39
3 changed files with 9 additions and 3 deletions
|
@ -98,7 +98,9 @@ class DownloadCommand(RequirementCommand):
|
||||||
)
|
)
|
||||||
build_delete = (not (options.no_clean or options.build_dir))
|
build_delete = (not (options.no_clean or options.build_dir))
|
||||||
|
|
||||||
with get_requirement_tracker() as req_tracker, TempDirectory(
|
req_tracker = self.enter_context(get_requirement_tracker())
|
||||||
|
|
||||||
|
with TempDirectory(
|
||||||
options.build_dir, delete=build_delete, kind="download"
|
options.build_dir, delete=build_delete, kind="download"
|
||||||
) as directory:
|
) as directory:
|
||||||
reqs = self.get_requirements(
|
reqs = self.get_requirements(
|
||||||
|
|
|
@ -288,7 +288,9 @@ class InstallCommand(RequirementCommand):
|
||||||
build_delete = (not (options.no_clean or options.build_dir))
|
build_delete = (not (options.no_clean or options.build_dir))
|
||||||
wheel_cache = WheelCache(options.cache_dir, options.format_control)
|
wheel_cache = WheelCache(options.cache_dir, options.format_control)
|
||||||
|
|
||||||
with get_requirement_tracker() as req_tracker, TempDirectory(
|
req_tracker = self.enter_context(get_requirement_tracker())
|
||||||
|
|
||||||
|
with TempDirectory(
|
||||||
options.build_dir, delete=build_delete, kind="install"
|
options.build_dir, delete=build_delete, kind="install"
|
||||||
) as directory:
|
) as directory:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -124,7 +124,9 @@ class WheelCommand(RequirementCommand):
|
||||||
options.wheel_dir = normalize_path(options.wheel_dir)
|
options.wheel_dir = normalize_path(options.wheel_dir)
|
||||||
ensure_dir(options.wheel_dir)
|
ensure_dir(options.wheel_dir)
|
||||||
|
|
||||||
with get_requirement_tracker() as req_tracker, TempDirectory(
|
req_tracker = self.enter_context(get_requirement_tracker())
|
||||||
|
|
||||||
|
with TempDirectory(
|
||||||
options.build_dir, delete=build_delete, kind="wheel"
|
options.build_dir, delete=build_delete, kind="wheel"
|
||||||
) as directory:
|
) as directory:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue