Use fully frozen requirements.txt for venv
Fixes
There's also a 'freeze.bash' script that'll generate the frozen
versions from the unfrozen versions at current date.
MODIFY
repo2docker/buildpacks/python/__init__.py
repo2docker/buildpacks/python/__init__.py
@@ -28,7 +28,7 @@ class PythonBuildPack(BuildPack):
build_script_files = {
- 'python/requirements.txt': '/tmp/requirements.txt',
+ 'python/requirements.frozen.txt': '/tmp/requirements.frozen.txt',
}
build_scripts = [
@@ -48,7 +48,7 @@ class PythonBuildPack(BuildPack):
(
"${NB_USER}",
r"""
- pip install --no-cache-dir -r /tmp/requirements.txt && \
+ pip install --no-cache-dir -r /tmp/requirements.frozen.txt && \
jupyter nbextension enable --py widgetsnbextension --sys-prefix && \
jupyter serverextension enable --py jupyterlab --sys-prefix
"""
@@ -95,7 +95,7 @@ class Python2BuildPack(BuildPack):
}
build_script_files = {
- 'python/requirements2.txt': '/tmp/requirements2.txt',
+ 'python/requirements2.frozen.txt': '/tmp/requirements2.frozen.txt',
}
env = [
@@ -123,7 +123,7 @@ class Python2BuildPack(BuildPack):
(
"${NB_USER}",
r"""
- pip2 install --no-cache-dir -r /tmp/requirements2.txt && \
+ pip2 install --no-cache-dir -r /tmp/requirements2.frozen.txt && \
python2 -m ipykernel install --prefix=${NB_PYTHON_PREFIX}
"""
)

ADD
repo2docker/buildpacks/python/freeze.bash
+#!/bin/bash
+set -euo pipefail
+# Freeze requirements.txt into requirements.frozen.txt, pinning all dependent library versions to
+# versions that are resolved at time of freezing.
+# Does the same for requirements2.txt to requirements2.frozen.txt...
+
+# cd to the directory where the freeze script is located
+dirname "$(readlink -f "$0")"
+
+function freeze-requirements {
+ # Freeze a requirements file $2 into a frozen requirements file $3
+ # Requires that a completely empty venv of appropriate version exist in $1
+ VENV_PATH="$1"
+ REQUIREMENTS_FILE="$2"
+ FROZEN_FILE="$3"
+
+ ./${VENV_PATH}/bin/pip install --no-cache-dir -r ${REQUIREMENTS_FILE}
+ echo "# AUTO GENERATED FROM ${REQUIREMENTS_FILE}, DO NOT MANUALLY MODIFY" > ${FROZEN_FILE}
+ echo "# Frozen on $(date -u)" >> ${FROZEN_FILE}
+ ./${VENV_PATH}/bin/pip freeze | sort >> ${FROZEN_FILE}
+}
+
+rm -rf py3venv
+python3 -m venv py3venv
+freeze-requirements py3venv requirements.txt requirements.frozen.txt
+rm -rf py3venv
+
+
+rm -rf py2venv
+virtualenv -p python2 py2venv
+freeze-requirements py2venv requirements2.txt requirements2.frozen.txt
+rm -rf py2venv

ADD
repo2docker/buildpacks/python/requirements.frozen.txt
+# AUTO GENERATED FROM requirements.txt, DO NOT MANUALLY MODIFY
+# Frozen on Thu Nov 30 08:51:37 UTC 2017
+bleach==2.1.1
+decorator==4.1.2
+entrypoints==0.2.3
+html5lib==1.0b10
+ipykernel==4.6.1
+ipython==6.2.1
+ipython-genutils==0.2.0
+ipywidgets==6.0.0
+jedi==0.11.0
+Jinja2==2.10
+jsonschema==2.6.0
+jupyter-client==5.1.0
+jupyter-core==4.4.0
+jupyterlab==0.28.0
+jupyterlab-launcher==0.6.0
+MarkupSafe==1.0
+mistune==0.8.1
+nbconvert==5.3.1
+nbformat==4.4.0
+notebook==5.2.2
+pandocfilters==1.4.2
+parso==0.1.0
+pexpect==4.3.0
+pickleshare==0.7.4
+pkg-resources==0.0.0
+prompt-toolkit==1.0.15
+ptyprocess==0.5.2
+Pygments==2.2.0
+python-dateutil==2.6.1
+pyzmq==16.0.3
+simplegeneric==0.8.1
+six==1.11.0
+terminado==0.8.1
+testpath==0.3.1
+tornado==4.5.2
+traitlets==4.3.2
+wcwidth==0.1.7
+webencodings==0.5.1
+widgetsnbextension==2.0.1

ADD
repo2docker/buildpacks/python/requirements2.frozen.txt
+# AUTO GENERATED FROM requirements2.txt, DO NOT MANUALLY MODIFY
+# Frozen on Thu Nov 30 08:51:48 UTC 2017
+backports-abc==0.5
+backports.shutil-get-terminal-size==1.0.0
+certifi==2017.11.5
+decorator==4.1.2
+enum34==1.1.6
+ipykernel==4.6.1
+ipython==5.5.0
+ipython-genutils==0.2.0
+jupyter-client==5.1.0
+jupyter-core==4.4.0
+pathlib2==2.3.0
+pexpect==4.3.0
+pickleshare==0.7.4
+pkg-resources==0.0.0
+prompt-toolkit==1.0.15
+ptyprocess==0.5.2
+Pygments==2.2.0
+python-dateutil==2.6.1
+pyzmq==16.0.3
+scandir==1.6
+simplegeneric==0.8.1
+singledispatch==3.4.0.3
+six==1.11.0
+tornado==4.5.2
+traitlets==4.3.2
+wcwidth==0.1.7

Use fully frozen requirements.txt for venv

Fixes #154

There's also a 'freeze.bash' script that'll generate the frozen
versions from the unfrozen versions at current date.