mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Adding the ability to define conda channels
This commit is contained in:
@@ -43,6 +43,15 @@ def test_ensure_packages(prefix):
|
|||||||
# Throws an error if this fails
|
# Throws an error if this fails
|
||||||
subprocess.check_call([os.path.join(prefix, "bin", "python"), "-c", "import numpy"])
|
subprocess.check_call([os.path.join(prefix, "bin", "python"), "-c", "import numpy"])
|
||||||
|
|
||||||
|
|
||||||
|
def test_ensure_channel_packages(prefix):
|
||||||
|
"""
|
||||||
|
Test installing packages in conda environment
|
||||||
|
"""
|
||||||
|
conda.ensure_conda_packages(prefix, ["csvtk"], channels=('conda-forge', 'bioconda'))
|
||||||
|
# Throws an error if this fails
|
||||||
|
subprocess.check_call([os.path.join(prefix, "bin", "csvtk"), "cat", "--help"])
|
||||||
|
|
||||||
|
|
||||||
def test_ensure_pip_packages(prefix):
|
def test_ensure_pip_packages(prefix):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -90,9 +90,9 @@ def install_miniconda(installer_path, prefix):
|
|||||||
fix_permissions(prefix)
|
fix_permissions(prefix)
|
||||||
|
|
||||||
|
|
||||||
def ensure_conda_packages(prefix, packages):
|
def ensure_conda_packages(prefix, packages, channels=('conda-forge',)):
|
||||||
"""
|
"""
|
||||||
Ensure packages (from conda-forge) are installed in the conda prefix.
|
Ensure packages (from channels) are installed in the conda prefix.
|
||||||
|
|
||||||
Note that conda seem to update dependencies by default, so there is probably
|
Note that conda seem to update dependencies by default, so there is probably
|
||||||
no need to have a update parameter exposed for this function.
|
no need to have a update parameter exposed for this function.
|
||||||
@@ -103,16 +103,18 @@ def ensure_conda_packages(prefix, packages):
|
|||||||
# Explicitly do *not* capture stderr, since that's not always JSON!
|
# Explicitly do *not* capture stderr, since that's not always JSON!
|
||||||
# Scripting conda is a PITA!
|
# Scripting conda is a PITA!
|
||||||
# FIXME: raise different exception when using
|
# FIXME: raise different exception when using
|
||||||
|
|
||||||
|
channel_cmd = '-c ' + ' -c '.join(channels)
|
||||||
|
|
||||||
raw_output = subprocess.check_output(
|
raw_output = subprocess.check_output(
|
||||||
conda_executable
|
conda_executable
|
||||||
+ [
|
+ [
|
||||||
"install",
|
"install",
|
||||||
"-c",
|
|
||||||
"conda-forge", # Make customizable if we ever need to
|
|
||||||
"--json",
|
"--json",
|
||||||
"--prefix",
|
"--prefix",
|
||||||
abspath,
|
abspath,
|
||||||
]
|
]
|
||||||
|
+ channel_cmd.split()
|
||||||
+ packages
|
+ packages
|
||||||
).decode()
|
).decode()
|
||||||
# `conda install` outputs JSON lines for fetch updates,
|
# `conda install` outputs JSON lines for fetch updates,
|
||||||
|
|||||||
Reference in New Issue
Block a user