Skip to content
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

Make Python3.7 the default #433

Merged
merged 10 commits into from
Jan 31, 2020
54 changes: 54 additions & 0 deletions docs/howto/env/user-environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <install/installing>` 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 pip_pkgs.txt
GeorgianaElena marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions docs/install/index.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _install/installing:

==========
Installing
==========
Expand Down
6 changes: 3 additions & 3 deletions tests/test_conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 13 additions & 5 deletions tljh/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Expand Down