summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabien Catteau <fcatteau@gitlab.com>2019-06-07 16:46:05 +0000
committerFabien Catteau <fcatteau@gitlab.com>2019-06-07 16:46:05 +0000
commitc1eff826603590c83778ff8c2e8aa018df5c0e73 (patch)
treeb54b9f1850a607daa1e31bd953255314f1d6a488
parent86bcbbc7758ee2f084d7baa624a349adc654c20c (diff)
parent368542b7fd5f1599a29722ea31a0166ce8848c50 (diff)
Merge branch 'python3' into 'master'v1.3.0
Add option to select Python version 2 or 3 See merge request gitlab-org/security-products/license-management!36
-rw-r--r--CHANGELOG.md4
-rw-r--r--Dockerfile27
-rwxr-xr-xrun.sh20
3 files changed, 49 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2c39ad2..a2d60d8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# GitLab License management changelog
+## v1.3.0
+
+- Add `LM_PYTHON_VERSION` variable, to be set to `3` to switch to Python 3.5, pip 19.1.1. (!36)
+
## v1.2.6
- Fix: better support of go projects (!31)
diff --git a/Dockerfile b/Dockerfile
index 359fef3..900019b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -15,12 +15,35 @@ RUN cd /tmp && \
RUN npm install npm-install-peers cheerio
-# Don't let Rubygem fail with the numerous projects using PG or MySQL, install realpath
-RUN apt-get update && apt-get install -y libpq-dev libmysqlclient-dev realpath && rm -rf /var/lib/apt/lists/*
+# Don't let Rubygem fail with the numerous projects using PG or MySQL,
+# install realpath, includes for python3, and pip for python3
+RUN apt-get update && \
+ apt-get install -y --no-install-recommends \
+ libpq-dev libmysqlclient-dev realpath python3-dev python3-pip && \
+ rm -rf /var/lib/apt/lists/*
# Don't load RVM automatically, it doesn't work with GitLab-CI
RUN mv /etc/profile.d/rvm.sh /rvm.sh
+# Warning! Environment variable PIP_VERSION causes the upgrade of pip to fail.
+ARG VERSION_OF_PIP=19.1.1
+ENV VERSION_OF_PIP $VERSION_OF_PIP
+
+ARG SETUPTOOLS_VERSION=41.0.1
+ENV SETUPTOOLS_VERSION $SETUPTOOLS_VERSION
+
+ARG LOCAL_PYPI_INDEX=/pypi
+ENV LOCAL_PYPI_INDEX $LOCAL_PYPI_INDEX
+
+# Install setuptools, and fetch a recent version pip to be installed later on
+RUN pip3 install --disable-pip-version-check setuptools==$SETUPTOOLS_VERSION && \
+ mkdir $LOCAL_PYPI_INDEX && \
+ wget -q -O $LOCAL_PYPI_INDEX/pip-$VERSION_OF_PIP.tar.gz https://files.pythonhosted.org/packages/93/ab/f86b61bef7ab14909bd7ec3cd2178feb0a1c86d451bc9bccd5a1aedcde5f/pip-$VERSION_OF_PIP.tar.gz
+
+# Version of Python, defaults to Python 2.7
+ARG LM_PYTHON_VERSION
+ENV LM_PYTHON_VERSION ${LM_PYTHON_VERSION:-2.7}
+
COPY test /test
COPY run.sh html2json.js /
diff --git a/run.sh b/run.sh
index 8270381..7adf439 100755
--- a/run.sh
+++ b/run.sh
@@ -65,6 +65,26 @@ if [ "$COMMAND" = "test" -a $# -ne 2 ] ; then
exit 1
fi
+# Switch to Python 3 if requesting
+case "$LM_PYTHON_VERSION" in
+ "2"|"2.7")
+ echo "using python $LM_PYTHON_VERSION"
+ pip --version
+ ;;
+
+ "3"|"3.5")
+ echo "switching to python $LM_PYTHON_VERSION"
+ pip3 install --upgrade --no-index -f "file://$LOCAL_PYPI_INDEX" "pip==$VERSION_OF_PIP"
+ update-alternatives --install /usr/bin/python python /usr/bin/python3.5 1
+ pip --version
+ ;;
+
+ *)
+ echo "python version not supported: $LM_PYTHON_VERSION" >&2
+ exit 1
+ ;;
+esac
+
# Run command
case "$COMMAND" in
test)