Skip to content

Commit 9099def

Browse files
authored
[MRG] install notebook in its own env (#651)
[MRG] install notebook in its own env
2 parents 7681a6c + e2c7de8 commit 9099def

File tree

21 files changed

+119
-69
lines changed

21 files changed

+119
-69
lines changed

docs/source/changelog.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ New features
1313
:user:`davidanthoff`
1414
- Set JULIA_PROJECT globally, so that every julia instance starts with the
1515
julia environment activated in :pr:`612` by :user:`davidanthoff`.
16+
- Update Miniconda version to 4.6.14 and Conda version to 4.6.14 in :pr:`637` by
17+
:user:`jhamman`
18+
- Install notebook into `notebook` env instead of `root`.
19+
Activate conda environments and shell integration via ENTRYPOINT
20+
in :pr:`651` by :user:`minrk`
1621

1722
API changes
1823
-----------

repo2docker/buildpacks/base.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,13 @@
155155
# Add start script
156156
{% if start_script is not none -%}
157157
RUN chmod +x "{{ start_script }}"
158-
ENTRYPOINT ["{{ start_script }}"]
158+
ENV R2D_ENTRYPOINT "{{ start_script }}"
159159
{% endif -%}
160160
161+
# Add entrypoint
162+
COPY /repo2docker-entrypoint /usr/local/bin/repo2docker-entrypoint
163+
ENTRYPOINT ["/usr/local/bin/repo2docker-entrypoint"]
164+
161165
# Specify the default command to run
162166
CMD ["jupyter", "notebook", "--ip", "0.0.0.0"]
163167
@@ -167,6 +171,11 @@
167171
{% endif %}
168172
"""
169173

174+
ENTRYPOINT_FILE = os.path.join(
175+
os.path.dirname(os.path.abspath(__file__)),
176+
"repo2docker-entrypoint",
177+
)
178+
170179

171180
class BuildPack:
172181
"""
@@ -493,6 +502,8 @@ def _filter_tar(tar):
493502
src_path = os.path.join(os.path.dirname(__file__), *src_parts)
494503
tar.add(src_path, src, filter=_filter_tar)
495504

505+
tar.add(ENTRYPOINT_FILE, "repo2docker-entrypoint", filter=_filter_tar)
506+
496507
tar.add('.', 'src/', filter=_filter_tar)
497508

498509
tar.close()

repo2docker/buildpacks/conda/__init__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def get_build_env(self):
2828
"""
2929
env = super().get_build_env() + [
3030
('CONDA_DIR', '${APP_BASE}/conda'),
31-
('NB_PYTHON_PREFIX', '${CONDA_DIR}'),
31+
('NB_PYTHON_PREFIX', '${CONDA_DIR}/envs/notebook'),
3232
]
3333
if self.py2:
3434
env.append(('KERNEL_PYTHON_PREFIX', '${CONDA_DIR}/envs/kernel'))
@@ -42,9 +42,10 @@ def get_path(self):
4242
4343
"""
4444
path = super().get_path()
45+
path.insert(0, '${CONDA_DIR}/bin')
4546
if self.py2:
4647
path.insert(0, '${KERNEL_PYTHON_PREFIX}/bin')
47-
path.insert(0, '${CONDA_DIR}/bin')
48+
path.insert(0, '${NB_PYTHON_PREFIX}/bin')
4849
return path
4950

5051
def get_build_scripts(self):
@@ -97,6 +98,7 @@ def get_build_script_files(self):
9798
"""
9899
files = {
99100
'conda/install-miniconda.bash': '/tmp/install-miniconda.bash',
101+
'conda/activate-conda.sh': '/etc/profile.d/activate-conda.sh',
100102
}
101103
py_version = self.python_version
102104
self.log.info("Building conda environment for python=%s" % py_version)
@@ -174,16 +176,16 @@ def get_assemble_scripts(self):
174176
"""
175177
assembly_scripts = []
176178
environment_yml = self.binder_path('environment.yml')
177-
env_name = 'kernel' if self.py2 else 'root'
179+
env_prefix = "${KERNEL_PYTHON_PREFIX}" if self.py2 else "${NB_PYTHON_PREFIX}"
178180
if os.path.exists(environment_yml):
179181
assembly_scripts.append((
180182
'${NB_USER}',
181183
r"""
182-
conda env update -n {0} -f "{1}" && \
184+
conda env update -p {0} -f "{1}" && \
183185
conda clean -tipsy && \
184-
conda list -n {0} && \
186+
conda list -p {0} && \
185187
rm -rf /srv/conda/pkgs
186-
""".format(env_name, environment_yml)
188+
""".format(env_prefix, environment_yml)
187189
))
188190
return super().get_assemble_scripts() + assembly_scripts
189191

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# enable conda and activate the notebook environment
2+
CONDA_PROFILE="${CONDA_DIR}/etc/profile.d/conda.sh"
3+
test -f $CONDA_PROFILE && . $CONDA_PROFILE
4+
if [[ "${KERNEL_PYTHON_PREFIX}" != "${NB_PYTHON_PREFIX}" ]]; then
5+
# if the kernel is a separate env, stack them
6+
# so both are on PATH
7+
conda activate ${KERNEL_PYTHON_PREFIX}
8+
conda activate --stack ${NB_PYTHON_PREFIX}
9+
else
10+
conda activate ${NB_PYTHON_PREFIX}
11+
fi

repo2docker/buildpacks/conda/environment.frozen.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# AUTO GENERATED FROM environment.py-3.7.yml, DO NOT MANUALLY MODIFY
2-
# Frozen on 2019-04-24 18:01:25 UTC
2+
# Frozen on 2019-04-26 14:12:19 UTC
33
name: r2d
44
channels:
55
- conda-forge
@@ -16,7 +16,7 @@ dependencies:
1616
- defusedxml=0.5.0=py_1
1717
- entrypoints=0.3=py37_1000
1818
- ipykernel=5.1.0=py37h24bf2e0_1002
19-
- ipython=7.4.0=py37h24bf2e0_0
19+
- ipython=7.5.0=py37h24bf2e0_0
2020
- ipython_genutils=0.2.0=py_1
2121
- ipywidgets=7.4.2=py_0
2222
- jedi=0.13.3=py37_0
@@ -27,7 +27,9 @@ dependencies:
2727
- jupyterlab=0.35.4=py37_0
2828
- jupyterlab_server=0.2.0=py_0
2929
- libffi=3.2.1=he1b5a44_1006
30+
- libgcc-ng=8.2.0=hdf63c60_1
3031
- libsodium=1.0.16=h14c3975_1001
32+
- libstdcxx-ng=8.2.0=hdf63c60_1
3133
- markupsafe=1.1.1=py37h14c3975_0
3234
- mistune=0.8.4=py37h14c3975_1000
3335
- nbconvert=5.4.1=py_2
@@ -45,7 +47,7 @@ dependencies:
4547
- prompt_toolkit=2.0.9=py_0
4648
- ptyprocess=0.6.0=py_1001
4749
- pygments=2.3.1=py_0
48-
- pyrsistent=0.14.11=py37h14c3975_0
50+
- pyrsistent=0.15.1=py37h516909a_0
4951
- python=3.7.3=h5b0a415_0
5052
- python-dateutil=2.8.0=py_0
5153
- pyzmq=18.0.1=py37hc4ba49a_1
@@ -66,8 +68,6 @@ dependencies:
6668
- xz=5.2.4=h14c3975_1001
6769
- zeromq=4.3.1=hf484d3e_1000
6870
- zlib=1.2.11=h14c3975_1004
69-
- libgcc-ng=8.2.0=hdf63c60_1
70-
- libstdcxx-ng=8.2.0=hdf63c60_1
7171
- pip:
7272
- alembic==1.0.9
7373
- async-generator==1.10

repo2docker/buildpacks/conda/environment.py-2.7.frozen.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# AUTO GENERATED FROM environment.py-2.7.yml, DO NOT MANUALLY MODIFY
2-
# Frozen on 2019-04-24 17:58:08 UTC
2+
# Frozen on 2019-04-26 14:09:19 UTC
33
name: r2d
44
channels:
55
- conda-forge
@@ -20,7 +20,9 @@ dependencies:
2020
- jupyter_client=5.2.4=py_3
2121
- jupyter_core=4.4.0=py_0
2222
- libffi=3.2.1=he1b5a44_1006
23+
- libgcc-ng=8.2.0=hdf63c60_1
2324
- libsodium=1.0.16=h14c3975_1001
25+
- libstdcxx-ng=8.2.0=hdf63c60_1
2426
- ncurses=6.1=hf484d3e_1002
2527
- openssl=1.1.1b=h14c3975_1
2628
- pathlib2=2.3.3=py27_1000
@@ -47,7 +49,5 @@ dependencies:
4749
- wheel=0.33.1=py27_0
4850
- zeromq=4.3.1=hf484d3e_1000
4951
- zlib=1.2.11=h14c3975_1004
50-
- libgcc-ng=8.2.0=hdf63c60_1
51-
- libstdcxx-ng=8.2.0=hdf63c60_1
5252
prefix: /opt/conda/envs/r2d
5353

repo2docker/buildpacks/conda/environment.py-3.6.frozen.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# AUTO GENERATED FROM environment.py-3.6.yml, DO NOT MANUALLY MODIFY
2-
# Frozen on 2019-04-24 17:59:15 UTC
2+
# Frozen on 2019-04-26 14:10:28 UTC
33
name: r2d
44
channels:
55
- conda-forge
@@ -15,7 +15,7 @@ dependencies:
1515
- defusedxml=0.5.0=py_1
1616
- entrypoints=0.3=py36_1000
1717
- ipykernel=5.1.0=py36h24bf2e0_1002
18-
- ipython=7.4.0=py36h24bf2e0_0
18+
- ipython=7.5.0=py36h24bf2e0_0
1919
- ipython_genutils=0.2.0=py_1
2020
- ipywidgets=7.4.2=py_0
2121
- jedi=0.13.3=py36_0
@@ -26,7 +26,9 @@ dependencies:
2626
- jupyterlab=0.35.4=py36_0
2727
- jupyterlab_server=0.2.0=py_0
2828
- libffi=3.2.1=he1b5a44_1006
29+
- libgcc-ng=8.2.0=hdf63c60_1
2930
- libsodium=1.0.16=h14c3975_1001
31+
- libstdcxx-ng=8.2.0=hdf63c60_1
3032
- markupsafe=1.1.1=py36h14c3975_0
3133
- mistune=0.8.4=py36h14c3975_1000
3234
- nbconvert=5.4.1=py_2
@@ -44,7 +46,7 @@ dependencies:
4446
- prompt_toolkit=2.0.9=py_0
4547
- ptyprocess=0.6.0=py_1001
4648
- pygments=2.3.1=py_0
47-
- pyrsistent=0.14.11=py36h14c3975_0
49+
- pyrsistent=0.15.1=py36h516909a_0
4850
- python=3.6.7=h381d211_1004
4951
- python-dateutil=2.8.0=py_0
5052
- pyzmq=18.0.1=py36hc4ba49a_1
@@ -65,8 +67,6 @@ dependencies:
6567
- xz=5.2.4=h14c3975_1001
6668
- zeromq=4.3.1=hf484d3e_1000
6769
- zlib=1.2.11=h14c3975_1004
68-
- libgcc-ng=8.2.0=hdf63c60_1
69-
- libstdcxx-ng=8.2.0=hdf63c60_1
7070
- pip:
7171
- alembic==1.0.9
7272
- async-generator==1.10

repo2docker/buildpacks/conda/environment.py-3.6.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# AUTO GENERATED FROM environment.yml, DO NOT MANUALLY MODIFY
2-
# Generated on 2019-04-24 17:59:15 UTC
2+
# Generated on 2019-04-26 14:10:28 UTC
33
dependencies:
44
- python=3.6.*
55
- ipywidgets==7.4.2

repo2docker/buildpacks/conda/environment.py-3.7.frozen.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# AUTO GENERATED FROM environment.py-3.7.yml, DO NOT MANUALLY MODIFY
2-
# Frozen on 2019-04-24 18:01:25 UTC
2+
# Frozen on 2019-04-26 14:12:19 UTC
33
name: r2d
44
channels:
55
- conda-forge
@@ -16,7 +16,7 @@ dependencies:
1616
- defusedxml=0.5.0=py_1
1717
- entrypoints=0.3=py37_1000
1818
- ipykernel=5.1.0=py37h24bf2e0_1002
19-
- ipython=7.4.0=py37h24bf2e0_0
19+
- ipython=7.5.0=py37h24bf2e0_0
2020
- ipython_genutils=0.2.0=py_1
2121
- ipywidgets=7.4.2=py_0
2222
- jedi=0.13.3=py37_0
@@ -27,7 +27,9 @@ dependencies:
2727
- jupyterlab=0.35.4=py37_0
2828
- jupyterlab_server=0.2.0=py_0
2929
- libffi=3.2.1=he1b5a44_1006
30+
- libgcc-ng=8.2.0=hdf63c60_1
3031
- libsodium=1.0.16=h14c3975_1001
32+
- libstdcxx-ng=8.2.0=hdf63c60_1
3133
- markupsafe=1.1.1=py37h14c3975_0
3234
- mistune=0.8.4=py37h14c3975_1000
3335
- nbconvert=5.4.1=py_2
@@ -45,7 +47,7 @@ dependencies:
4547
- prompt_toolkit=2.0.9=py_0
4648
- ptyprocess=0.6.0=py_1001
4749
- pygments=2.3.1=py_0
48-
- pyrsistent=0.14.11=py37h14c3975_0
50+
- pyrsistent=0.15.1=py37h516909a_0
4951
- python=3.7.3=h5b0a415_0
5052
- python-dateutil=2.8.0=py_0
5153
- pyzmq=18.0.1=py37hc4ba49a_1
@@ -66,8 +68,6 @@ dependencies:
6668
- xz=5.2.4=h14c3975_1001
6769
- zeromq=4.3.1=hf484d3e_1000
6870
- zlib=1.2.11=h14c3975_1004
69-
- libgcc-ng=8.2.0=hdf63c60_1
70-
- libstdcxx-ng=8.2.0=hdf63c60_1
7171
- pip:
7272
- alembic==1.0.9
7373
- async-generator==1.10

repo2docker/buildpacks/conda/environment.py-3.7.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# AUTO GENERATED FROM environment.yml, DO NOT MANUALLY MODIFY
2-
# Generated on 2019-04-24 18:01:25 UTC
2+
# Generated on 2019-04-26 14:12:19 UTC
33
dependencies:
44
- python=3.7.*
55
- ipywidgets==7.4.2

0 commit comments

Comments
 (0)