mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
@@ -6,18 +6,12 @@ from tljh.hooks import hookimpl
|
|||||||
|
|
||||||
@hookimpl
|
@hookimpl
|
||||||
def tljh_extra_user_conda_packages():
|
def tljh_extra_user_conda_packages():
|
||||||
return [
|
return ["hypothesis", "csvtk", "tqdm"]
|
||||||
"hypothesis",
|
|
||||||
"csvtk",
|
|
||||||
"tqdm"
|
|
||||||
]
|
|
||||||
|
|
||||||
@hookimpl
|
@hookimpl
|
||||||
def tljh_extra_user_conda_channels():
|
def tljh_extra_user_conda_channels():
|
||||||
return [
|
return ["conda-forge", "bioconda"]
|
||||||
"conda-forge",
|
|
||||||
"bioconda"
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
@hookimpl
|
@hookimpl
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ def test_conda_packages():
|
|||||||
subprocess.check_call([f"{USER_ENV_PREFIX}/bin/python3", "-c", "import hypothesis"])
|
subprocess.check_call([f"{USER_ENV_PREFIX}/bin/python3", "-c", "import hypothesis"])
|
||||||
subprocess.check_call([f"{USER_ENV_PREFIX}/bin/csvtk", "cat", "--help"])
|
subprocess.check_call([f"{USER_ENV_PREFIX}/bin/csvtk", "cat", "--help"])
|
||||||
|
|
||||||
|
|
||||||
def test_tljh_extra_apt_packages():
|
def test_tljh_extra_apt_packages():
|
||||||
assert os.path.exists("/usr/games/sl")
|
assert os.path.exists("/usr/games/sl")
|
||||||
|
|
||||||
|
|||||||
@@ -32,15 +32,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):
|
def test_ensure_channel_packages(prefix):
|
||||||
"""
|
"""
|
||||||
Test installing packages in conda environment
|
Test installing packages in conda environment
|
||||||
"""
|
"""
|
||||||
conda.ensure_conda_packages(prefix, ["csvtk"], channels=('conda-forge', 'bioconda'))
|
conda.ensure_conda_packages(prefix, ["csvtk"], channels=("conda-forge", "bioconda"))
|
||||||
# Throws an error if this fails
|
# Throws an error if this fails
|
||||||
subprocess.check_call([os.path.join(prefix, "bin", "csvtk"), "cat", "--help"])
|
subprocess.check_call([os.path.join(prefix, "bin", "csvtk"), "cat", "--help"])
|
||||||
|
|
||||||
|
|
||||||
def test_ensure_pip_packages(prefix):
|
def test_ensure_pip_packages(prefix):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ def tljh_extra_user_conda_channels():
|
|||||||
"""
|
"""
|
||||||
Return a list of conda channels to be used during user environment installation.
|
Return a list of conda channels to be used during user environment installation.
|
||||||
"""
|
"""
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@hookspec
|
@hookspec
|
||||||
|
|||||||
@@ -452,14 +452,16 @@ def run_plugin_actions(plugin_manager):
|
|||||||
conda_packages = list(set(itertools.chain(*hook.tljh_extra_user_conda_packages())))
|
conda_packages = list(set(itertools.chain(*hook.tljh_extra_user_conda_packages())))
|
||||||
conda_channels = list(itertools.chain(*hook.tljh_extra_user_conda_channels()))
|
conda_channels = list(itertools.chain(*hook.tljh_extra_user_conda_channels()))
|
||||||
if len(conda_channels) == 0:
|
if len(conda_channels) == 0:
|
||||||
conda_channels = ('conda-forge',)
|
conda_channels = ("conda-forge",)
|
||||||
if conda_packages:
|
if conda_packages:
|
||||||
logger.info(
|
logger.info(
|
||||||
"Installing {} user conda packages collected from plugins: {}".format(
|
"Installing {} user conda packages collected from plugins: {}".format(
|
||||||
len(conda_packages), " ".join(conda_packages)
|
len(conda_packages), " ".join(conda_packages)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
conda.ensure_conda_packages(USER_ENV_PREFIX, conda_packages, conda_channels=conda_channels)
|
conda.ensure_conda_packages(
|
||||||
|
USER_ENV_PREFIX, conda_packages, conda_channels=conda_channels
|
||||||
|
)
|
||||||
|
|
||||||
# Install pip packages
|
# Install pip packages
|
||||||
user_pip_packages = list(set(itertools.chain(*hook.tljh_extra_user_pip_packages())))
|
user_pip_packages = list(set(itertools.chain(*hook.tljh_extra_user_pip_packages())))
|
||||||
|
|||||||
Reference in New Issue
Block a user