Skip to content

Commit 0ef7932

Browse files
committed
Escape environment variable when using Python string formatting
1 parent b8d8206 commit 0ef7932

File tree

5 files changed

+16
-1
lines changed

5 files changed

+16
-1
lines changed

repo2docker/buildpacks/python/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ def get_assemble_scripts(self):
5353
if os.path.exists(nb_requirements_file):
5454
assemble_scripts.append((
5555
'${NB_USER}',
56-
'${NB_PYTHON_PREFIX}/bin/pip install --no-cache-dir -r "{}"'.format(nb_requirements_file)
56+
# want the $NB_PYHTON_PREFIX environment variable, not for
57+
# Python's string formatting to try and replace this
58+
'${{NB_PYTHON_PREFIX}}/bin/pip install --no-cache-dir -r "{}"'.format(nb_requirements_file)
5759
))
5860

5961
# install requirements.txt in the kernel env
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# install this in the kernel's environment, the user wants Python 2 there
2+
numpy
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# install this in the environment in which the notebook server
2+
# is running nbgitpuller does not work with Python 2
3+
nbgitpuller==0.6.1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python-2.7
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env python2
2+
import sys
3+
4+
print(sys.version_info)
5+
assert sys.version_info[:2] == (2, 7)
6+
7+
import numpy

0 commit comments

Comments
 (0)