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 handle our package versions which are invalid by PEP-440 #286

Merged
merged 1 commit into from
May 31, 2023

Conversation

tsibley
Copy link
Member

@tsibley tsibley commented May 31, 2023

Our nextstrain-base Conda package versions are not PEP-440 compliant, so we inadvertently relied on packaging.version.parse_version() falling back to its LegacyVersion class when it encountered an InvalidVersion error. LegacyVersion was dropped, however, in packaging 22.0 (December 2022).¹ This resulted in seeing the InvalidVersion error during runtime update, e.g.:

packaging.version.InvalidVersion: Invalid version: '20221019T172207Z'

To avoid that, we start handling InvalidVersion ourselves and produce a valid proxy version instead with reasonable comparison semantics similar to LegacyVersion.

The new version handling is more than strictly necessary for our current package versions (which could just be simpler string comparisons), but it allows us more leeway to change package versioning in the future if need be without affecting existing installs of Nextstrain CLI. I didn't want to vendor LegacyVersion itself because it's fairly complex and tangled with the implementation of packaging.version.

Resolves #285.

¹ https://packaging.pypa.io/en/latest/changelog.html

Testing

  • Checks pass

…d by PEP-440

Our nextstrain-base Conda package versions are not PEP-440 compliant, so
we inadvertently relied on packaging.version.parse_version() falling
back to its LegacyVersion class when it encountered an InvalidVersion
error.  LegacyVersion was dropped, however, in packaging 22.0 (December
2022).¹  This resulted in seeing the InvalidVersion error during runtime
update, e.g.:

    packaging.version.InvalidVersion: Invalid version: '20221019T172207Z'

To avoid that, we start handling InvalidVersion ourselves and produce a
valid proxy version instead with reasonable comparison semantics similar
to LegacyVersion.

The new version handling is more than strictly necessary for our current
package versions (which could just be simpler string comparisons), but
it allows us more leeway to change package versioning in the future if
need be without affecting existing installs of Nextstrain CLI.  I didn't
want to vendor LegacyVersion itself because it's fairly complex and
tangled with the implementation of packaging.version.

Resolves <#285>.

¹ <https://packaging.pypa.io/en/latest/changelog.html>
@tsibley
Copy link
Member Author

tsibley commented May 31, 2023

Passes CI and installing the build from this PR fixes nextstrain update conda for me:

$ nextstrain update conda
Checking for newer versions of Nextstrain CLI…

nextstrain-cli is up to date!

Updating conda runtime…
Updating Conda package nextstrain-base from 20230523T234132Z to 20230531T111651Z…

Updating Conda packages in /home/tom/.nextstrain/runtimes/conda/env…
  - nextstrain-base ==20230531T111651Z

                                           __
          __  ______ ___  ____ _____ ___  / /_  ____ _
         / / / / __ `__ \/ __ `/ __ `__ \/ __ \/ __ `/
        / /_/ / / / / / / /_/ / / / / / / /_/ / /_/ /
       / .___/_/ /_/ /_/\__,_/_/ /_/ /_/_.___/\__,_/
      /_/

nextstrain/noarch                                  135.0 B @ 294.0 B/s  0.5s
nextstrain/linux-64                                 28.1kB @  50.5kB/s  0.6s
bioconda/linux-64                                    5.0MB @   3.7MB/s  1.4s
bioconda/noarch                                      4.3MB @   3.0MB/s  1.0s
conda-forge/noarch                                  12.4MB @   4.6MB/s  2.8s

@tsibley tsibley merged commit 797f30a into master May 31, 2023
@tsibley tsibley deleted the trs/conda/broken-update branch May 31, 2023 21:12
@joverlee521
Copy link
Contributor

Thanks for fixing this @tsibley! Installing the build from this PR fixes the issue for me as well.

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.

nextstrain update conda in 7.0.0 can error with "Invalid version"
2 participants