run freeze-requirements in docker
avoids mismatch between freeze env and 'real' env, e.g. running on mac, where dependencies differ,
or running with Python 3.4 vs 3.5, etc.
@@ -17,23 +17,23 @@ cd $(dirname "$($realpath "$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"
+ PYTHON_VERSION="$1"
REQUIREMENTS_FILE="$2"
FROZEN_FILE="$3"
+ if [[ $(echo ${PYTHON_VERSION} | cut -d. -f 1) == "2" ]]; then
+ VENV=virtualenv
+ else
+ VENV=venv
+ fi
- ./${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}
+ docker run --rm -v $PWD:/python -it python:${PYTHON_VERSION} \
+ sh -c "
+ python -m $VENV /venv
+ /venv/bin/pip install -r /python/${REQUIREMENTS_FILE} &&
+ /venv/bin/pip freeze | sort --ignore-case >> /python/${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
+freeze-requirements 3.5 requirements.txt requirements.frozen.txt
+freeze-requirements 2.7 requirements2.txt requirements2.frozen.txt
