Skip to content

Commit 7e2d389

Browse files
authored
[1.26] Fix running CPython 2.7 tests in CI (#3137)
1 parent 9c2c230 commit 7e2d389

4 files changed

Lines changed: 17 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,12 @@ jobs:
2929
strategy:
3030
fail-fast: false
3131
matrix:
32-
python-version: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10"]
32+
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
3333
os: [macos-11, windows-latest, ubuntu-latest]
3434
experimental: [false]
3535
nox-session: ['']
3636
exclude:
37-
# GitHub Actions dropped support for Python 2.7 and 3.7 in Ubuntu 22.04
38-
- python-version: "2.7"
39-
os: ubuntu-latest
37+
# actions/setup-python dropped support for 3.6 in Ubuntu 22.04
4038
- python-version: "3.6"
4139
os: ubuntu-latest
4240
# Python 3.7 does not fully support OpenSSL 3, the default on Ubuntu 22.04
@@ -45,7 +43,7 @@ jobs:
4543
os: ubuntu-latest
4644
include:
4745
- python-version: "2.7"
48-
os: ubuntu-20.04
46+
os: ubuntu-latest
4947
experimental: false
5048
nox-session: ''
5149
- python-version: "3.6"
@@ -89,10 +87,20 @@ jobs:
8987
uses: actions/checkout@v2
9088

9189
- name: Set Up Python - ${{ matrix.python-version }}
90+
if: matrix.python-version != '2.7'
9291
uses: actions/setup-python@v4
9392
with:
9493
python-version: ${{ matrix.python-version }}
9594

95+
# Unfortunately, actions/setup-python does not support CPython 2.7.
96+
- name: Set Up Python - 2.7
97+
if: matrix.python-version == '2.7'
98+
run: |
99+
sudo apt update
100+
sudo apt install python2.7-dev python-is-python3
101+
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
102+
sudo python2.7 get-pip.py
103+
96104
- name: Set Up Python 3 to run nox
97105
if: matrix.python-version == '2.7' || matrix.python-version == 'pypy2.7'
98106
uses: actions/setup-python@v4

ci/run_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
if [[ "${NOX_SESSION}" == "app_engine" ]]; then
55
export GAE_SDK_PATH=$HOME/.cache/google_appengine
6-
python2 -m pip install gcp-devrel-py-tools==0.0.16
6+
python2.7 -m pip install gcp-devrel-py-tools==0.0.16
77
gcp-devrel-py-tools download-appengine-sdk "$(dirname ${GAE_SDK_PATH})"
88
fi
99

noxfile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def google_brotli(session):
5555
# https://pypi.org/project/Brotli/ is the Google version of brotli, so
5656
# install it separately and don't install our brotli extra (which installs
5757
# brotlipy).
58-
session.install("brotli")
58+
# https://github.com/google/brotli/issues/1074
59+
session.install("brotli==1.0.9" if session.python == "2.7" else "brotli")
5960
tests_impl(session, extras="socks,secure")
6061

6162

src/urllib3/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def connect(self):
437437
and self.ssl_version is None
438438
and hasattr(self.sock, "version")
439439
and self.sock.version() in {"TLSv1", "TLSv1.1"}
440-
):
440+
): # Defensive:
441441
warnings.warn(
442442
"Negotiating TLSv1/TLSv1.1 by default is deprecated "
443443
"and will be disabled in urllib3 v2.0.0. Connecting to "

0 commit comments

Comments
 (0)