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

v.concrete does not mean isinstance(v, Version) #26482

Closed
haampie opened this issue Oct 4, 2021 · 4 comments
Closed

v.concrete does not mean isinstance(v, Version) #26482

haampie opened this issue Oct 4, 2021 · 4 comments
Assignees
Labels
bug Something isn't working triage The issue needs to be prioritized versions
Milestone

Comments

@haampie
Copy link
Member

haampie commented Oct 4, 2021

Steps to reproduce

After #24639

In [2]: spack.spec.Spec('mpich@3.1,3.1.1:3.1.2')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~/spack/lib/spack/spack/cmd/python.py in <module>
----> 1 spack.spec.Spec('mpich@3.1,3.1.1:3.1.2')

~/spack/lib/spack/spack/spec.py in __init__(self, spec_like, normal, concrete, external_path, external_modules)
   1092 
   1093         if isinstance(spec_like, six.string_types):
-> 1094             spec_list = SpecParser(self).parse(spec_like)
   1095             if len(spec_list) > 1:
   1096                 raise ValueError("More than one spec in string: " + spec_like)

~/spack/lib/spack/spack/parse.py in parse(self, text)
    151     def parse(self, text):
    152         self.setup(text)
--> 153         return self.do_parse()
    154 
    155 

~/spack/lib/spack/spack/spec.py in do_parse(self)
   4687             # Cannot do lookups for versions in anonymous specs
   4688             # Only allow concrete versions using git for now
-> 4689             if spec.name and spec.versions.concrete and spec.version.is_commit:
   4690                 pkg = spec.package
   4691                 if hasattr(pkg, 'git'):

AttributeError: 'VersionRange' object has no attribute 'is_commit'

Before #24639

In [1]: spack.spec.Spec('mpich@3.1,3.1.1:3.1.2')
Out[1]: mpich@3.1:3.1

Note that this is technically incorrect, since it should be a version list of a concrete version and a range. This also hits yet another bug in spack, namely:

In [2]: spack.spec.Spec('mpich@3.1,3.1.1:3.1.2').versions.concrete
Out[2]: Version('3.1')

:/

@haampie haampie added bug Something isn't working triage The issue needs to be prioritized labels Oct 4, 2021
@haampie
Copy link
Member Author

haampie commented Oct 4, 2021

@becker33 I guess the issue is not on the git version side, but rather with VersionRange x:x being concrete -- which is a bug imho. I've tried to address that here: #26208 but spack seems to rely on this behavior

@haampie haampie changed the title Version list is broken VersionRange is broken Oct 4, 2021
@tgamblin
Copy link
Member

tgamblin commented Oct 4, 2021

VersionRange is broken

Is this title helpful?

@haampie haampie changed the title VersionRange is broken v.concrete does not mean isinstance(v, Version) Oct 4, 2021
@haampie
Copy link
Member Author

haampie commented Oct 4, 2021

What title would you give to it? There's multiple bugs going on.

  1. The new git versions PR assumes that version.concrete being truthy implies that instance(version, Version), which is incorrect.
  2. VersionRange can be concrete, which doesn't make sense
  3. Spack relies on VersionRange being concrete in some cases.

@haampie
Copy link
Member Author

haampie commented Oct 4, 2021

The tl;dr VersionList incorrectly simplifies ranges x,x.y:x.z to x:x, which is considered a concrete version, which triggers a bug in the new git commit code which assume that concrete versions === Version objects.

@alalazo alalazo added this to the v0.20.0 milestone Apr 6, 2023
@haampie haampie closed this as completed May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage The issue needs to be prioritized versions
Projects
None yet
Development

No branches or pull requests

4 participants