Skip to content

Commit

Permalink
Merge branch 'trs/conda/install-latest-version'
Browse files Browse the repository at this point in the history
  • Loading branch information
tsibley committed Sep 18, 2023
2 parents dc6c7d9 + 960decb commit dc09b9b
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 dc09b9b

Please sign in to comment.