Skip to content

Conversation

@marcoesters
Copy link
Collaborator

@marcoesters marcoesters commented Sep 16, 2025

The current version checks for conda-standalone result 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.

@Jrice1317 Jrice1317 deleted the branch Jrice1317:protected_envs September 16, 2025 16:37
@Jrice1317 Jrice1317 closed this Sep 16, 2025
@marcoesters marcoesters reopened this Sep 16, 2025
@marcoesters marcoesters changed the base branch from frozen_fork to protected_envs September 16, 2025 17:58
@marcoesters marcoesters marked this pull request as ready for review September 16, 2025 18:53
)
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")
Copy link
Owner

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?

Copy link
Collaborator Author

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.

Copy link
Owner

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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"):
Copy link
Owner

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

Copy link
Collaborator Author

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.

@Jrice1317 Jrice1317 merged commit f4c092e into Jrice1317:protected_envs Sep 16, 2025
13 checks passed
@marcoesters marcoesters deleted the conda-standalone-version-helper branch November 11, 2025 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants