bootstrap.py: let --version flag take precedence over env vars

This commit is contained in:
Erik Sundell
2023-06-06 22:48:06 +02:00
parent ab947333d2
commit ecf11f0f27

View File

@@ -364,7 +364,7 @@ def main():
) )
parser.add_argument( parser.add_argument(
"--version", "--version",
default="latest", default="",
help=( help=(
"TLJH version or Git reference. " "TLJH version or Git reference. "
"Default 'latest' is the most recent release. " "Default 'latest' is the most recent release. "
@@ -478,21 +478,26 @@ def main():
logger.info("Upgrading pip...") logger.info("Upgrading pip...")
run_subprocess([hub_env_pip, "install", "--upgrade", "pip"]) run_subprocess([hub_env_pip, "install", "--upgrade", "pip"])
# Install/upgrade TLJH installer # pip install TLJH installer based on
#
# 1. --version, _resolve_git_version is used
# 2. TLJH_BOOTSTRAP_PIP_SPEC (then also respect TLJH_BOOTSTRAP_DEV)
# 3. latest, _resolve_git_version is used
#
tljh_install_cmd = [hub_env_pip, "install", "--upgrade"] tljh_install_cmd = [hub_env_pip, "install", "--upgrade"]
if os.environ.get("TLJH_BOOTSTRAP_DEV", "no") == "yes":
logger.info("Selected TLJH_BOOTSTRAP_DEV=yes...")
tljh_install_cmd.append("--editable")
bootstrap_pip_spec = os.environ.get("TLJH_BOOTSTRAP_PIP_SPEC") bootstrap_pip_spec = os.environ.get("TLJH_BOOTSTRAP_PIP_SPEC")
if not bootstrap_pip_spec: if args.version or not bootstrap_pip_spec:
version_to_resolve = args.version or "latest"
bootstrap_pip_spec = ( bootstrap_pip_spec = (
"git+https://github.com/jupyterhub/the-littlest-jupyterhub.git@{}".format( "git+https://github.com/jupyterhub/the-littlest-jupyterhub.git@{}".format(
_resolve_git_version(args.version) _resolve_git_version(version_to_resolve)
) )
) )
elif os.environ.get("TLJH_BOOTSTRAP_DEV", "no") == "yes":
logger.info("Selected TLJH_BOOTSTRAP_DEV=yes...")
tljh_install_cmd.append("--editable")
tljh_install_cmd.append(bootstrap_pip_spec) tljh_install_cmd.append(bootstrap_pip_spec)
if initial_setup: if initial_setup:
logger.info("Installing TLJH installer...") logger.info("Installing TLJH installer...")
else: else: