kopia lustrzana https://github.com/jupyterhub/repo2docker
commit
80b979f858
|
@ -36,6 +36,13 @@ class CondaBuildPack(BaseImage):
|
||||||
env.append(('KERNEL_PYTHON_PREFIX', '${NB_PYTHON_PREFIX}'))
|
env.append(('KERNEL_PYTHON_PREFIX', '${NB_PYTHON_PREFIX}'))
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
def get_env(self):
|
||||||
|
"""Make kernel env the default for `conda install`"""
|
||||||
|
env = super().get_env() + [
|
||||||
|
('CONDA_DEFAULT_ENV', '${KERNEL_PYTHON_PREFIX}'),
|
||||||
|
]
|
||||||
|
return env
|
||||||
|
|
||||||
def get_path(self):
|
def get_path(self):
|
||||||
"""Return paths (including conda environment path) to be added to
|
"""Return paths (including conda environment path) to be added to
|
||||||
the PATH environment variable.
|
the PATH environment variable.
|
||||||
|
|
|
@ -3,9 +3,16 @@ CONDA_PROFILE="${CONDA_DIR}/etc/profile.d/conda.sh"
|
||||||
test -f $CONDA_PROFILE && . $CONDA_PROFILE
|
test -f $CONDA_PROFILE && . $CONDA_PROFILE
|
||||||
if [[ "${KERNEL_PYTHON_PREFIX}" != "${NB_PYTHON_PREFIX}" ]]; then
|
if [[ "${KERNEL_PYTHON_PREFIX}" != "${NB_PYTHON_PREFIX}" ]]; then
|
||||||
# if the kernel is a separate env, stack them
|
# if the kernel is a separate env, stack them
|
||||||
# so both are on PATH
|
# so both are on PATH, notebook first
|
||||||
conda activate ${KERNEL_PYTHON_PREFIX}
|
conda activate ${KERNEL_PYTHON_PREFIX}
|
||||||
conda activate --stack ${NB_PYTHON_PREFIX}
|
conda activate --stack ${NB_PYTHON_PREFIX}
|
||||||
|
|
||||||
|
# even though it's second on $PATH
|
||||||
|
# make sure CONDA_DEFAULT_ENV is the *kernel* env
|
||||||
|
# so that `!conda install PKG` installs in the kernel env
|
||||||
|
# where user packages are installed, not the notebook env
|
||||||
|
# which only contains UI when the two are different
|
||||||
|
export CONDA_DEFAULT_ENV="${KERNEL_PYTHON_PREFIX}"
|
||||||
else
|
else
|
||||||
conda activate ${NB_PYTHON_PREFIX}
|
conda activate ${NB_PYTHON_PREFIX}
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# install pytest with conda in the default env (should be $KERNEL_PYTHON_PREFIX)
|
||||||
|
conda install -yq pytest
|
||||||
|
# install there with pip (should be the same)
|
||||||
|
pip install there
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
pytest -v ./verify.py
|
|
@ -0,0 +1,13 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def test_sys_prefix():
|
||||||
|
# verify that pytest was installed in the notebook env
|
||||||
|
assert sys.prefix == os.environ["KERNEL_PYTHON_PREFIX"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_there():
|
||||||
|
# verify that there was installed in the notebook env
|
||||||
|
import there
|
Ładowanie…
Reference in New Issue