Skip to content

Commit

Permalink
Persist packages from original lockfile for platforms not requested f…
Browse files Browse the repository at this point in the history
…or lock

Addresses conda#196: for requested platforms replaces lock content without erroneously persisting packages.

Co-authored-by: Arie Knoester <[email protected]>
Reviewed-by: Matt Fisher <[email protected]>
  • Loading branch information
2 people authored and mfisher87 committed Sep 3, 2023
1 parent 6fd13e9 commit 0dfa59a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion conda_lock/conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ def make_lock_files(

if platforms_to_lock:
print(f"Locking dependencies for {platforms_to_lock}...", file=sys.stderr)
lock_content = lock_content | create_lockfile_from_spec(

new_lock_content = create_lockfile_from_spec(
conda=conda,
spec=lock_spec,
platforms=platforms_to_lock,
Expand All @@ -389,6 +390,21 @@ def make_lock_files(
strip_auth=strip_auth,
)

if not lock_content:
lock_content = new_lock_content
else:
# Persist packages from original lockfile for platforms not requested for lock
packages_not_to_lock = [
dep
for dep in lock_content.package
if dep.platform not in platforms_to_lock
]
filtered_lock_content = lock_content.copy(
deep=True,
update={"package": packages_not_to_lock},
)
lock_content = filtered_lock_content | new_lock_content

if "lock" in kinds:
write_conda_lock_file(
lock_content,
Expand Down

0 comments on commit 0dfa59a

Please sign in to comment.