mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
user env: ensure pip>=23.1.2 on install
This commit is contained in:
@@ -146,9 +146,10 @@ MAMBAFORGE_CHECKSUMS = {
|
|||||||
|
|
||||||
# minimum versions of packages
|
# minimum versions of packages
|
||||||
MINIMUM_VERSIONS = {
|
MINIMUM_VERSIONS = {
|
||||||
# if conda/mamba are lower than this, upgrade them before installing the user packages
|
# if conda/mamba/pip are lower than this, upgrade them before installing the user packages
|
||||||
"mamba": "0.16.0",
|
"mamba": "0.16.0",
|
||||||
"conda": "4.10",
|
"conda": "4.10",
|
||||||
|
"pip": "23.1.2",
|
||||||
# minimum Python version (if not matched, abort to avoid big disruptive updates)
|
# minimum Python version (if not matched, abort to avoid big disruptive updates)
|
||||||
"python": "3.9",
|
"python": "3.9",
|
||||||
}
|
}
|
||||||
@@ -224,10 +225,14 @@ def ensure_user_environment(user_requirements_txt_file):
|
|||||||
logger.error(msg)
|
logger.error(msg)
|
||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
|
|
||||||
# at this point, we know we have an env ready with conda and are going to start installing
|
# Ensure minimum versions of the following packages by upgrading to the
|
||||||
# first, check if we should upgrade/install conda and/or mamba
|
# latest if below that version.
|
||||||
|
#
|
||||||
|
# - conda/mamba, via conda-forge
|
||||||
|
# - pip, via PyPI
|
||||||
|
#
|
||||||
to_upgrade = []
|
to_upgrade = []
|
||||||
for pkg in ("conda", "mamba"):
|
for pkg in ("conda", "mamba", "pip"):
|
||||||
version = package_versions.get(pkg)
|
version = package_versions.get(pkg)
|
||||||
min_version = MINIMUM_VERSIONS[pkg]
|
min_version = MINIMUM_VERSIONS[pkg]
|
||||||
if not version:
|
if not version:
|
||||||
@@ -241,19 +246,21 @@ def ensure_user_environment(user_requirements_txt_file):
|
|||||||
)
|
)
|
||||||
to_upgrade.append(pkg)
|
to_upgrade.append(pkg)
|
||||||
|
|
||||||
if to_upgrade:
|
cf_pkgs_to_upgrade = list(set(to_upgrade) & {"conda", "mamba"})
|
||||||
conda.ensure_conda_packages(
|
if cf_pkgs_to_upgrade:
|
||||||
USER_ENV_PREFIX,
|
conda.ensure_conda_packages(
|
||||||
# we _could_ explicitly pin Python here,
|
USER_ENV_PREFIX,
|
||||||
# but conda already does this by default
|
# we _could_ explicitly pin Python here,
|
||||||
to_upgrade,
|
# but conda already does this by default
|
||||||
)
|
cf_pkgs_to_upgrade,
|
||||||
|
)
|
||||||
conda.ensure_pip_requirements(
|
pypi_pkgs_to_upgrade = list(set(to_upgrade) & {"pip"})
|
||||||
USER_ENV_PREFIX,
|
if pypi_pkgs_to_upgrade:
|
||||||
os.path.join(HERE, "requirements-user-env.txt"),
|
conda.ensure_pip_packages(
|
||||||
upgrade=True,
|
USER_ENV_PREFIX,
|
||||||
)
|
pypi_pkgs_to_upgrade,
|
||||||
|
upgrade=True,
|
||||||
|
)
|
||||||
if is_fresh_install:
|
if is_fresh_install:
|
||||||
conda.ensure_pip_requirements(
|
conda.ensure_pip_requirements(
|
||||||
USER_ENV_PREFIX,
|
USER_ENV_PREFIX,
|
||||||
|
|||||||
Reference in New Issue
Block a user