Skip to content

Commit

Permalink
runner.conda: Explicitly install the latest package version during setup
Browse files Browse the repository at this point in the history
This our intent and expectation, and it's good to be explicit about it.
It may surface more installation issues, such as the one we observed in
monkeypox CI¹ with the latest version not being installable, but
obscuring those or surfacing them later on is _probably_ worse than
addressing them head on earlier.  This change will mean that any macOS
10.14 users, if any, would have to use

    NEXTSTRAIN_CONDA_BASE_PACKAGE="nextstrain-base ==20230615T171309Z"

since newer versions aren't installable for them.²

This behaviour also parallels update's behaviour since "runner.conda:
Explicitly specify a nextstrain-base version when updating" (d6e4f2b).
It was an oversight (on my part) to not use the same behaviour during
setup, but at the time I was focused on fixing an update bug.

Related-to: <nextstrain/conda-base#41>
Related-to: <nextstrain/conda-base#42>

¹ <nextstrain/mpox#177>
² <nextstrain/conda-base#38>
  • Loading branch information
tsibley committed Sep 15, 2023
1 parent 3c93e87 commit 960decb
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions nextstrain/cli/runner/conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,23 +247,30 @@ def setup_prefix(dry_run: bool = False, force: bool = False) -> bool:
if not dry_run:
shutil.rmtree(str(PREFIX))

# Conda packages to install.
# We accept a package match spec, which one to three space-separated parts.¹
# If we got a spec, then we use it as-is.
#
# ¹ <https://docs.conda.io/projects/conda/en/latest/user-guide/concepts/pkg-specs.html#package-match-specifications>
#
# HEY YOU: If you add/remove packages here, make sure to account for how
# update() should make the same changes to existing envs.
# -trs, 1 Sept 2022
packages = (
NEXTSTRAIN_BASE,
)
if " " in NEXTSTRAIN_BASE.strip():
install_spec = NEXTSTRAIN_BASE
else:
latest_version = (package_distribution(NEXTSTRAIN_CHANNEL, NEXTSTRAIN_BASE) or {}).get("version")

if latest_version:
install_spec = f"{NEXTSTRAIN_BASE} =={latest_version}"
else:
warn(f"Unable to find latest version of {NEXTSTRAIN_BASE} package; falling back to non-specific install")

install_spec = NEXTSTRAIN_BASE

# Create environment
print(f"Installing Conda packages into {PREFIX}…")
for pkg in packages:
print(f" - {pkg}")
print(f" - {install_spec}")

if not dry_run:
try:
micromamba("create", *packages)
micromamba("create", install_spec)
except InternalError as err:
warn(err)
traceback.print_exc()
Expand Down

0 comments on commit 960decb

Please sign in to comment.