Prefix and `:upper` version ranges match pre-releases of the next version (`=4rc1` satisfies `@3`, `[email protected]` resolves to `0.2.1-rc.1`)

Open
#53,371 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
54/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend, databases

Research direction

Start with lib/spack/spack/version/version_types.py, especially ClosedOpenRange.from_version_range and _next_version; the issue identifies the upper-bound behavior causing the mismatch. Read the version specifier documentation and the case near lib/spack/spack/test/versions.py:326, then run the five satisfies examples and spack spec [email protected]. Done when all five checks are false and that spec fails to concretize.

Written by the indexing model from the issue text.

Description

Steps to reproduce

Prefix version specs (@3, @1.2.0) and upper-bounded ranges (@:3, @:1.1, @:1.2.0) match alpha, beta, and rc pre-releases of the incremented version whenever the pre-release has the same number of release components as the upper bound.

$ spack python -c 'from spack.version import ver; print([(c, r, ver(c).satisfies(ver(r))) for c, r in [("=4rc1", "3"), ("=4alpha1", ":3"), ("=1.2alpha1", ":1.1"), ("=1.2.1alpha1", "1.2.0"), ("=1.2.1alpha1", ":1.2.0")]])'
$ spack spec [email protected]
Error message

No error is raised (including under spack --debug --stacktrace), and Spack returns the wrong match:

[('=4rc1', '3', True), ('=4alpha1', ':3', True), ('=1.2alpha1', ':1.1', True), ('=1.2.1alpha1', '1.2.0', True), ('=1.2.1alpha1', ':1.2.0', True)]
 -   [email protected] build_system=autotools platform=linux os=debian12 target=cascadelake %[email protected]
 -       ^[email protected] build_system=generic platform=linux os=debian12 target=cascadelake
[e]      ^[email protected]+binutils+bootstrap+futex~graphite+libsanitizer~mold~nvptx~piclibs~profiled~strip build_system=autotools build_type=Release languages:='c,c++' platform=linux os=debian12 target=x86_64
 -       ^[email protected] build_system=generic platform=linux os=debian12 target=cascadelake
[e]      ^[email protected] build_system=autotools platform=linux os=debian12 target=x86_64
 -       ^[email protected]~guile build_system=generic platform=linux os=debian12 target=cascadelake %[email protected]
 -       ^[email protected]~classic-names+envmods~external-libfabric~generic-names~ilp64 build_system=generic platform=linux os=debian12 target=cascadelake %[email protected]
 -       ^[email protected] build_system=autotools platform=linux os=debian12 target=cascadelake %[email protected]
 -           ^[email protected] build_system=autotools platform=linux os=debian12 target=cascadelake
 -       ^[email protected] build_system=autotools platform=linux os=debian12 target=cascadelake %[email protected]

Expected behavior: all five satisfies checks should return False, and spack spec [email protected] should fail to concretize because libcircle only defines master, 0.3.0, and 0.2.1-rc.1. Per the version specifier documentation, @3 includes versions with major version 3, and lib/spack/spack/test/versions.py:326 notes that :1.1 should not include next-version pre-releases (which passed there only because 1.2.0alpha1 has three release segments while 1.1 has two).

In lib/spack/spack/version/version_types.py, ClosedOpenRange.from_version_range sets the exclusive upper bound via _next_version(hi), which increments the last release component while keeping prerelease = (FINAL,), so any pre-release with that incremented release tuple compares strictly less than hi.

Information on your system

Reproduced on both Spack 1.2.2 and develop:

* **Spack:** 1.2.2 (https://github.com/spack/spack/commit/3e19345b6e12f5ff1b874f4059622fc6a1fd804a)
* **Builtin repo:** https://github.com/spack/spack-packages/commit/6fe25eaebe46cee8386bd0b935b31d2ac5a3b348
* **Python:** 3.11.2
* **Platform:** linux-debian12-cascadelake
* **Spack:** 1.3.0.dev0 (https://github.com/spack/spack/commit/aea937f0ba030daebd645ff69bdfc55675d8e76c)
* **Builtin repo:** https://github.com/spack/spack-packages/commit/6fe25eaebe46cee8386bd0b935b31d2ac5a3b348
* **Python:** 3.11.2
* **Platform:** linux-debian12-cascadelake
General information
  • I have run spack debug report and reported the version of Spack/Python/Platform
  • I have searched the issues of this repo and believe this is not a duplicate
  • I have run the failing commands in debug mode and reported the output

Credit: https://ucsbplse.github.io/

Dominant language
Python
Stars
5.2k
Forks
2.5k
Avg merge
2d 4h
Merged PRs (30d)
40

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from spack/spack

All issues in spack/spack

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.