Skip to content

Conversation

@Jrice1317
Copy link
Owner

Description

Enable metadata for SH and PKG installers (INST-636)

Related tickets:

  • Provide metadata to easily protect environments (INST-622)
  • Create frozen_environments metadata (INST-635)
  • Enable metadata for EXE installers (INST-637)
  • Extend integration tests for the new metadata (INST-638)

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?

@Jrice1317 Jrice1317 closed this Dec 8, 2025
@Jrice1317 Jrice1317 reopened this Dec 8, 2025
@Jrice1317 Jrice1317 requested a review from marcoesters December 8, 2025 13:18
Copy link
Collaborator

@marcoesters marcoesters left a comment

Choose a reason for hiding this comment

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

The big item to fix is the way falsy values are handled, which would result in a couple of false negatives.

# shortcuts
write_shortcuts_txt(info, env_pkgs, env_config)
# frozen marker file
if env_config.get("freeze_env"):
Copy link
Collaborator

Choose a reason for hiding this comment

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

You could use the walrus operator here.



def write_frozen(freeze_info, dst_dir):
if freeze_info and "conda" in freeze_info:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This would result in you checking for freeze_info, once before the call and once during the call.

if freeze_info and "conda" in freeze_info:
frozen_path = join(dst_dir, "frozen")
with open(frozen_path, "w") as ff:
json.dump(freeze_info, ff, indent=2, sort_keys=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will not result in the correct file. If conda is in freeze_info, the resulting file will at least be:

{
  "conda": {}
}

Which is not the correct format. Also, why do we need to indent and sort keys? The file is not intended for human consumption.

Comment on lines 184 to 185
pre_t.addfile(tarinfo=tarfile.TarInfo("conda-meta/frozen"))
post_t.add(join(tmp_dir, "conda-meta", "frozen"), "conda-meta/frozen")
Copy link
Collaborator

Choose a reason for hiding this comment

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

With these lines, you are adding an empty conda-meta/frozen to the preconda archive and the designated conda-meta/frozen file to the postconda archive. Did you use the same patterns as for the history file?

If so, history is an exception. It must exist so that conda recognizes that the environment it's installing packages into is a conda environment. That's why there is an empty file in preconda. However, installing the packages changes the history file. Since we are installing from an @EXPLICIT file, this can cause package conflicts down the line. The file packaged in postconda is the history file we need after the installation.

For the frozen file, we only need in one archive. I don't think it matters which one it is.

and check_version(CONDA_EXE_VERSION, min_version="25.5.0", max_version="25.7.0")
),
reason="conda-standalone 25.5.x fails with protected environments",
reason="conda-standalone 25.5.x fails with protected environments and older versions ignore frozen files",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Leftover?

Comment on lines 179 to 185
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",
)
env_config = info["_extra_envs_info"][env_name]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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",
)
env_config = info["_extra_envs_info"][env_name]
for env_name, env_config in info.get("_extra_envs_info", {}).items():
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",
)

If you use the value, you can just iterate over the items - it's a little cleaner.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I thought about doing this too when I first decided to move my logic here.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I ended up not doing this since we're checking for if the files exist instead of using the config logic

pre_t.addfile(tarinfo=tarfile.TarInfo("conda-meta/history"))
post_t.add(join(tmp_dir, "conda-meta", "history"), "conda-meta/history")

if info.get("freeze_base"):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't 100% sufficient since you also have to look for the conda sub key. I think the easiest way to verify would be to check if tmp_dir / conda-meta / frozen exists.

@Jrice1317 Jrice1317 merged commit b59b421 into metadata Dec 15, 2025
15 checks passed
@Jrice1317 Jrice1317 deleted the sh_and_pkg branch December 15, 2025 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants