Skip to content

Conversation

jaimergp
Copy link
Contributor

@jaimergp jaimergp commented Sep 11, 2025

Description

Closes #1052

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@github-project-automation github-project-automation bot moved this to 🆕 New in 🔎 Review Sep 11, 2025
@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Sep 11, 2025
@jaimergp jaimergp marked this pull request as ready for review September 11, 2025 20:27
@jaimergp jaimergp requested a review from a team as a code owner September 11, 2025 20:27
@jaimergp jaimergp changed the title Expect env.txt lockfile in conda-meta Add initial-state.lockfile.txt lockfile to conda-meta/ Sep 11, 2025
SetOutPath "{{ env.conda_meta }}"
File "{{ env.history_abspath }}"
# We also place a copy of the env.txt file here, as a lockfile
File /oname=initial-state.lockfile.txt "{{ env.env_txt_abspath }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of renaming the env.txt file during the installation, why don't we just package env.txt as conda-meta/initial-state.lockfile.txt and use that file for the --file argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works too. I wanted to start with the smallest diff possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed. Let's see if I got it right :P

@jaimergp jaimergp changed the title Add initial-state.lockfile.txt lockfile to conda-meta/ Add initial-state.explicit.txt lockfile to conda-meta/ Sep 11, 2025
Comment on lines 569 to 576
# We need to move the initial-state.explicit.txt files from pkgs/ to their conda-meta targets
shutil.move(join(pkgs_dir, "initial-state.explicit.txt"), conda_meta)
if isdir(join(pkgs_dir, "envs")):
for envname in os.listdir(join(pkgs_dir, "envs")):
lockfile = join(pkgs_dir, "envs", envname, "initial-state.explicit.txt")
env_conda_meta = join(prefix, "envs", envname, "conda-meta")
os.makedirs(env_conda_meta)
shutil.move(lockfile, env_conda_meta)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not super proud of this block, but the alternative is refactoring the logic in preconda so it's multi-directory (and not just assume that everything goes in dst_dir == "pkgs/").

What do you think @marcoesters? Worth the refactor or not? There'll still be differences between Unix and Windows.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it's much of a refactor. Since write_files writes very specific files with very specific file locations, you could pass in prefix and adjust the paths inside the function accordingly. This would make the SH code a little simpler, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see: fe1e040

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks pretty clean and extendable. The directory creation can probably be further abstracted by using Path().parent.mkdir(parents=True, exist_ok=True), but that's probably better suited for #1063.

@jaimergp jaimergp changed the title Add initial-state.explicit.txt lockfile to conda-meta/ Move pkgs/env.txt lockfile to conda-meta/initial-state.explicit.txt to preserve it Sep 13, 2025
@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Approved in 🔎 Review Sep 15, 2025
@jaimergp jaimergp merged commit d992bd7 into conda:main Sep 15, 2025
20 checks passed
@github-project-automation github-project-automation bot moved this from ✅ Approved to 🏁 Done in 🔎 Review Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA
Projects
Status: 🏁 Done
Development

Successfully merging this pull request may close these issues.

Transform envs.txt into persistent explicit lockfile
3 participants