Skip to content

Commit

Permalink
fix: use conda package version parsing by obtaining conda version spe…
Browse files Browse the repository at this point in the history
…c from github (#52)
  • Loading branch information
johanneskoester authored Feb 3, 2023
1 parent de4ece2 commit ed821c8
Show file tree
Hide file tree
Showing 8 changed files with 721 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ For getting started and a basic tutorial, see the documentation at
## License

* Free software: MPL 2.0 License
* `snakedeploy/conda_version.py`: the [source](https://github.com/conda/conda/raw/23.1.0/conda/models/version.py) of this file is distributed under the BSD 3-clause license by Anaconda Inc.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from setuptools import setup, find_packages
import versioneer
import os
import urllib.request


def get_lookup():
Expand Down
7 changes: 3 additions & 4 deletions snakedeploy/conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from snakedeploy.exceptions import UserError
from snakedeploy.logger import logger
from snakedeploy.utils import YamlDumper
from snakedeploy.conda_version import VersionOrder


def pin_conda_envs(conda_env_paths: list, conda_frontend="mamba"):
Expand Down Expand Up @@ -193,16 +194,14 @@ def get_pkg_versions(conda_env_path):
def downgraded():
for pkg_name, version in posterior_pkg_versions.items():
try:
version = packaging_version.parse(version)
version = VersionOrder(version)
except packaging_version.InvalidVersion as e:
logger.debug(json.dumps(posterior_pkg_json, indent=2))
raise UserError(
f"Cannot parse version {version} of package {pkg_name}: {e}"
)
prior_version = prior_pkg_versions.get(pkg_name)
if prior_version is not None and version < packaging_version.parse(
prior_version
):
if prior_version is not None and version < VersionOrder(prior_version):
yield pkg_name

downgraded = list(downgraded())
Expand Down
Loading

0 comments on commit ed821c8

Please sign in to comment.