From 38bc58856e496076940efee9ca773a74c878d67a Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 15 Mar 2022 13:03:44 +0000 Subject: [PATCH 01/14] Move CI to GitHub Actions --- .github/workflows/ci.yml | 18 ++++++++++++++++++ .travis.yml | 11 ----------- 2 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..ede1d85f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,18 @@ +name: CI + +on: + pull_request: + push: + +concurrency: + group: ${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: docker pull jmadler/python-future-builder:latest + - run: ./build.sh + - run: ./lint.sh \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3fe6a983..00000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: generic - -services: - - docker - -before_script: - - docker pull jmadler/python-future-builder:latest - -script: - - ./build.sh - - ./lint.sh From c3f7a8165bdcd6ff853d35e8ca56d42f8d6b36c1 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 15 Mar 2022 13:35:49 +0000 Subject: [PATCH 02/14] Update build badge --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 1ab43e53..cce7605c 100644 --- a/README.rst +++ b/README.rst @@ -3,8 +3,8 @@ Overview: Easy, clean, reliable Python 2/3 compatibility ======================================================== -.. image:: https://travis-ci.org/PythonCharmers/python-future.svg?branch=master - :target: https://travis-ci.org/PythonCharmers/python-future +.. image:: https://github.com/PythonCharmers/python-future/actions/workflows/ci.yml/badge.svg?branch=master + :target: https://github.com/PythonCharmers/python-future/actions/workflows/ci.yml?query=branch%3Amaster .. image:: https://readthedocs.org/projects/python-future/badge/?version=latest :target: https://python-future.readthedocs.io/en/latest/?badge=latest From fa19c715052f58200fd701b8f756ffa055ec2f36 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 15 Mar 2022 17:07:33 +0000 Subject: [PATCH 03/14] Configure a basic build matrix using the Docker image --- .github/workflows/ci.yml | 29 ++++++++++++++++-- Dockerfile | 65 +++++++++++++++++++++------------------- setup.sh | 2 +- 3 files changed, 61 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ede1d85f..96e2c67d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,9 +10,32 @@ concurrency: jobs: test: + strategy: + fail-fast: false + matrix: + versions: + - debian: 9 + python: 2.6.9 + virtalenv: 15.2.0 + pytag: py26 + - debian: 9 + python: 3.7.7 + virtalenv: 20.0.21 + pytag: py37 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - run: docker pull jmadler/python-future-builder:latest - - run: ./build.sh - - run: ./lint.sh \ No newline at end of file + - run: | + docker build \ + . \ + --build-arg DEBIAN_VERSION=${{ matrix.versions.debian }} \ + --build-arg PYTHON_VERSION=${{ matrix.versions.python }} \ + --build-arg VIRTUALENV_VERSION=${{ matrix.versions.virtalenv }} \ + -t jmadler/python-future-builder:debian-${{ matrix.versions.debian }}-${{ matrix.versions.python }} + - run: | + docker run \ + -it \ + -v $(realpath dist):/root/python-future/dist \ + jmadler/python-future-builder:debian-${{ matrix.versions.debian }}-${{ matrix.versions.python }} + /root/python-future/setup.sh 0.18.2 ${{ matrix.versions.pytag }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 6b94c0a8..e2e5b8ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,39 +1,42 @@ -FROM debian:9 -# This docker image has a copy of a wide array of Pythons installed -RUN apt-get update -RUN apt-get install --yes --no-install-recommends make build-essential zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libffi-dev liblzma-dev libssl1.0-dev -RUN apt-get install --yes git vim -RUN apt-get install --yes python3-pip +ARG DEBIAN_VERSION +ARG PYTHON_VERSION +# Note: venv 15.2.0 is the last to support Python 2.6. +ARG VIRTUALENV_VERSION + +FROM debian:${DEBIAN_VERSION} + +RUN apt-get update && \ + apt-get install --yes --no-install-recommends \ + make \ + build-essential \ + zlib1g-dev \ + libbz2-dev \ + libreadline-dev \ + libsqlite3-dev \ + wget \ + curl \ + llvm \ + libncurses5-dev \ + xz-utils \ + tk-dev \ + libxml2-dev \ + libffi-dev \ + liblzma-dev \ + libssl1.0-dev && \ + apt-get install --yes git vim && \ + apt-get install --yes python3-pip + ENV PYENV_ROOT=/opt/pyenv RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash RUN echo export PATH="/opt/pyenv/bin:$PATH" >> ~/.bashrc RUN echo 'eval "$(pyenv init -)"' >> ~/.bashrc RUN echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc -# venv 15.2.0 is the last to support Python 2.6. -RUN pip3 install virtualenv==15.2.0 -RUN PATH=/opt/pyenv/bin:$PATH pyenv install 2.6.9 -RUN virtualenv /root/py26 --python /opt/pyenv/versions/2.6.9/bin/python -RUN PATH=/opt/pyenv/bin:$PATH pyenv install 3.3.7 -RUN virtualenv /root/py33 --python /opt/pyenv/versions/3.3.7/bin/python -RUN pip3 install virtualenv==20.0.21 -RUN PATH=/opt/pyenv/bin:$PATH pyenv install 3.4.10 -RUN virtualenv /root/py34 --python /opt/pyenv/versions/3.4.10/bin/python -RUN apt-get install --yes libssl-dev libxmlsec1-dev -RUN PATH=/opt/pyenv/bin:$PATH pyenv install 2.7.18 -RUN virtualenv /root/py27 --python /opt/pyenv/versions/2.7.18/bin/python -RUN PATH=/opt/pyenv/bin:$PATH pyenv install 3.5.9 -RUN virtualenv /root/py35 --python /opt/pyenv/versions/3.5.9/bin/python -RUN PATH=/opt/pyenv/bin:$PATH pyenv install 3.6.10 -RUN virtualenv /root/py36 --python /opt/pyenv/versions/3.6.10/bin/python -RUN PATH=/opt/pyenv/bin:$PATH pyenv install 3.7.7 -RUN virtualenv /root/py37 --python /opt/pyenv/versions/3.7.7/bin/python -RUN PATH=/opt/pyenv/bin:$PATH pyenv install 3.8.3 -RUN virtualenv /root/py38 --python /opt/pyenv/versions/3.8.3/bin/python -RUN PATH=/opt/pyenv/bin:$PATH pyenv install 3.9.0 -RUN virtualenv /root/py39 --python /opt/pyenv/versions/3.9.0/bin/python -# Lint tools -RUN pip3 install flake8 -RUN ln -s /usr/bin/python3 /usr/bin/python + +RUN pip3 install virtualenv==${VIRTUALENV_VERSION} + +RUN PATH=/opt/pyenv/bin:$PATH pyenv install ${PYTHON_VERSION} +RUN virtualenv /root/venv --python /opt/pyenv/versions/${PYTHON_VERSION}/bin/python + ENV LC_ALL=C.UTF-8 ENV LANG=C.UTF-8 WORKDIR /root/python-future diff --git a/setup.sh b/setup.sh index 8e8dc150..ed4b0dad 100755 --- a/setup.sh +++ b/setup.sh @@ -9,7 +9,7 @@ if [ $pytag = 'py33' ]; then pip3 install virtualenv==16.2.0 fi -source /root/$pytag/bin/activate +source /root/venv/bin/activate if [ $pytag = 'py26' ]; then pip install importlib From 04991b26e1a33f3770c4fd53325d854ce648bdcf Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 15 Mar 2022 17:12:57 +0000 Subject: [PATCH 04/14] Fix missing virtual env version --- .github/workflows/ci.yml | 7 ++++--- Dockerfile | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 96e2c67d..d0a15962 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,11 +16,12 @@ jobs: versions: - debian: 9 python: 2.6.9 - virtalenv: 15.2.0 + # Note: virtualenv 15.2.0 is the last to support Python 2.6. + virtualenv: 15.2.0 pytag: py26 - debian: 9 python: 3.7.7 - virtalenv: 20.0.21 + virtualenv: 20.0.21 pytag: py37 runs-on: ubuntu-latest @@ -31,7 +32,7 @@ jobs: . \ --build-arg DEBIAN_VERSION=${{ matrix.versions.debian }} \ --build-arg PYTHON_VERSION=${{ matrix.versions.python }} \ - --build-arg VIRTUALENV_VERSION=${{ matrix.versions.virtalenv }} \ + --build-arg VIRTUALENV_VERSION=${{ matrix.versions.virtualenv }} \ -t jmadler/python-future-builder:debian-${{ matrix.versions.debian }}-${{ matrix.versions.python }} - run: | docker run \ diff --git a/Dockerfile b/Dockerfile index e2e5b8ac..c243cf5b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ ARG DEBIAN_VERSION ARG PYTHON_VERSION -# Note: venv 15.2.0 is the last to support Python 2.6. ARG VIRTUALENV_VERSION FROM debian:${DEBIAN_VERSION} @@ -32,6 +31,7 @@ RUN echo export PATH="/opt/pyenv/bin:$PATH" >> ~/.bashrc RUN echo 'eval "$(pyenv init -)"' >> ~/.bashrc RUN echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc +ENV VIRTUALENV_VERSION $VIRTUALENV_VERSION RUN pip3 install virtualenv==${VIRTUALENV_VERSION} RUN PATH=/opt/pyenv/bin:$PATH pyenv install ${PYTHON_VERSION} From 7dc0a0a0272e4b1e2fea15b04e4203bd584b6d5c Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 15 Mar 2022 17:29:44 +0000 Subject: [PATCH 05/14] Move Docker build arguments closer to their use --- Dockerfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index c243cf5b..9ea150fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,4 @@ ARG DEBIAN_VERSION -ARG PYTHON_VERSION -ARG VIRTUALENV_VERSION - FROM debian:${DEBIAN_VERSION} RUN apt-get update && \ @@ -31,9 +28,10 @@ RUN echo export PATH="/opt/pyenv/bin:$PATH" >> ~/.bashrc RUN echo 'eval "$(pyenv init -)"' >> ~/.bashrc RUN echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc -ENV VIRTUALENV_VERSION $VIRTUALENV_VERSION +ARG VIRTUALENV_VERSION RUN pip3 install virtualenv==${VIRTUALENV_VERSION} +ARG PYTHON_VERSION RUN PATH=/opt/pyenv/bin:$PATH pyenv install ${PYTHON_VERSION} RUN virtualenv /root/venv --python /opt/pyenv/versions/${PYTHON_VERSION}/bin/python From c95330b2dac47572dbf39f5b54686fad049e3a77 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Fri, 18 Mar 2022 16:18:28 +0000 Subject: [PATCH 06/14] Split CI across multiple jobs --- .github/workflows/ci.yml | 27 ++++++++++++--------------- Dockerfile | 14 ++++++++++---- build.sh | 17 ----------------- lint.sh | 3 --- setup.sh | 20 -------------------- test.sh | 14 ++++++++++++++ 6 files changed, 36 insertions(+), 59 deletions(-) delete mode 100755 build.sh delete mode 100755 lint.sh delete mode 100755 setup.sh create mode 100755 test.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0a15962..c28ad982 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,15 +14,15 @@ jobs: fail-fast: false matrix: versions: - - debian: 9 - python: 2.6.9 - # Note: virtualenv 15.2.0 is the last to support Python 2.6. - virtualenv: 15.2.0 - pytag: py26 - - debian: 9 - python: 3.7.7 - virtualenv: 20.0.21 - pytag: py37 + - python: 2.6.9 + - python: 2.7.18 + - python: 3.3.7 + - python: 3.4.10 + - python: 3.5.9 + - python: 3.6.10 + - python: 3.7.7 + - python: 3.8.3 + - python: 3.9.0 runs-on: ubuntu-latest steps: @@ -30,13 +30,10 @@ jobs: - run: | docker build \ . \ - --build-arg DEBIAN_VERSION=${{ matrix.versions.debian }} \ --build-arg PYTHON_VERSION=${{ matrix.versions.python }} \ - --build-arg VIRTUALENV_VERSION=${{ matrix.versions.virtualenv }} \ - -t jmadler/python-future-builder:debian-${{ matrix.versions.debian }}-${{ matrix.versions.python }} + -t jmadler/python-future-builder:debian-9-${{ matrix.versions.python }} - run: | docker run \ - -it \ -v $(realpath dist):/root/python-future/dist \ - jmadler/python-future-builder:debian-${{ matrix.versions.debian }}-${{ matrix.versions.python }} - /root/python-future/setup.sh 0.18.2 ${{ matrix.versions.pytag }} \ No newline at end of file + jmadler/python-future-builder:debian-9-${{ matrix.versions.python }} + /root/python-future/test.sh \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 9ea150fc..b1e7cc60 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG DEBIAN_VERSION +ARG DEBIAN_VERSION=9 FROM debian:${DEBIAN_VERSION} RUN apt-get update && \ @@ -28,14 +28,20 @@ RUN echo export PATH="/opt/pyenv/bin:$PATH" >> ~/.bashrc RUN echo 'eval "$(pyenv init -)"' >> ~/.bashrc RUN echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc -ARG VIRTUALENV_VERSION -RUN pip3 install virtualenv==${VIRTUALENV_VERSION} - ARG PYTHON_VERSION + +# virtualenv 15.2.0 is the last to support Python 2.6. +RUN if [[ "$PYTHON_VERSION" == "2.6.9" || "$PYTHON_VERSION" == "3.3.7" ]] ; \ + then export VIRTUALENV_VERSION=15.2.0 ; \ + else export VIRTUALENV_VERSION=20.0.21 ; \ + fi ; \ + pip3 install virtualenv==${VIRTUALENV_VERSION} + RUN PATH=/opt/pyenv/bin:$PATH pyenv install ${PYTHON_VERSION} RUN virtualenv /root/venv --python /opt/pyenv/versions/${PYTHON_VERSION}/bin/python ENV LC_ALL=C.UTF-8 ENV LANG=C.UTF-8 + WORKDIR /root/python-future ADD . /root/python-future diff --git a/build.sh b/build.sh deleted file mode 100755 index d17fa7ce..00000000 --- a/build.sh +++ /dev/null @@ -1,17 +0,0 @@ -# XXX: TODO: we should make this include -e once tests pass -set -xuo pipefail - -DOCKER_IMAGE=jmadler/python-future-builder -# XXX: TODO: Perhaps this version shouldn't be hardcoded -version=0.18.2 - -docker build . -t $DOCKER_IMAGE -docker push $DOCKER_IMAGE:latest - -for i in py26 py27 py33 py34 py35 py36 py37 py38 py39; do - docker run -ti -v $(realpath dist):/root/python-future/dist $DOCKER_IMAGE /root/python-future/setup.sh $version $(basename $i) -done - -python setup.py sdist -python setup.py clean -echo You may now run: "twine upload dist/*" diff --git a/lint.sh b/lint.sh deleted file mode 100755 index 667b258f..00000000 --- a/lint.sh +++ /dev/null @@ -1,3 +0,0 @@ -# TODO: Run under Python 2.7 and 3.7 -flake8 . --count --exit-zero --select=E901,E999,F821,F822,F823 --show-source --statistics || true -flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics || true diff --git a/setup.sh b/setup.sh deleted file mode 100755 index ed4b0dad..00000000 --- a/setup.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -set -exo pipefail - -version=$1 -pytag=$2 - -if [ $pytag = 'py33' ]; then - pip3 install virtualenv==16.2.0 -fi - -source /root/venv/bin/activate - -if [ $pytag = 'py26' ]; then - pip install importlib -fi -pip install pytest unittest2 -python setup.py bdist_wheel --python-tag=$pytag -pip install dist/future-$version-$pytag-none-any.whl -pytest tests/ diff --git a/test.sh b/test.sh new file mode 100755 index 00000000..3603f7fe --- /dev/null +++ b/test.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -exo pipefail + +source /root/venv/bin/activate + +if [ $pytag = 'py26' ]; then + pip install importlib +fi +pip install pytest unittest2 + +python setup.py bdist_wheel +pip install dist/future-*-none-any.whl +pytest tests/ From 9954b446bb8d56783cd1dd829014abf246466227 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Fri, 18 Mar 2022 16:30:56 +0000 Subject: [PATCH 07/14] Fix syntax --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c28ad982..17d67488 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,5 +35,5 @@ jobs: - run: | docker run \ -v $(realpath dist):/root/python-future/dist \ - jmadler/python-future-builder:debian-9-${{ matrix.versions.python }} + jmadler/python-future-builder:debian-9-${{ matrix.versions.python }} \ /root/python-future/test.sh \ No newline at end of file From 5a2d8e245d690914b540afdf4eaed873a9e800c6 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Fri, 18 Mar 2022 17:38:57 +0000 Subject: [PATCH 08/14] Split builds between Python 2.6 vs other versions --- .github/workflows/ci.yml | 32 +++++++++------ 2.6.Dockerfile | 86 ++++++++++++++++++++++++++++++++++++++++ Dockerfile | 42 +------------------- test.sh | 5 --- 4 files changed, 106 insertions(+), 59 deletions(-) create mode 100644 2.6.Dockerfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 17d67488..578033ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,26 +14,32 @@ jobs: fail-fast: false matrix: versions: - - python: 2.6.9 - - python: 2.7.18 - - python: 3.3.7 - - python: 3.4.10 - - python: 3.5.9 - - python: 3.6.10 - - python: 3.7.7 - - python: 3.8.3 - - python: 3.9.0 + - python: "2.6" + - python: "2.7" + - python: "3.3" + - python: "3.4" + - python: "3.5" + - python: "3.6" + - python: "3.7" + - python: "3.8" + - python: "3.9" runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - run: | + - if: ${{ matrix.versions.python != '2.6' }} + run: | docker build \ . \ --build-arg PYTHON_VERSION=${{ matrix.versions.python }} \ - -t jmadler/python-future-builder:debian-9-${{ matrix.versions.python }} + -t jmadler/python-future-builder:${{ matrix.versions.python }} + - if: ${{ matrix.versions.python == '2.6' }} + run: | + docker build \ + . \ + -f 2.6.Dockerfile \ + -t jmadler/python-future-builder:${{ matrix.versions.python }} - run: | docker run \ - -v $(realpath dist):/root/python-future/dist \ - jmadler/python-future-builder:debian-9-${{ matrix.versions.python }} \ + jmadler/python-future-builder:${{ matrix.versions.python }} \ /root/python-future/test.sh \ No newline at end of file diff --git a/2.6.Dockerfile b/2.6.Dockerfile new file mode 100644 index 00000000..60362e81 --- /dev/null +++ b/2.6.Dockerfile @@ -0,0 +1,86 @@ +# +# Image forked from the offical Python 2.7 image +# + +FROM buildpack-deps:stretch + +# ensure local python is preferred over distribution python +ENV PATH /usr/local/bin:$PATH + +# http://bugs.python.org/issue19846 +# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. +ENV LANG C.UTF-8 +# https://github.com/docker-library/python/issues/147 +ENV PYTHONIOENCODING UTF-8 + +# extra dependencies (over what buildpack-deps already includes) +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + tk-dev \ + zlib1g-dev \ + && rm -rf /var/lib/apt/lists/* \ + && export LDFLAGS="${LDFLAGS} -L/usr/local/opt/zlib/lib" \ + && export CPPFLAGS="${CPPFLAGS} -I/usr/local/opt/zlib/include" \ + && export PKG_CONFIG_PATH="${PKG_CONFIG_PATH} /usr/local/opt/zlib/lib/pkgconfig" + +ENV PYTHON_VERSION 2.6.9 + +RUN set -ex \ + \ + && wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \ + && mkdir -p /usr/src/python \ + && tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \ + && rm python.tar.xz \ + \ + && cd /usr/src/python \ + && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ + && ./configure \ + --build="$gnuArch" \ + --enable-shared \ + --enable-unicode=ucs4 \ + --with-zlib-dir=/usr/local/lib \ + && make -j "$(nproc)" \ + && make install \ + && ldconfig \ + \ + && find /usr/local -depth \ + \( \ + \( -type d -a \( -name test -o -name tests \) \) \ + -o \ + \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ + \) -exec rm -rf '{}' + \ + && rm -rf /usr/src/python \ + \ + && python2 --version + +# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value ''" +ENV PYTHON_PIP_VERSION 10.0.1 + +RUN set -ex; \ + \ + wget -O get-pip.py 'https://bootstrap.pypa.io/pip/2.6/get-pip.py'; \ + \ + python get-pip.py \ + --disable-pip-version-check \ + --no-cache-dir \ + "pip==$PYTHON_PIP_VERSION" \ + ; \ + pip --version; \ + \ + find /usr/local -depth \ + \( \ + \( -type d -a \( -name test -o -name tests \) \) \ + -o \ + \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ + \) -exec rm -rf '{}' +; \ + rm -f get-pip.py + +# install "virtualenv", since the vast majority of users of this image will want it +RUN pip install --no-cache-dir virtualenv + +## END official Docker image, below is our stuff + +RUN pip install importlib + +WORKDIR /root/python-future +ADD . /root/python-future \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index b1e7cc60..c859757f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,47 +1,7 @@ -ARG DEBIAN_VERSION=9 -FROM debian:${DEBIAN_VERSION} - -RUN apt-get update && \ - apt-get install --yes --no-install-recommends \ - make \ - build-essential \ - zlib1g-dev \ - libbz2-dev \ - libreadline-dev \ - libsqlite3-dev \ - wget \ - curl \ - llvm \ - libncurses5-dev \ - xz-utils \ - tk-dev \ - libxml2-dev \ - libffi-dev \ - liblzma-dev \ - libssl1.0-dev && \ - apt-get install --yes git vim && \ - apt-get install --yes python3-pip - -ENV PYENV_ROOT=/opt/pyenv -RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash -RUN echo export PATH="/opt/pyenv/bin:$PATH" >> ~/.bashrc -RUN echo 'eval "$(pyenv init -)"' >> ~/.bashrc -RUN echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc - ARG PYTHON_VERSION - -# virtualenv 15.2.0 is the last to support Python 2.6. -RUN if [[ "$PYTHON_VERSION" == "2.6.9" || "$PYTHON_VERSION" == "3.3.7" ]] ; \ - then export VIRTUALENV_VERSION=15.2.0 ; \ - else export VIRTUALENV_VERSION=20.0.21 ; \ - fi ; \ - pip3 install virtualenv==${VIRTUALENV_VERSION} - -RUN PATH=/opt/pyenv/bin:$PATH pyenv install ${PYTHON_VERSION} -RUN virtualenv /root/venv --python /opt/pyenv/versions/${PYTHON_VERSION}/bin/python +FROM python:${PYTHON_VERSION}-slim ENV LC_ALL=C.UTF-8 -ENV LANG=C.UTF-8 WORKDIR /root/python-future ADD . /root/python-future diff --git a/test.sh b/test.sh index 3603f7fe..1af0beb0 100755 --- a/test.sh +++ b/test.sh @@ -2,11 +2,6 @@ set -exo pipefail -source /root/venv/bin/activate - -if [ $pytag = 'py26' ]; then - pip install importlib -fi pip install pytest unittest2 python setup.py bdist_wheel From 741f38397e6ea1d5f9e70335e8dd24304ed06c5c Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Fri, 18 Mar 2022 18:04:32 +0000 Subject: [PATCH 09/14] Fix 'zlib not available' error --- 2.6.Dockerfile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/2.6.Dockerfile b/2.6.Dockerfile index 60362e81..ba380b0f 100644 --- a/2.6.Dockerfile +++ b/2.6.Dockerfile @@ -18,10 +18,7 @@ RUN apt-get update \ && apt-get install -y --no-install-recommends \ tk-dev \ zlib1g-dev \ - && rm -rf /var/lib/apt/lists/* \ - && export LDFLAGS="${LDFLAGS} -L/usr/local/opt/zlib/lib" \ - && export CPPFLAGS="${CPPFLAGS} -I/usr/local/opt/zlib/include" \ - && export PKG_CONFIG_PATH="${PKG_CONFIG_PATH} /usr/local/opt/zlib/lib/pkgconfig" + && rm -rf /var/lib/apt/lists/* ENV PYTHON_VERSION 2.6.9 @@ -33,12 +30,14 @@ RUN set -ex \ && rm python.tar.xz \ \ && cd /usr/src/python \ + && export LDFLAGS="${LDFLAGS} -L/usr/lib/x86_64-linux-gnu" \ + && export CPPFLAGS="${CPPFLAGS} -I/usr/include" \ + && export PKG_CONFIG_PATH="${PKG_CONFIG_PATH} /usr/lib/x86_64-linux-gnu/pkgconfig" \ && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ && ./configure \ --build="$gnuArch" \ --enable-shared \ --enable-unicode=ucs4 \ - --with-zlib-dir=/usr/local/lib \ && make -j "$(nproc)" \ && make install \ && ldconfig \ From 9b490433bfdd012673d490b796937efb1bea2393 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 21 Mar 2022 12:35:51 +0000 Subject: [PATCH 10/14] Use existing Docker image to get a working version of Python 2.6 --- .github/workflows/ci.yml | 1 + 2.6.Dockerfile | 102 ++++++++------------------------------- test.sh | 20 ++++++-- 3 files changed, 38 insertions(+), 85 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 578033ac..fb7f5064 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,5 +41,6 @@ jobs: -t jmadler/python-future-builder:${{ matrix.versions.python }} - run: | docker run \ + -e PYTHON_VERSION=${{ matrix.versions.python }} \ jmadler/python-future-builder:${{ matrix.versions.python }} \ /root/python-future/test.sh \ No newline at end of file diff --git a/2.6.Dockerfile b/2.6.Dockerfile index ba380b0f..a783f4f8 100644 --- a/2.6.Dockerfile +++ b/2.6.Dockerfile @@ -1,85 +1,23 @@ -# -# Image forked from the offical Python 2.7 image -# - -FROM buildpack-deps:stretch - -# ensure local python is preferred over distribution python -ENV PATH /usr/local/bin:$PATH - -# http://bugs.python.org/issue19846 -# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. -ENV LANG C.UTF-8 -# https://github.com/docker-library/python/issues/147 -ENV PYTHONIOENCODING UTF-8 - -# extra dependencies (over what buildpack-deps already includes) -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - tk-dev \ - zlib1g-dev \ - && rm -rf /var/lib/apt/lists/* - -ENV PYTHON_VERSION 2.6.9 - -RUN set -ex \ - \ - && wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \ - && mkdir -p /usr/src/python \ - && tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \ - && rm python.tar.xz \ - \ - && cd /usr/src/python \ - && export LDFLAGS="${LDFLAGS} -L/usr/lib/x86_64-linux-gnu" \ - && export CPPFLAGS="${CPPFLAGS} -I/usr/include" \ - && export PKG_CONFIG_PATH="${PKG_CONFIG_PATH} /usr/lib/x86_64-linux-gnu/pkgconfig" \ - && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ - && ./configure \ - --build="$gnuArch" \ - --enable-shared \ - --enable-unicode=ucs4 \ - && make -j "$(nproc)" \ - && make install \ - && ldconfig \ - \ - && find /usr/local -depth \ - \( \ - \( -type d -a \( -name test -o -name tests \) \) \ - -o \ - \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ - \) -exec rm -rf '{}' + \ - && rm -rf /usr/src/python \ - \ - && python2 --version - -# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value ''" -ENV PYTHON_PIP_VERSION 10.0.1 - -RUN set -ex; \ - \ - wget -O get-pip.py 'https://bootstrap.pypa.io/pip/2.6/get-pip.py'; \ - \ - python get-pip.py \ - --disable-pip-version-check \ - --no-cache-dir \ - "pip==$PYTHON_PIP_VERSION" \ - ; \ - pip --version; \ - \ - find /usr/local -depth \ - \( \ - \( -type d -a \( -name test -o -name tests \) \) \ - -o \ - \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ - \) -exec rm -rf '{}' +; \ - rm -f get-pip.py - -# install "virtualenv", since the vast majority of users of this image will want it -RUN pip install --no-cache-dir virtualenv - -## END official Docker image, below is our stuff - -RUN pip install importlib +FROM jmadler/python-future-builder:latest + +RUN echo 'pyenv global 2.6.9' >> ~/.bashrc + +RUN mkdir -p ~/.pip/ && echo '[global] \n\ +trusted-host = pypi.python.org\n\ + pypi.org\n\ + files.pythonhosted.org\n\ +' >> ~/.pip/pip.conf + +RUN mkdir -p /root/pip && \ + cd /root/pip && \ + curl -O https://files.pythonhosted.org/packages/31/77/3781f65cafe55480b56914def99022a5d2965a4bb269655c89ef2f1de3cd/importlib-1.0.4.zip && \ + curl -O https://files.pythonhosted.org/packages/ef/41/d8a61f1b2ba308e96b36106e95024977e30129355fd12087f23e4b9852a1/pytest-3.2.5-py2.py3-none-any.whl && \ + curl -O https://files.pythonhosted.org/packages/72/20/7f0f433060a962200b7272b8c12ba90ef5b903e218174301d0abfd523813/unittest2-1.1.0-py2.py3-none-any.whl && \ + curl -O https://files.pythonhosted.org/packages/53/67/9620edf7803ab867b175e4fd23c7b8bd8eba11cb761514dcd2e726ef07da/py-1.4.34-py2.py3-none-any.whl && \ + curl -O https://files.pythonhosted.org/packages/53/25/ef88e8e45db141faa9598fbf7ad0062df8f50f881a36ed6a0073e1572126/ordereddict-1.1.tar.gz && \ + curl -O https://files.pythonhosted.org/packages/17/0a/6ac05a3723017a967193456a2efa0aa9ac4b51456891af1e2353bb9de21e/traceback2-1.4.0-py2.py3-none-any.whl && \ + curl -O https://files.pythonhosted.org/packages/65/26/32b8464df2a97e6dd1b656ed26b2c194606c16fe163c695a992b36c11cdf/six-1.13.0-py2.py3-none-any.whl && \ + curl -O https://files.pythonhosted.org/packages/c7/a3/c5da2a44c85bfbb6eebcfc1dde24933f8704441b98fdde6528f4831757a6/linecache2-1.0.0-py2.py3-none-any.whl WORKDIR /root/python-future ADD . /root/python-future \ No newline at end of file diff --git a/test.sh b/test.sh index 1af0beb0..f686fa29 100755 --- a/test.sh +++ b/test.sh @@ -1,9 +1,23 @@ #!/bin/bash +if [ -e "${HOME}/.bashrc" ] +then + source "${HOME}/.bashrc" +fi + set -exo pipefail -pip install pytest unittest2 +python --version + +if [ -e "/root/pip" ] +then + pip install /root/pip/*.zip /root/pip/*.whl /root/pip/*tar.gz +else + pip install pytest unittest2 +fi + +pytag="py${PYTHON_VERSION//./}" -python setup.py bdist_wheel -pip install dist/future-*-none-any.whl +python setup.py bdist_wheel --python-tag="${pytag}" +pip install dist/future-*-${pytag}-none-any.whl pytest tests/ From c7b5b47968bb6080508f9333a8f772d1e562c714 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 21 Mar 2022 19:21:51 +0000 Subject: [PATCH 11/14] Use a lighter Docker image for 2.6 --- 2.6.Dockerfile | 9 ++++++--- test.sh | 5 ----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/2.6.Dockerfile b/2.6.Dockerfile index a783f4f8..efaf3809 100644 --- a/2.6.Dockerfile +++ b/2.6.Dockerfile @@ -1,6 +1,4 @@ -FROM jmadler/python-future-builder:latest - -RUN echo 'pyenv global 2.6.9' >> ~/.bashrc +FROM mrupgrade/deadsnakes:2.6 RUN mkdir -p ~/.pip/ && echo '[global] \n\ trusted-host = pypi.python.org\n\ @@ -8,10 +6,15 @@ trusted-host = pypi.python.org\n\ files.pythonhosted.org\n\ ' >> ~/.pip/pip.conf +RUN apt-get update && \ + apt-get install -y curl + RUN mkdir -p /root/pip && \ cd /root/pip && \ + curl -O https://files.pythonhosted.org/packages/8a/e9/8468cd68b582b06ef554be0b96b59f59779627131aad48f8a5bce4b13450/wheel-0.29.0-py2.py3-none-any.whl && \ curl -O https://files.pythonhosted.org/packages/31/77/3781f65cafe55480b56914def99022a5d2965a4bb269655c89ef2f1de3cd/importlib-1.0.4.zip && \ curl -O https://files.pythonhosted.org/packages/ef/41/d8a61f1b2ba308e96b36106e95024977e30129355fd12087f23e4b9852a1/pytest-3.2.5-py2.py3-none-any.whl && \ + curl -O https://files.pythonhosted.org/packages/f2/94/3af39d34be01a24a6e65433d19e107099374224905f1e0cc6bbe1fd22a2f/argparse-1.4.0-py2.py3-none-any.whl && \ curl -O https://files.pythonhosted.org/packages/72/20/7f0f433060a962200b7272b8c12ba90ef5b903e218174301d0abfd523813/unittest2-1.1.0-py2.py3-none-any.whl && \ curl -O https://files.pythonhosted.org/packages/53/67/9620edf7803ab867b175e4fd23c7b8bd8eba11cb761514dcd2e726ef07da/py-1.4.34-py2.py3-none-any.whl && \ curl -O https://files.pythonhosted.org/packages/53/25/ef88e8e45db141faa9598fbf7ad0062df8f50f881a36ed6a0073e1572126/ordereddict-1.1.tar.gz && \ diff --git a/test.sh b/test.sh index f686fa29..d45e98d3 100755 --- a/test.sh +++ b/test.sh @@ -1,10 +1,5 @@ #!/bin/bash -if [ -e "${HOME}/.bashrc" ] -then - source "${HOME}/.bashrc" -fi - set -exo pipefail python --version From 6e580cb73a3de83b3ba2e760ae72742d1870eeb3 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 21 Mar 2023 15:12:26 +0000 Subject: [PATCH 12/14] Update test_pow --- tests/test_future/test_builtins.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/test_future/test_builtins.py b/tests/test_future/test_builtins.py index 3921a608..a24c9505 100644 --- a/tests/test_future/test_builtins.py +++ b/tests/test_future/test_builtins.py @@ -1303,8 +1303,15 @@ def test_pow(self): self.assertAlmostEqual(pow(-1, 0.5), 1j) self.assertAlmostEqual(pow(-1, 1/3), 0.5 + 0.8660254037844386j) - # Raises TypeError in Python < v3.5, ValueError in v3.5: - self.assertRaises((TypeError, ValueError), pow, -1, -2, 3) + if sys.version_info < (3, 8): + # Raises TypeError in Python < v3.5, ValueError in v3.5: + self.assertRaises((TypeError, ValueError), pow, -1, -2, 3) + else: + # Changed in version 3.8: For int operands, the three-argument form + # of pow now allows the second argument to be negative, permitting + # computation of modular inverses. + self.assertEqual(pow(-1, -2, 3), 1) + self.assertRaises(ValueError, pow, 1, 2, 0) self.assertRaises(TypeError, pow) From 1d50290ca306a3539089a8e7cd8fd0a9f6a508a0 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 21 Mar 2023 15:16:42 +0000 Subject: [PATCH 13/14] Update test_ftp --- tests/test_future/test_urllib2.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/test_future/test_urllib2.py b/tests/test_future/test_urllib2.py index 2d69dad1..87bc585a 100644 --- a/tests/test_future/test_urllib2.py +++ b/tests/test_future/test_urllib2.py @@ -691,10 +691,6 @@ def connect_ftp(self, user, passwd, host, port, dirs, h = NullFTPHandler(data) h.parent = MockOpener() - # MIME guessing works in Python 3.8! - guessed_mime = None - if sys.hexversion >= 0x03080000: - guessed_mime = "image/gif" for url, host, port, user, passwd, type_, dirs, filename, mimetype in [ ("ftp://localhost/foo/bar/baz.html", "localhost", ftplib.FTP_PORT, "", "", "I", @@ -713,7 +709,7 @@ def connect_ftp(self, user, passwd, host, port, dirs, ["foo", "bar"], "", None), ("ftp://localhost/baz.gif;type=a", "localhost", ftplib.FTP_PORT, "", "", "A", - [], "baz.gif", guessed_mime), + [], "baz.gif", None), ]: req = Request(url) req.timeout = None From efb02b9a3e26581243c81f20cea4f3c0eb468395 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 21 Mar 2023 15:35:36 +0000 Subject: [PATCH 14/14] Make _dummy_thread move work in Python 3.9 --- src/future/moves/_dummy_thread.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/future/moves/_dummy_thread.py b/src/future/moves/_dummy_thread.py index 688d249b..42ae5848 100644 --- a/src/future/moves/_dummy_thread.py +++ b/src/future/moves/_dummy_thread.py @@ -1,7 +1,11 @@ from __future__ import absolute_import -from future.utils import PY3 +from future.utils import PY3, PY39_PLUS -if PY3: +if PY39_PLUS: + # _dummy_thread and dummy_threading modules + # have both been removed in Python 3.9 + from _thread import * +elif PY3: from _dummy_thread import * else: __future_module__ = True