Use Version object for version comparison#12138
Merged
scheibelp merged 1 commit intospack:developfrom Jul 29, 2019
Merged
Conversation
adamjstewart
commented
Jul 25, 2019
|
|
||
| depends_on('py-appnope', type=('build', 'run'), | ||
| when=sys.platform == 'darwin' and | ||
| int(platform.mac_ver()[0].split('.')[1]) >= 9) |
Member
Author
There was a problem hiding this comment.
I don't think this works, right? You can't use a when= that evaluates to True or False, it has to be a string, right?
Member
There was a problem hiding this comment.
Yes - it must be a string (or spec) (see below)
Member
There was a problem hiding this comment.
CORRECTION: I'm wrong, it can be a boolean. We have unit tests for this.
| if not ((platform.system() == "Darwin") and | ||
| (platform.mac_ver()[0] == '10.12')): | ||
| (Version(platform.mac_ver()[0]).up_to(2) == Version( | ||
| '10.12'))): |
Member
Author
There was a problem hiding this comment.
platform.mac_ver() usually returns a 3-digit string, which will never be equal to 10.12
Member
There was a problem hiding this comment.
platform.mac_ver returns ('10.14.5', ('', '', ''), 'x86_64') for me, so I assume you mean a 3-part version (vs. a 3-digit version). The logic here makes sense in that case.
alalazo
approved these changes
Jul 26, 2019
dev-zero
pushed a commit
to dev-zero/spack
that referenced
this pull request
Aug 13, 2019
* Fix Mac platform check for dependency in py-ipython package: 'when' constraints in Spack directives must be Specs (either a Spec object or a Spec in string format) * Fix Mac version check in py-numpy: platform.mac_ver() returns a 3-part string as its first tuple item so the check as written would never pass; use Spack Version object to simplify check. * Fix Mac version check in qt package (the check was incorrectly comparing ints and strings) and use Spack version object to simplify check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, we were doing string to int comparison like
(1, 3) > ('1', '2'). This is incredibly buggy:Also, this does not work at all in Python 3. You get the following error message when trying to install
qt@4 platform=darwin:This PR makes use of the
Versionclass for version comparison.