Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runner.conda: Explicitly install the latest package version during setup #312

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Changes from all 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
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