diff --git a/docs/howto/env/user-environment.rst b/docs/howto/env/user-environment.rst index c46b08c..5ea9fcb 100644 --- a/docs/howto/env/user-environment.rst +++ b/docs/howto/env/user-environment.rst @@ -153,3 +153,57 @@ The most common & portable way to fix this when using ``ssh`` is: .. code-block:: bash sudo PATH=${PATH} conda install -c conda-forge gdal + + +Upgrade to a newer Python version +================================= + +All new TLJH installs use miniconda 4.7.10, which comes with a Python 3.7 +environment for the users. The previously TLJH installs came with miniconda 4.5.4, +which meant a Python 3.6 environment. + +To upgrade the Python version of the user environment, one can: + +* **Start fresh on a machine that doesn't have TLJH already installed.** + + See the :ref:`installation guide ` section about how to install TLJH. + +* **Upgrade Python manually.** + + Because upgrading Python for existing installs can break packages alaredy installed + under the old Python, upgrading your current TLJH installation, will NOT upgrade + the Python version of the user environment, but you may do so manually. + + **Steps:** + + 1. Activate the user environment, if using ssh. + If the terminal was started with JupyterHub, this step can be skipped: + + .. code-block:: bash + + source /opt/tljh/user/bin/activate + + 2. Get the list of currently installed pip packages (so you can later install them under the + new Python): + + .. code-block:: bash + + pip freeze > pip_pkgs.txt + + 3. Update all conda installed packages in the environment: + + .. code-block:: bash + + sudo PATH=${PATH} conda update --all + + 4. Update Python version: + + .. code-block:: bash + + sudo PATH=${PATH} conda install python=3.7 + + 5. Install the pip packages previously saved: + + .. code-block:: bash + + pip install -r pip_pkgs.txt diff --git a/docs/install/index.rst b/docs/install/index.rst index a28baca..b783486 100644 --- a/docs/install/index.rst +++ b/docs/install/index.rst @@ -1,3 +1,5 @@ +.. _install/installing: + ========== Installing ========== diff --git a/tests/test_conda.py b/tests/test_conda.py index b1f8872..95c7795 100644 --- a/tests/test_conda.py +++ b/tests/test_conda.py @@ -13,13 +13,13 @@ def prefix(): """ Provide a temporary directory with a conda environment """ - miniconda_version = '4.5.4' - miniconda_installer_md5 = "a946ea1d0c4a642ddf0c3a26a18bb16d" + miniconda_version = '4.7.10' + miniconda_installer_md5 = "1c945f2b3335c7b2b15130b1b2dc5cf4" with tempfile.TemporaryDirectory() as tmpdir: with conda.download_miniconda_installer(miniconda_version, miniconda_installer_md5) as installer_path: conda.install_miniconda(installer_path, tmpdir) conda.ensure_conda_packages(tmpdir, [ - 'conda==4.5.8' + 'conda==4.8.1' ]) yield tmpdir diff --git a/tljh/installer.py b/tljh/installer.py index c02d198..0e8b2ac 100644 --- a/tljh/installer.py +++ b/tljh/installer.py @@ -237,17 +237,25 @@ def ensure_user_environment(user_requirements_txt_file): Set up user conda environment with required packages """ logger.info("Setting up user environment...") - miniconda_version = '4.5.4' - miniconda_installer_md5 = "a946ea1d0c4a642ddf0c3a26a18bb16d" - if not conda.check_miniconda_version(USER_ENV_PREFIX, miniconda_version): + miniconda_old_version = '4.5.4' + miniconda_new_version = '4.7.10' + conda_version = '4.5.8' + + # If no prior miniconda installation is found, we can install a newer version + if not conda.check_miniconda_version( + USER_ENV_PREFIX, miniconda_old_version + ) and not conda.check_miniconda_version(USER_ENV_PREFIX, miniconda_new_version): + miniconda_installer_md5 = "1c945f2b3335c7b2b15130b1b2dc5cf4" + conda_version = '4.8.1' + logger.info('Downloading & setting up user environment...') - with conda.download_miniconda_installer(miniconda_version, miniconda_installer_md5) as installer_path: + with conda.download_miniconda_installer(miniconda_new_version, miniconda_installer_md5) as installer_path: conda.install_miniconda(installer_path, USER_ENV_PREFIX) conda.ensure_conda_packages(USER_ENV_PREFIX, [ # Conda's latest version is on conda much more so than on PyPI. - 'conda==4.5.8' + 'conda==' + conda_version ]) conda.ensure_pip_packages(USER_ENV_PREFIX, [