From 5ab3e47b42f004d2cd847051c72f5c10ab16485c Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Wed, 17 Oct 2018 12:10:08 -0700 Subject: [PATCH] Add workaround for Debian/Ubuntu venv setup failure Signed-off-by: Joffrey F --- script/release/release.sh | 4 ++-- script/release/setup-venv.sh | 25 +++++++++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/script/release/release.sh b/script/release/release.sh index c10f8aba5..5f853808b 100755 --- a/script/release/release.sh +++ b/script/release/release.sh @@ -1,6 +1,6 @@ #!/bin/sh -if test -d ./.release-venv; then +if test -d ${VENV_DIR:-./.release-venv}; then true else ./script/release/setup-venv.sh @@ -10,4 +10,4 @@ if test -z "$*"; then args="--help" fi -./.release-venv/bin/python ./script/release/release.py "$@" +${VENV_DIR:-./.release-venv}/bin/python ./script/release/release.py "$@" diff --git a/script/release/setup-venv.sh b/script/release/setup-venv.sh index d3d3f9a42..780fc800f 100755 --- a/script/release/setup-venv.sh +++ b/script/release/setup-venv.sh @@ -1,5 +1,11 @@ #!/bin/bash +debian_based() { test -f /etc/debian_version; } + +if test -z $VENV_DIR; then + VENV_DIR=./.release-venv +fi + if test -z $PYTHONBIN; then PYTHONBIN=$(which python3) if test -z $PYTHONBIN; then @@ -16,15 +22,26 @@ if test $(echo $VERSION | cut -d. -f2) -lt 3; then echo "Python 3.3 or above is required" fi -$PYTHONBIN -m venv ./.release-venv +# Debian / Ubuntu workaround: +# https://askubuntu.com/questions/879437/ensurepip-is-disabled-in-debian-ubuntu-for-the-system-python +if debian_based; then + VENV_FLAGS="$VENV_FLAGS --without-pip" +fi -VENVBINS=./.release-venv/bin +$PYTHONBIN -m venv $VENV_DIR $VENV_FLAGS -$VENVBINS/pip install -U Jinja2==2.10 \ +VENV_PYTHONBIN=$VENV_DIR/bin/python + +if debian_based; then + curl https://bootstrap.pypa.io/get-pip.py -o $VENV_DIR/get-pip.py + $VENV_PYTHONBIN $VENV_DIR/get-pip.py +fi + +$VENV_PYTHONBIN -m pip install -U Jinja2==2.10 \ PyGithub==1.39 \ pypandoc==1.4 \ GitPython==2.1.9 \ requests==2.18.4 \ twine==1.11.0 -$VENVBINS/python setup.py develop +$VENV_PYTHONBIN setup.py develop