Repair missing packages during environment sync
This commit is contained in:
@@ -149,6 +149,7 @@ def main() -> int:
|
||||
requirements=requirements,
|
||||
python=python,
|
||||
local_requirements=local_requirements,
|
||||
repair_requirements=environment.stale_requirements,
|
||||
force=args.force,
|
||||
)
|
||||
|
||||
@@ -250,6 +251,7 @@ def build_install_plan(
|
||||
python: str,
|
||||
local_requirements: tuple[RequirementEntry, ...],
|
||||
force: bool,
|
||||
repair_requirements: tuple[RequirementEntry, ...] = (),
|
||||
) -> InstallPlan:
|
||||
full_command = (python, "-m", "pip", "install", "-r", str(requirements))
|
||||
if force:
|
||||
@@ -273,7 +275,12 @@ def build_install_plan(
|
||||
removed_paths = set(previous_inputs) - set(current_inputs)
|
||||
stale_requirements = requirements_key in changed_paths or requirements_key in removed_paths
|
||||
|
||||
installs: list[tuple[str, ...]] = []
|
||||
# Metadata changes and installation drift can happen together. Keep both
|
||||
# sets in one resolver transaction so a selective metadata sync also
|
||||
# repairs local distributions omitted from the current environment.
|
||||
installs: list[tuple[str, ...]] = [
|
||||
requirement.install_args for requirement in repair_requirements
|
||||
]
|
||||
warnings: list[str] = []
|
||||
|
||||
if stale_requirements:
|
||||
@@ -322,7 +329,7 @@ def build_install_plan(
|
||||
)
|
||||
return InstallPlan(
|
||||
"Selective Python environment sync",
|
||||
f"installing {len(deduped_installs)} stale local requirement(s) in one resolver transaction.",
|
||||
f"installing {len(deduped_installs)} stale or missing local requirement(s) in one resolver transaction.",
|
||||
(command,),
|
||||
tuple(warnings),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user