-
Notifications
You must be signed in to change notification settings - Fork 336
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
--force-reinstall old conda to ensure it's working before we try to install conda packages #920
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4f0179a
bump minimum conda/mamba versions
minrk 4cc55df
force upgrade of conda itself
minrk 29b354b
use force-reinstall
minrk ee23e04
reinstall conda/mamba in a separate, unconditional step
minrk 39b1e1a
preserve version pin when reinstalling conda
minrk File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -242,21 +242,42 @@ def ensure_user_environment(user_requirements_txt_file): | |
) | ||
to_upgrade.append(pkg) | ||
|
||
cf_pkgs_to_upgrade = list(set(to_upgrade) & {"conda", "mamba"}) | ||
if cf_pkgs_to_upgrade: | ||
conda.ensure_conda_packages( | ||
USER_ENV_PREFIX, | ||
# we _could_ explicitly pin Python here, | ||
# but conda already does this by default | ||
cf_pkgs_to_upgrade, | ||
) | ||
pypi_pkgs_to_upgrade = list(set(to_upgrade) & {"pip"}) | ||
if pypi_pkgs_to_upgrade: | ||
conda.ensure_pip_packages( | ||
USER_ENV_PREFIX, | ||
pypi_pkgs_to_upgrade, | ||
upgrade=True, | ||
) | ||
# force reinstall conda/mamba to ensure a basically consistent env | ||
# avoids issues with RemoveError: 'requests' is a dependency of conda | ||
# only do this for 'old' conda versions known to have a problem | ||
# we don't know how old, but we know 4.10 is affected and 23.1 is not | ||
if not is_fresh_install and V(package_versions.get("conda", "0")) < V("23.1"): | ||
# force-reinstall doesn't upgrade packages | ||
# it reinstalls them in-place | ||
# only reinstall packages already present | ||
to_reinstall = [] | ||
for pkg in ["conda", "mamba"]: | ||
if pkg in package_versions: | ||
# add version pin to avoid upgrades | ||
to_reinstall.append(f"{pkg}=={package_versions[pkg]}") | ||
logger.info( | ||
f"Reinstalling {', '.join(to_reinstall)} to ensure a consistent environment" | ||
) | ||
conda.ensure_conda_packages( | ||
USER_ENV_PREFIX, list(to_reinstall), force_reinstall=True | ||
) | ||
|
||
cf_pkgs_to_upgrade = list(set(to_upgrade) & {"conda", "mamba"}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These lines are unchanged, but they are dedented because they should have always been run after the for loop, not on each iteration. Results should be unchanged, it was just a few unnecessary calls to # first 'conda' iteration
conda install conda
# second 'mamba' iteration
conda install conda mamba
# third 'pip' iteration
conda install conda mamba
pip install --upgrade pip when it should have just been the last two calls. |
||
if cf_pkgs_to_upgrade: | ||
conda.ensure_conda_packages( | ||
USER_ENV_PREFIX, | ||
# we _could_ explicitly pin Python here, | ||
# but conda already does this by default | ||
cf_pkgs_to_upgrade, | ||
) | ||
|
||
pypi_pkgs_to_upgrade = list(set(to_upgrade) & {"pip"}) | ||
if pypi_pkgs_to_upgrade: | ||
conda.ensure_pip_packages( | ||
USER_ENV_PREFIX, | ||
pypi_pkgs_to_upgrade, | ||
upgrade=True, | ||
) | ||
|
||
# Install/upgrade the jupyterhub version in the user env based on the | ||
# version specification used for the hub env. | ||
|
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.
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 don't really like what I ended up doing here, but I bracketed the force reinstall on a version older than what's going to be in 1.0, with the hope that we actually remove this step when we drop support for upgrading from earlier than 1.0.
I think you need pretty old conda to get here, but that's what we have in 0.2. It really is a special-case to handle:
pip install --upgrade
commands)but this is what you'll get if you start with tljh 0.2 and haven't upgraded conda, so we should handle it. I think it is appropriate to treat it specially, as if users have broken their own envs such that conda itself doesn't work, I think it's appropriate for us to not handle that and require users to fix their conda (or delete their user env to start fresh) before upgrading. But since we are creating a broken environment, we need to handle it, at least for the very specific case of upgrading from a previous tljh known to have this issue.