Skip to content

Specify user-environment Python version #784

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/topic/customizing-installer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 - \
--user-python-version 3.7.10

Installing TLJH plugins
=======================

Expand Down
10 changes: 8 additions & 2 deletions tljh/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, user_python_version):
"""
Set up user conda environment with required packages
"""
Expand All @@ -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"
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"
Expand All @@ -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==" + user_python_version,
],
)

Expand Down Expand Up @@ -438,6 +440,10 @@ def main():
type=int,
help="The pid of the progress page server",
)
argparser.add_argument(
"--user-python-version",
help="Set user-environment Python version",
)

args = argparser.parse_args()

Expand All @@ -446,7 +452,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.user_python_version)

logger.info("Setting up JupyterHub...")
ensure_jupyterhub_package(HUB_ENV_PREFIX)
Expand Down