-
Notifications
You must be signed in to change notification settings - Fork 1
Create helper function for version range checks #2
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
Create helper function for version range checks #2
Conversation
constructor/main.py
Outdated
| ) | ||
| elif sys.platform != "win32" and ( | ||
| exe_type != StandaloneExe.CONDA or (exe_version and exe_version < Version("23.11.0")) | ||
| exe_type != StandaloneExe.CONDA or not check_version(exe_version, min_version="23.11.0") |
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.
Why are we using not here?
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.
check_version returns True when your version number is within the version specification. Using not here means it is not >= 23.11.0, which is equivalent to < 23.11.0.
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.
So, would the alternative check_version(exe_version, max_version="23.11.0") work as well? I'm trying to see if we can refrain using the negation here because it took me a little longer to understand the logic.
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.
I think you're right, yes. That should work, too.
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.
I changed it - let's see what happens.
| # Add --no-rc option to CONDA_EXE command so that existing | ||
| # .condarc files do not pollute the installation process. | ||
| if exe_type == StandaloneExe.CONDA and exe_version and exe_version >= Version("24.9.0"): | ||
| if exe_type == StandaloneExe.CONDA and check_version(exe_version, min_version="24.9.0"): |
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.
I know this may be a little out of scope but there's no logger warning or comment regarding the need to use 24.9.0 here
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.
Yes, it's out of scope. It's not really an opt-in feature but a bug fix. If conda didn't crash when using an unknown flag, none of these checks would even be necessary. A logger comment would be necessary if this was something a constructor user controlled, but couldn't have.
…ers/constructor into conda-standalone-version-helper
The current version checks for
conda-standaloneresult in bloated if-conditions. Create a helper function to clean up the code.The function assumes
>=and<operators for minimum and maximum versions, respectively. This is consistent with what we currently need. The function can be expanded later if more complex version comparisons are needed.