Skip to content

Commit bf312ab

Browse files
authored
Merge pull request #377 from betatim/escape-me
[MRG] Escape environment variable when using Python string formatting
2 parents 9cb14b4 + a1df2eb commit bf312ab

File tree

5 files changed

+28
-1
lines changed

5 files changed

+28
-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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python2
2+
import os
3+
import sys
4+
5+
print(sys.version_info)
6+
assert sys.version_info[:2] == (2, 7)
7+
8+
import numpy
9+
10+
try:
11+
import nbgitpuller
12+
except ImportError:
13+
pass
14+
else:
15+
raise Exception("'nbgitpuller' shouldn't have been installed from requirements3.txt")
16+
17+
# Python 3 is the executable used for the notebook server, this should
18+
# have nbgitpuller installed
19+
os.system("python3 -c 'import nbgitpuller'")

0 commit comments

Comments
 (0)