Skip to content

Commit 89b8d8a

Browse files
committed
ci: test pypy upstream
tests: fix leading indent in PyPy code Update noxfile.py Co-authored-by: Matti Picus <[email protected]> Update tests/test_exceptions.py Co-authored-by: Matti Picus <[email protected]> Revert "Update tests/test_exceptions.py" This reverts commit af3061d.
1 parent 5f9b090 commit 89b8d8a

File tree

3 files changed

+97
-3
lines changed

3 files changed

+97
-3
lines changed

.github/workflows/upstream.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
standard:
1717
name: "🐍 3.11 dev • ubuntu-latest • x64"
1818
runs-on: ubuntu-latest
19-
if: "contains(github.event.pull_request.labels.*.name, 'python dev')"
19+
if: "contains(github.event.pull_request.labels.*.name, 'python dev') || github.event_name == 'workflow_dispatch'"
2020

2121
steps:
2222
- uses: actions/checkout@v2
@@ -110,3 +110,23 @@ jobs:
110110
# setuptools
111111
- name: Setuptools helpers test
112112
run: pytest tests/extra_setuptools
113+
114+
pypy:
115+
name: "🐍 PyPy ${{ matrix.pypy-version }} dev • ${{ matrix.runs-on }} • x64"
116+
runs-on: ${{ matrix.runs-on }}
117+
if: "contains(github.event.pull_request.labels.*.name, 'python dev') || github.event_name == 'workflow_dispatch'"
118+
strategy:
119+
fail-fast: false
120+
matrix:
121+
runs-on: [ubuntu-latest, macos-latest]
122+
pypy-version: ["3.7", "3.8", "3.9"]
123+
124+
steps:
125+
- uses: actions/checkout@v2
126+
127+
- name: Setup Boost (Linux)
128+
if: runner.os == 'Linux'
129+
run: sudo apt-get install libboost-dev
130+
131+
- name: Build and test
132+
run: pipx run nox -s 'pypy_upstream(${{ matrix.pypy-version }})'

noxfile.py

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
import os
2+
import sys
3+
from pathlib import Path
24

35
import nox
46

57
nox.needs_version = ">=2022.1.7"
68
nox.options.sessions = ["lint", "tests", "tests_packaging"]
79

8-
PYTHON_VERISONS = ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.7", "pypy3.8"]
10+
DIR = Path(__file__).parent.resolve()
11+
12+
PYTHON_VERISONS = [
13+
"3.6",
14+
"3.7",
15+
"3.8",
16+
"3.9",
17+
"3.10",
18+
"3.11",
19+
"pypy3.7",
20+
"pypy3.8",
21+
"pypy3.9",
22+
]
23+
PYPY_VERSIONS = ["3.7", "3.8", "3.9"]
924

1025
if os.environ.get("CI", None):
1126
nox.options.error_on_missing_interpreters = True
@@ -95,3 +110,58 @@ def build(session: nox.Session) -> None:
95110
session.run(
96111
"python", "-m", "build", *session.posargs, env={"PYBIND11_GLOBAL_SDIST": "1"}
97112
)
113+
114+
115+
@nox.session
116+
@nox.parametrize("pypy", PYPY_VERSIONS, ids=PYPY_VERSIONS)
117+
def pypy_upstream(session: nox.Session, pypy: str) -> None:
118+
"""
119+
Test against upstream PyPy (64-bit UNIX only)
120+
"""
121+
import tarfile
122+
import urllib.request
123+
124+
binary = "linux64" if sys.platform.startswith("linux") else "osx64"
125+
url = (
126+
f"https://buildbot.pypy.org/nightly/py{pypy}/pypy-c-jit-latest-{binary}.tar.bz2"
127+
)
128+
129+
tmpdir = session.create_tmp()
130+
with session.chdir(tmpdir):
131+
urllib.request.urlretrieve(url, "pypy.tar.bz2")
132+
with tarfile.open("pypy.tar.bz2", "r:bz2") as tar:
133+
tar.extractall()
134+
(found,) = Path(tmpdir).glob("*/bin/pypy3")
135+
pypy_prog = str(found.resolve())
136+
pypy_dir = found.parent.parent
137+
138+
session.run(pypy_prog, "-m", "ensurepip", external=True)
139+
session.run(pypy_prog, "-m", "pip", "install", "--upgrade", "pip", external=True)
140+
session.run(
141+
pypy_prog,
142+
"-m",
143+
"pip",
144+
"install",
145+
"pytest",
146+
"numpy;python_version<'3.9' and platform_system=='Linux'",
147+
"--only-binary=:all:",
148+
external=True,
149+
)
150+
151+
session.install("cmake", "ninja")
152+
build_dir = session.create_tmp()
153+
tmpdir = session.create_tmp()
154+
session.run(
155+
"cmake",
156+
f"-S{DIR}",
157+
f"-B{build_dir}",
158+
"-DPYBIND11_FINDPYTHON=ON",
159+
f"-DPython_ROOT={pypy_dir}",
160+
"-GNinja",
161+
"-DPYBIND11_WERROR=ON",
162+
"-DDOWNLOAD_EIGEN=ON",
163+
*session.posargs,
164+
)
165+
session.run("cmake", "--build", build_dir)
166+
session.run("cmake", "--build", build_dir, "--target", "pytest")
167+
session.run("cmake", "--build", build_dir, "--target", "test_cmake_build")

tests/test_exceptions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ def ignore_pytest_unraisable_warning(f):
9595

9696

9797
# TODO: find out why this fails on PyPy, https://foss.heptapod.net/pypy/pypy/-/issues/3583
98-
@pytest.mark.xfail(env.PYPY, reason="Failure on PyPy 3.8 (7.3.7)", strict=False)
98+
@pytest.mark.xfail(
99+
env.PYPY and sys.version_info >= (3, 8),
100+
reason="Failure on PyPy 3.8 (7.3.7)",
101+
strict=False,
102+
)
99103
@ignore_pytest_unraisable_warning
100104
def test_python_alreadyset_in_destructor(monkeypatch, capsys):
101105
hooked = False

0 commit comments

Comments
 (0)