def ensure_user_environment(user_requirements_txt_file):
    """
    Set up user conda environment with required packages
    """
    logger.info("Setting up user environment...")

    miniconda_old_version = '4.5.4'
    miniconda_new_version = '4.7.10'
    miniconda_installer_sha256 = "8a324adcc9eaf1c09e22a992bb6234d91a94146840ee6b11c114ecadafc68121"

    if conda.check_miniconda_version(USER_ENV_PREFIX, miniconda_new_version):
        conda_version = '4.8.1'
    elif conda.check_miniconda_version(USER_ENV_PREFIX, miniconda_old_version):
        conda_version = '4.5.8'
    # If no prior miniconda installation is found, we can install a newer version
    else:
        logger.info('Downloading & setting up user environment...')
        # FIXME: allow using miniforge
        installer_url = "https://repo.continuum.io/miniconda/Miniconda3-{}-Linux-x86_64.sh".format(
            miniconda_new_version)
        with conda.download_miniconda_installer(
                installer_url, miniconda_installer_sha256) as installer_path:
            conda.install_miniconda(installer_path, USER_ENV_PREFIX)
        conda_version = '4.8.1'

    conda.ensure_conda_packages(
        USER_ENV_PREFIX,
        [
            # Conda's latest version is on conda much more so than on PyPI.
            'conda==' + conda_version
        ])

    conda.ensure_pip_requirements(
        USER_ENV_PREFIX,
        os.path.join(HERE, 'requirements-base.txt'),
    )

    if user_requirements_txt_file:
        # FIXME: This currently fails hard, should fail soft and not abort installer
        conda.ensure_pip_requirements(USER_ENV_PREFIX,
                                      user_requirements_txt_file)
def ensure_user_environment(user_requirements_txt_file):
    """
    Set up user conda environment with required packages
    """
    logger.info("Setting up user environment...")

    miniconda_old_version = '4.5.4'
    miniconda_new_version = '4.7.10'
    miniconda_installer_sha256 = "1314b90489f154602fd794accfc90446111514a5a72fe1f71ab83e07de9504a7"

    if conda.check_miniconda_version(USER_ENV_PREFIX, miniconda_new_version):
        conda_version = '4.8.1'
    elif conda.check_miniconda_version(USER_ENV_PREFIX, miniconda_old_version):
        conda_version = '4.5.8'
    # If no prior miniconda installation is found, we can install a newer version
    else:
        logger.info('Downloading & setting up user environment...')
        # FIXME: allow using miniforge
        installer_url = "https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh"
        with conda.download_miniconda_installer(
                installer_url, miniconda_installer_sha256) as installer_path:
            conda.install_miniconda(installer_path, USER_ENV_PREFIX)
        conda_version = '4.9.2'

    conda.ensure_conda_packages(
        USER_ENV_PREFIX,
        [
            # Conda's latest version is on conda much more so than on PyPI.
            'conda==' + conda_version
        ])

    conda.ensure_pip_requirements(
        USER_ENV_PREFIX,
        os.path.join(HERE, 'requirements-base.txt'),
    )

    if user_requirements_txt_file:
        # FIXME: This currently fails hard, should fail soft and not abort installer
        conda.ensure_pip_requirements(USER_ENV_PREFIX,
                                      user_requirements_txt_file)
Example #3
0
def ensure_user_environment(user_requirements_txt_file):
    """
    Set up user conda environment with required packages
    """
    logger.info("Setting up user environment...")

    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_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==' + conda_version
        ])

    conda.ensure_pip_requirements(
        USER_ENV_PREFIX,
        os.path.join(HERE, 'requirements-base.txt'),
    )

    if user_requirements_txt_file:
        # FIXME: This currently fails hard, should fail soft and not abort installer
        conda.ensure_pip_requirements(USER_ENV_PREFIX,
                                      user_requirements_txt_file)
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):
        logger.info('Downloading & setting up user environment...')
        with conda.download_miniconda_installer(miniconda_version, miniconda_installer_md5) as installer_path:
            conda.install_miniconda(installer_path, USER_ENV_PREFIX)

    # nbresuse needs psutil, which requires gcc
    apt.install_packages([
        'gcc'
    ])

    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.ensure_pip_packages(USER_ENV_PREFIX, [
        # JupyterHub + notebook package are base requirements for user environment
        'jupyterhub==0.9.1',
        'notebook==5.6.0',
        # Install additional notebook frontends!
        'jupyterlab==0.32.1',
        'nteract-on-jupyter==1.8.1',
        # nbgitpuller for easily pulling in Git repositories
        'nbgitpuller==0.6.1',
        # nbresuse to show people how much RAM they are using
        'nbresuse==0.3.0'
    ])

    if user_requirements_txt_file:
        # FIXME: This currently fails hard, should fail soft and not abort installer
        conda.ensure_pip_requirements(USER_ENV_PREFIX, user_requirements_txt_file)
def ensure_user_environment(user_requirements_txt_file):
    """
    Set up user conda environment with required packages
    """
    logger.info("Setting up user environment...")

    miniconda_old_version = "4.5.4"
    miniconda_new_version = "4.7.10"
    # Install mambaforge using an installer from
    # https://github.com/conda-forge/miniforge/releases
    mambaforge_new_version = "4.10.3-7"
    # Check system architecture, set appropriate installer checksum
    if os.uname().machine == "aarch64":
        installer_sha256 = (
            "ac95f137b287b3408e4f67f07a284357b1119ee157373b788b34e770ef2392b2")
    elif os.uname().machine == "x86_64":
        installer_sha256 = (
            "fc872522ec427fcab10167a93e802efaf251024b58cc27b084b915a9a73c4474")
    # Check OS, set appropriate string for conda installer path
    if os.uname().sysname != "Linux":
        raise OSError("TLJH is only supported on Linux platforms.")
    # Then run `mamba --version` to get the conda and mamba versions
    # Keep these in sync with tests/test_conda.py::prefix
    mambaforge_conda_new_version = "4.10.3"
    mambaforge_mamba_version = "0.16.0"

    if conda.check_miniconda_version(USER_ENV_PREFIX,
                                     mambaforge_conda_new_version):
        conda_version = "4.10.3"
    elif conda.check_miniconda_version(USER_ENV_PREFIX, miniconda_new_version):
        conda_version = "4.8.1"
    elif conda.check_miniconda_version(USER_ENV_PREFIX, miniconda_old_version):
        conda_version = "4.5.8"
    # If no prior miniconda installation is found, we can install a newer version
    else:
        logger.info("Downloading & setting up user environment...")
        installer_url = "https://github.com/conda-forge/miniforge/releases/download/{v}/Mambaforge-{v}-Linux-{arch}.sh".format(
            v=mambaforge_new_version, arch=os.uname().machine)
        with conda.download_miniconda_installer(
                installer_url, installer_sha256) as installer_path:
            conda.install_miniconda(installer_path, USER_ENV_PREFIX)
        conda_version = "4.10.3"

    conda.ensure_conda_packages(
        USER_ENV_PREFIX,
        [
            # Conda's latest version is on conda much more so than on PyPI.
            "conda==" + conda_version,
            "mamba==" + mambaforge_mamba_version,
        ],
    )

    conda.ensure_pip_requirements(
        USER_ENV_PREFIX,
        os.path.join(HERE, "requirements-base.txt"),
        upgrade=True,
    )

    if user_requirements_txt_file:
        # FIXME: This currently fails hard, should fail soft and not abort installer
        conda.ensure_pip_requirements(
            USER_ENV_PREFIX,
            user_requirements_txt_file,
            upgrade=True,
        )