Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions constructor/nsis/main.nsi.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -1382,6 +1382,8 @@ Section "Install"
# A conda-meta\history file is required for a valid conda prefix
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
Copy Markdown
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
Copy Markdown
Member 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
Copy Markdown
Member 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


# Set channels
System::Call 'kernel32::SetEnvironmentVariable(t,t)i("CONDA_CHANNELS", "{{ channels }}").r0'
Expand Down
5 changes: 4 additions & 1 deletion constructor/osx/run_installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ fi

# Move the prepackaged history file into place
mv "$PREFIX/pkgs/conda-meta/history" "$PREFIX/conda-meta/history"
# Place a copy of the input lockfile in conda-meta for future, potential restoring
cp "$PREFIX/pkgs/env.txt" "$PREFIX/conda-meta/initial-state.lockfile.txt"
rm -f "$PREFIX/env.txt"

# Same, but for the extra environments
Expand Down Expand Up @@ -102,7 +104,8 @@ for env_pkgs in "${PREFIX}"/pkgs/envs/*/; do
"$CONDA_EXEC" install --offline --file "${env_pkgs}env.txt" -yp "$PREFIX/envs/$env_name" $env_shortcuts {{ no_rcs_arg }} || exit 1
# Move the prepackaged history file into place
mv "${env_pkgs}/conda-meta/history" "$PREFIX/envs/$env_name/conda-meta/history"
rm -f "${env_pkgs}env.txt"
# Move the input lockfile in conda-meta for future, potential restoring
mv "${env_pkgs}env.txt" "$PREFIX/envs/$env_name/conda-meta/initial-state.lockfile.txt"
done

# Cleanup!
Expand Down
7 changes: 7 additions & 0 deletions constructor/shar.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,20 @@ def create(info, verbose=False):
pre_t.add(record_file_src, record_file_dest)
pre_t.addfile(tarinfo=tarfile.TarInfo("conda-meta/history"))
post_t.add(join(tmp_dir, "conda-meta", "history"), "conda-meta/history")
# Place a copy of the lockfile in conda-meta for future, potential restoring
post_t.add(join(tmp_dir, "env.txt"), "conda-meta/initial-state.lockfile.txt")

for env_name in info.get("_extra_envs_info", {}):
pre_t.addfile(tarinfo=tarfile.TarInfo(f"envs/{env_name}/conda-meta/history"))
post_t.add(
join(tmp_dir, "envs", env_name, "conda-meta", "history"),
f"envs/{env_name}/conda-meta/history",
)
# Place a copy of the lockfile in conda-meta for future, potential restoring
post_t.add(
join(tmp_dir, "envs", env_name, "env.txt"),
f"envs/{env_name}/conda-meta/initial-state.lockfile.txt",
)

extra_files = copy_extra_files(info.get("extra_files", []), tmp_dir)
for path in extra_files:
Expand Down
5 changes: 2 additions & 3 deletions constructor/winexe.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,8 @@ def setup_envs_commands(info, dir_path):
"prefix": r"$INSTDIR",
"env_txt": r"$INSTDIR\pkgs\env.txt", # env.txt as seen by the running installer
"env_txt_dir": r"$INSTDIR\pkgs", # env.txt location in the installer filesystem
"env_txt_abspath": join(
dir_path, "env.txt"
), # env.txt path while building the installer
# env.txt path while building the installer
"env_txt_abspath": join(dir_path, "env.txt"),
"conda_meta": r"$INSTDIR\conda-meta",
"history_abspath": join(dir_path, "conda-meta", "history"),
"final_channels": get_final_channels(info),
Expand Down
19 changes: 19 additions & 0 deletions news/1059-lockfiles
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* Ship `conda-meta/initial-state.lockfile.txt` as a copy of the lockfile that provisions the initial state of each environment. (#1052 via #1059)

### Bug fixes

* <news item>

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
10 changes: 9 additions & 1 deletion tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,15 @@ def test_example_extra_pages_win(tmp_path, request, extra_pages, monkeypatch):
def test_example_extra_envs(tmp_path, request):
input_path = _example_path("extra_envs")
for installer, install_dir in create_installer(input_path, tmp_path):
_run_installer(input_path, installer, install_dir, request=request)
_run_installer(input_path, installer, install_dir, request=request, uninstall=False)
assert (
"@EXPLICIT" in (install_dir / "conda-meta" / "initial-state.lockfile.txt").read_text()
)
for envtxt in install_dir.glob("envs/*/conda-meta/initial-state.lockfile.txt"):
assert "@EXPLICIT" in envtxt.read_text()
Comment thread
jaimergp marked this conversation as resolved.
Outdated

if sys.platform.startswith("win"):
_run_uninstaller_exe(install_dir=install_dir)


def test_example_extra_files(tmp_path, request):
Expand Down
Loading