From 9ee013b514c23f83a4b4f6732c0a1b4e8104da68 Mon Sep 17 00:00:00 2001 From: oisinBates Date: Sat, 18 Dec 2021 09:17:50 -0800 Subject: [PATCH 1/6] adding optional flag for user-environment python version --- tljh/installer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tljh/installer.py b/tljh/installer.py index 2e91e183e..ccf19cfc9 100644 --- a/tljh/installer.py +++ b/tljh/installer.py @@ -153,7 +153,7 @@ def ensure_usergroups(): f.write("Defaults exempt_group = jupyterhub-admins\n") -def ensure_user_environment(user_requirements_txt_file): +def ensure_user_environment(user_requirements_txt_file, python_version): """ Set up user conda environment with required packages """ @@ -180,6 +180,7 @@ def ensure_user_environment(user_requirements_txt_file): # Keep these in sync with tests/test_conda.py::prefix mambaforge_conda_new_version = "4.10.3" mambaforge_mamba_version = "0.16.0" + python_version = python_version if python_version else "3.9.*" if conda.check_miniconda_version(USER_ENV_PREFIX, mambaforge_conda_new_version): conda_version = "4.10.3" @@ -205,6 +206,7 @@ def ensure_user_environment(user_requirements_txt_file): # Conda's latest version is on conda much more so than on PyPI. "conda==" + conda_version, "mamba==" + mambaforge_mamba_version, + "python==" + python_version ], ) @@ -446,7 +448,7 @@ def main(): ensure_config_yaml(pm) ensure_admins(args.admin) ensure_usergroups() - ensure_user_environment(args.user_requirements_txt_url) + ensure_user_environment(args.user_requirements_txt_url, args.python_version) logger.info("Setting up JupyterHub...") ensure_jupyterhub_package(HUB_ENV_PREFIX) From bd33cc430e8180d02556573a4609833722594a73 Mon Sep 17 00:00:00 2001 From: oisinBates Date: Sat, 18 Dec 2021 10:10:06 -0800 Subject: [PATCH 2/6] adding optional flag for user-environment python version --- tljh/installer.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tljh/installer.py b/tljh/installer.py index ccf19cfc9..bed77b657 100644 --- a/tljh/installer.py +++ b/tljh/installer.py @@ -440,6 +440,10 @@ def main(): type=int, help="The pid of the progress page server", ) + argparser.add_argument( + "--python-version", + help="Set user-environment Python version", + ) args = argparser.parse_args() From e11d7c26ae7dd19659027a0e07975388056f39e0 Mon Sep 17 00:00:00 2001 From: oisinBates Date: Sun, 19 Dec 2021 15:46:17 -0800 Subject: [PATCH 3/6] updating documentation --- docs/topic/customizing-installer.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/topic/customizing-installer.rst b/docs/topic/customizing-installer.rst index e85dd48ad..a340fbf06 100644 --- a/docs/topic/customizing-installer.rst +++ b/docs/topic/customizing-installer.rst @@ -107,6 +107,21 @@ will fail. When pointing to a file on GitHub, make sure to use the 'Raw' version. It should point to ``raw.githubusercontent.com``, not ``github.com``. +Specifying the user-environment Python version +======================= + +By default the user environment is provisioned with the latest version of Python 3.9, +though it is possible to specify a specific Python version if desired. + +For example, to set Python version 3.7.10 for the user environment, +you would use: + +.. code-block:: bash + + curl -L https://tljh.jupyter.org/bootstrap.py \ + | sudo python3 - \ + --python-version 3.7.10 + Installing TLJH plugins ======================= From 030b931e851387a1106bb0e14b5a48fc9999e213 Mon Sep 17 00:00:00 2001 From: oisinBates Date: Sun, 19 Dec 2021 16:02:33 -0800 Subject: [PATCH 4/6] updating python-version variable name --- docs/topic/customizing-installer.rst | 2 +- tljh/installer.py | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/topic/customizing-installer.rst b/docs/topic/customizing-installer.rst index a340fbf06..299523853 100644 --- a/docs/topic/customizing-installer.rst +++ b/docs/topic/customizing-installer.rst @@ -120,7 +120,7 @@ you would use: curl -L https://tljh.jupyter.org/bootstrap.py \ | sudo python3 - \ - --python-version 3.7.10 + --user-python-version 3.7.10 Installing TLJH plugins ======================= diff --git a/tljh/installer.py b/tljh/installer.py index bed77b657..a208722ba 100644 --- a/tljh/installer.py +++ b/tljh/installer.py @@ -153,7 +153,7 @@ def ensure_usergroups(): f.write("Defaults exempt_group = jupyterhub-admins\n") -def ensure_user_environment(user_requirements_txt_file, python_version): +def ensure_user_environment(user_requirements_txt_file, user_python_version): """ Set up user conda environment with required packages """ @@ -180,7 +180,6 @@ def ensure_user_environment(user_requirements_txt_file, python_version): # Keep these in sync with tests/test_conda.py::prefix mambaforge_conda_new_version = "4.10.3" mambaforge_mamba_version = "0.16.0" - python_version = python_version if python_version else "3.9.*" if conda.check_miniconda_version(USER_ENV_PREFIX, mambaforge_conda_new_version): conda_version = "4.10.3" @@ -206,7 +205,7 @@ def ensure_user_environment(user_requirements_txt_file, python_version): # Conda's latest version is on conda much more so than on PyPI. "conda==" + conda_version, "mamba==" + mambaforge_mamba_version, - "python==" + python_version + "python==" + user_python_version, ], ) @@ -442,7 +441,7 @@ def main(): ) argparser.add_argument( "--python-version", - help="Set user-environment Python version", + default="3.9.*", help="Set user-environment Python version", ) args = argparser.parse_args() @@ -452,7 +451,7 @@ def main(): ensure_config_yaml(pm) ensure_admins(args.admin) ensure_usergroups() - ensure_user_environment(args.user_requirements_txt_url, args.python_version) + ensure_user_environment(args.user_requirements_txt_url, args.user_python_version) logger.info("Setting up JupyterHub...") ensure_jupyterhub_package(HUB_ENV_PREFIX) From bb8aa89a81a3ac8fee08154fdfe66454f6853ba9 Mon Sep 17 00:00:00 2001 From: oisinBates Date: Sun, 19 Dec 2021 16:10:36 -0800 Subject: [PATCH 5/6] updating python-version logic --- tljh/installer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tljh/installer.py b/tljh/installer.py index a208722ba..977f8e1e3 100644 --- a/tljh/installer.py +++ b/tljh/installer.py @@ -180,6 +180,7 @@ def ensure_user_environment(user_requirements_txt_file, user_python_version): # Keep these in sync with tests/test_conda.py::prefix mambaforge_conda_new_version = "4.10.3" mambaforge_mamba_version = "0.16.0" + user_python_version = user_python_version if user_python_version else "3.9.*" if conda.check_miniconda_version(USER_ENV_PREFIX, mambaforge_conda_new_version): conda_version = "4.10.3" @@ -441,7 +442,7 @@ def main(): ) argparser.add_argument( "--python-version", - default="3.9.*", help="Set user-environment Python version", + help="Set user-environment Python version", ) args = argparser.parse_args() From 8ae3993751aa201bd8c14f471187b5dfdbb277ba Mon Sep 17 00:00:00 2001 From: oisinBates Date: Sun, 19 Dec 2021 16:12:18 -0800 Subject: [PATCH 6/6] fixing arg typo --- tljh/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tljh/installer.py b/tljh/installer.py index 977f8e1e3..ecf2e5ea1 100644 --- a/tljh/installer.py +++ b/tljh/installer.py @@ -441,7 +441,7 @@ def main(): help="The pid of the progress page server", ) argparser.add_argument( - "--python-version", + "--user-python-version", help="Set user-environment Python version", )