Skip to content

Commit c2c9aef

Browse files
authoredNov 14, 2020
Fix GitHub Actions to run under pypy2 (pypa#351)
1 parent c4e1074 commit c2c9aef

File tree

4 files changed

+58
-52
lines changed

4 files changed

+58
-52
lines changed
 

‎.github/workflows/test.yml

+46-37
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ name: Test
33
on:
44
pull_request:
55
paths:
6-
- '.github/workflows/test.yml'
7-
- '**.py'
6+
- ".github/workflows/test.yml"
7+
- "**.py"
88
push:
99
paths:
10-
- '.github/workflows/test.yml'
11-
- '**.py'
10+
- ".github/workflows/test.yml"
11+
- "**.py"
1212

1313
jobs:
1414
test:
@@ -19,48 +19,57 @@ jobs:
1919
matrix:
2020
os: [Ubuntu, Windows, macOS]
2121
# Python 3.4 is not available from actions/setup-python@v2.
22-
python_version: ['2.7', '3.5', '3.6', '3.7', '3.8', '3.9', 'pypy2', 'pypy3']
22+
python_version:
23+
["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "pypy2", "pypy3"]
2324
exclude:
2425
# This is failing due to pip not being in the virtual environment.
2526
# https://github.com/pypa/packaging/runs/424785871#step:7:9
2627
- os: windows
2728
python_version: pypy3
2829

2930
steps:
30-
- uses: actions/checkout@v1
31+
- uses: actions/checkout@v1
3132

32-
- uses: actions/setup-python@v2
33-
name: Install Python ${{ matrix.python_version }}
34-
with:
35-
python-version: ${{ matrix.python_version }}
33+
- uses: actions/setup-python@v2
34+
name: Install Python ${{ matrix.python_version }}
35+
with:
36+
python-version: ${{ matrix.python_version }}
3637

37-
# Set `python` to a recent 3.x version if we're not testing Python 3.6+.
38-
# Why? Nox needs Python 3.5+ and everyone likes f-strings.
39-
- uses: actions/setup-python@v2
40-
name: Install Python 3.x
41-
with:
42-
python-version: 3.x
43-
if: >
44-
(
45-
matrix.python_version == '2.7' ||
46-
matrix.python_version == 'pypy2' ||
47-
matrix.python_version == '3.5'
48-
)
38+
# Set `python` to a recent 3.x version if we're not testing Python 3.6+.
39+
# Why? Nox needs Python 3.5+ and everyone likes f-strings.
40+
- uses: actions/setup-python@v2
41+
name: Install Python 3.x
42+
with:
43+
python-version: 3.x
44+
if: >
45+
(
46+
matrix.python_version == '2.7' ||
47+
matrix.python_version == 'pypy2' ||
48+
matrix.python_version == '3.5'
49+
)
4950
50-
# Workaround https://github.com/theacodes/nox/issues/250
51-
- name: Workaround for Windows Python 2.7
52-
# This is in PATH, so nox resolves to it - but then subsequent steps fail.
53-
run: rm C:/ProgramData/Chocolatey/bin/python2.7.exe
54-
shell: bash
55-
if: runner.os == 'Windows' && matrix.python_version == '2.7'
51+
# Workaround https://github.com/theacodes/nox/issues/250
52+
- name: Workaround for Windows Python 2.7
53+
# This is in PATH, so nox resolves to it - but then subsequent steps fail.
54+
run: rm C:/ProgramData/Chocolatey/bin/python2.7.exe
55+
shell: bash
56+
if: runner.os == 'Windows' && matrix.python_version == '2.7'
5657

57-
- name: Install dependencies
58-
run: |
59-
python -m pip install --upgrade pip
60-
python -m pip install nox
61-
shell: bash
58+
- name: Install dependencies
59+
run: |
60+
python -m pip install --upgrade pip
61+
python -m pip install nox
62+
shell: bash
6263

63-
- name: Run nox
64-
run: |
65-
python -m nox -s tests-${{ matrix.python_version }}
66-
shell: bash
64+
- name: Run nox
65+
run: |
66+
python -m nox --error-on-missing-interpreters -s tests-${{ matrix.python_version }}
67+
shell: bash
68+
if: matrix.python_version != 'pypy2'
69+
70+
# Binary is named 'pypy', but setup-python specifies it as 'pypy2'.
71+
- name: Run nox for pypy2
72+
run: |
73+
python -m nox --error-on-missing-interpreters -s tests-pypy
74+
shell: bash
75+
if: matrix.python_version == 'pypy2'

‎.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ matrix:
77
- python: 2.7
88
env: NOXSESSION=tests-2.7
99
- python: pypy
10-
env: NOXSESSION=tests-pypy2
10+
env: NOXSESSION=tests-pypy
1111
- python: pypy3
1212
env: NOXSESSION=tests-pypy3
1313
- python: 3.4

‎noxfile.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
nox.options.reuse_existing_virtualenvs = True
2121

2222

23-
@nox.session(python=["2.7", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "pypy2", "pypy3"])
23+
@nox.session(python=["2.7", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "pypy", "pypy3"])
2424
def tests(session):
2525
def coverage(*args):
2626
session.run("python", "-m", "coverage", *args)
@@ -86,7 +86,7 @@ def docs(session):
8686
def release(session):
8787
package_name = "packaging"
8888
version_file = Path(f"{package_name}/__about__.py")
89-
changelog_file = Path(f"CHANGELOG.rst")
89+
changelog_file = Path("CHANGELOG.rst")
9090

9191
try:
9292
release_version = _get_version_from_arguments(session.posargs)
@@ -129,7 +129,7 @@ def release(session):
129129
session.run("python", "setup.py", "sdist", "bdist_wheel")
130130

131131
# Check what files are in dist/ for upload.
132-
files = sorted(glob.glob(f"dist/*"))
132+
files = sorted(glob.glob("dist/*"))
133133
expected = [
134134
f"dist/{package_name}-{release_version}-py2.py3-none-any.whl",
135135
f"dist/{package_name}-{release_version}.tar.gz",
@@ -185,8 +185,7 @@ def _get_version_from_arguments(arguments):
185185

186186

187187
def _check_working_directory_state(session):
188-
"""Check state of the working directory, prior to making the release.
189-
"""
188+
"""Check state of the working directory, prior to making the release."""
190189
should_not_exist = ["build/", "dist/"]
191190

192191
bad_existing_paths = list(filter(os.path.exists, should_not_exist))
@@ -195,8 +194,7 @@ def _check_working_directory_state(session):
195194

196195

197196
def _check_git_state(session, version_tag):
198-
"""Check state of the git repository, prior to making the release.
199-
"""
197+
"""Check state of the git repository, prior to making the release."""
200198
# Ensure the upstream remote pushes to the correct URL.
201199
allowed_upstreams = [
202200
"git@github.com:pypa/packaging.git",
@@ -224,7 +222,7 @@ def _check_git_state(session, version_tag):
224222
)
225223
if result.stdout:
226224
print(result.stdout, end="", file=sys.stderr)
227-
session.error(f"The working tree has uncommitted changes")
225+
session.error("The working tree has uncommitted changes")
228226

229227
# Ensure this tag doesn't exist already.
230228
result = subprocess.run(
@@ -246,7 +244,7 @@ def _bump(session, *, version, file, kind):
246244
)
247245
file.write_text(new_contents)
248246

249-
session.log(f"git commit")
247+
session.log("git commit")
250248
subprocess.run(["git", "add", str(file)])
251249
subprocess.run(["git", "commit", "-m", f"Bump for {kind}"])
252250

@@ -269,8 +267,7 @@ def _replace_file(original_path):
269267

270268

271269
def _changelog_update_unreleased_title(version, *, file):
272-
"""Update an "*unreleased*" heading to "{version} - {date}"
273-
"""
270+
"""Update an "*unreleased*" heading to "{version} - {date}" """
274271
yyyy_mm_dd = datetime.datetime.today().strftime("%Y-%m-%d")
275272
title = f"{version} - {yyyy_mm_dd}"
276273

‎tests/test_tags.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ def test_linux_platforms_manylinux_glibc3(self, monkeypatch):
566566
"executable",
567567
os.path.join(os.path.dirname(__file__), "hello-world-aarch64"),
568568
)
569-
platforms = list(tags._linux_platforms())
569+
platforms = list(tags._linux_platforms(is_32bit=False))
570570
expected = (
571571
["manylinux_3_2_aarch64", "manylinux_3_1_aarch64", "manylinux_3_0_aarch64"]
572572
+ ["manylinux_2_{}_aarch64".format(i) for i in range(50, 16, -1)]
@@ -1279,7 +1279,7 @@ def manylinux_compatible(tag_major, tag_minor, tag_arch):
12791279
manylinux_compatible,
12801280
raising=False,
12811281
)
1282-
platforms = list(tags._linux_platforms())
1282+
platforms = list(tags._linux_platforms(is_32bit=False))
12831283
if tf:
12841284
expected = ["manylinux_2_22_{}".format(machine)]
12851285
else:
@@ -1301,7 +1301,7 @@ def manylinux_compatible(tag_major, tag_minor, tag_arch):
13011301
manylinux_compatible,
13021302
raising=False,
13031303
)
1304-
platforms = list(tags._linux_platforms())
1304+
platforms = list(tags._linux_platforms(is_32bit=False))
13051305
expected = [
13061306
"manylinux_2_30_x86_64",
13071307
"manylinux_2_29_x86_64",

0 commit comments

Comments
 (0)
Please sign in to comment.