-
Notifications
You must be signed in to change notification settings - Fork 385
Fix VersionSpec globs #3889
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
Fix VersionSpec globs #3889
Conversation
7d227ae
to
abc3070
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3889 +/- ##
=======================================
Coverage ? 62.91%
=======================================
Files ? 299
Lines ? 36955
Branches ? 2777
=======================================
Hits ? 23252
Misses ? 13651
Partials ? 52 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I have a few questions and suggestions.
5a3cf6a
to
fab70f0
Compare
@AntoinePrv how can I locally test this branch? I couldn't find any developer docs on how to setup a local development environment (eg I checked I tried following the instructions to build micromamba from source, but I assume I did something wrong because Details of attempt to test behavior with source build of micromamba
# Setup
docker run --rm -it condaforge/miniforge3 bash
mamba init
source ~/.bashrc
git clone https://github.com/mamba-org/mamba.git
cd mamba/
mamba env create -n mamba-from-source --file dev/environment-micromamba-static.yml
mamba activate mamba-from-source
# Build latest from main
git log -n 1 --pretty=reference
## 64a620a2 (ci: Adapt code coverage workflow (#3890), 2025-04-11)
cmake -B build-main/ \
-G Ninja \
${CMAKE_ARGS} \
-D CMAKE_INSTALL_PREFIX="${CONDA_PREFIX}" \
-D CMAKE_BUILD_TYPE="Release" \
-D BUILD_LIBMAMBA=ON \
-D BUILD_STATIC=ON \
-D BUILD_MICROMAMBA=ON
cmake --build build-main/ --parallel
./build-main/micromamba/micromamba --version
## 2.1.0
# Trailing glob works
./build-main/micromamba/micromamba create -n test --dry-run 'python=3.*'
## + python 3.13.3 hf636f53_100_cp313 conda-forge 33MB
# Internal glob fails
./build-main/micromamba/micromamba create -n test --dry-run 'python=3.*.1'
## error libmamba Could not solve for environment specs
## The following package could not be installed
## └─ python =3.0*.1 * does not exist (perhaps a typo or a missing channel).
## critical libmamba Could not solve for environment specs
# Leading glob fails
./build-main/micromamba/micromamba create -n test --dry-run 'python=*.13.3'
## error libmamba Could not solve for environment specs
## The following package could not be installed
## └─ python =0*.13.3 * does not exist (perhaps a typo or a missing channel).
## critical libmamba Could not solve for environment specs
# Build from PR 3889
git remote add AntoinePrv https://github.com/AntoinePrv/fork-mamba-org-mamba.git
git fetch AntoinePrv
git checkout -t AntoinePrv/fix-version-spec
git log -n 1 --pretty=reference
## fab70f0f (Cleanup, 2025-04-14)
cmake -B build-pr3889/ \
-G Ninja \
${CMAKE_ARGS} \
-D CMAKE_INSTALL_PREFIX="${CONDA_PREFIX}" \
-D CMAKE_BUILD_TYPE="Release" \
-D BUILD_LIBMAMBA=ON \
-D BUILD_STATIC=ON \
-D BUILD_MICROMAMBA=ON
cmake --build build-pr3889/ --parallel
./build-pr3889/micromamba/micromamba --version
## 2.1.0
# Trailing glob works
./build-pr3889/micromamba/micromamba create -n test --dry-run 'python=3.*'
## + python 3.13.3 hf636f53_100_cp313 conda-forge 33MB
# Internal glob fails
./build-pr3889/micromamba/micromamba create -n test --dry-run 'python=3.*.1'
## error libmamba Could not solve for environment specs
## The following package could not be installed
## └─ python =3.0*.1 * does not exist (perhaps a typo or a missing channel).
## critical libmamba Could not solve for environment specs
# Leading glob fails
./build-pr3889/micromamba/micromamba create -n test --dry-run 'python=*.13.3'
## error libmamba Could not solve for environment specs
## The following package could not be installed
## └─ python =0*.13.3 * does not exist (perhaps a typo or a missing channel).
## critical libmamba Could not solve for environment specs |
@jdblischak we have doc on dev environment but I guess you have everything right. I believe that I have not anticipated this case. |
I think this also must be handled, yes. |
a4af69a
to
3d5176c
Compare
3d5176c
to
c882b35
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @AntoinePrv.
})); | ||
} | ||
|
||
SECTION("python=3.*.1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, @jdblischak.
Thanks! I'm embarrassed I missed these instructions. Using a combination of the docs on Development Environment and Micromamba Installation (to initialize micromamba to use In case it could be useful to other contributors, here is the code I ran in a Docker container to test this PR: docker run --rm -it ubuntu:24.04 bash
apt-get update
apt-get install --yes bzip2 curl git tar
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
./bin/micromamba shell init -s bash -r ~/micromamba
source ~/.bashrc
micromamba --version
## 2.1.0
git clone https://github.com/mamba-org/mamba.git
cd mamba/
git remote add AntoinePrv https://github.com/AntoinePrv/fork-mamba-org-mamba.git
git fetch AntoinePrv
git checkout -t AntoinePrv/fix-version-spec
git log -n 1 --pretty=reference
## d5346f1b (Nit fixes, 2025-04-17)
micromamba create --yes -n mamba -c conda-forge \
-f dev/environment-dev.yml -f dev/environment-dev-extra.yml
micromamba activate mamba
cmake -B build/ -G Ninja --preset mamba-unix-shared-debug-dev
cmake --build build/ --parallel
./build/libmamba/tests/test_libmamba
cmake --install build/ --prefix "${CONDA_PREFIX}"
python -m pip install --no-deps --no-build-isolation libmambapy/
python -m pytest libmambapy/tests |
Also, I ran the same Python test code as I did with libmambapy 2.0.4 in #3601 (comment) to confirm that internal and leading version globs now behave as I expect: import libmambapy
libmambapy.version.version_info
## ('2', '1', '0')
import libmambapy.specs as specs
specs.VersionSpec.parse("0.0.*")
specs.VersionSpec.parse("0.*.0")
specs.VersionSpec.parse("*.0.0")
# Trailing glob works as expected
specs.VersionSpec.parse("0.0.*").contains(specs.Version.parse("0.0.1"))
## True
specs.VersionSpec.parse("0.0.*").contains(specs.Version.parse("1.0.0"))
## False
# Internal glob now works as expected
specs.VersionSpec.parse("0.*.0").contains(specs.Version.parse("0.1.0"))
## True
specs.VersionSpec.parse("0.*.0").contains(specs.Version.parse("1.0.0"))
## False
# Leading glob now works as expected
specs.VersionSpec.parse("*.0.0").contains(specs.Version.parse("1.0.0"))
## True
specs.VersionSpec.parse("*.0.0").contains(specs.Version.parse("0.0.1"))
## False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @AntoinePrv!
@jaimergp @jdblischak this should solve a number of cases. I'm happy to add more test cases if you have some to suggest.
Fix #3601
Note that full regex on versions are not implemented.