Skip to content

ci: test pypy upstream #3743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- '3.10'
- 'pypy-3.7'
- 'pypy-3.8'
- 'pypy-3.9'

# Items in here will either be added to the build matrix (if not
# present), or add new keys to an existing matrix element if all the
Expand Down
22 changes: 21 additions & 1 deletion .github/workflows/upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
standard:
name: "🐍 3.11 dev • ubuntu-latest • x64"
runs-on: ubuntu-latest
if: "contains(github.event.pull_request.labels.*.name, 'python dev')"
if: "contains(github.event.pull_request.labels.*.name, 'python dev') || github.event_name == 'workflow_dispatch'"

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -110,3 +110,23 @@ jobs:
# setuptools
- name: Setuptools helpers test
run: pytest tests/extra_setuptools

pypy:
name: "🐍 PyPy ${{ matrix.pypy-version }} dev • ${{ matrix.runs-on }} • x64"
runs-on: ${{ matrix.runs-on }}
if: "contains(github.event.pull_request.labels.*.name, 'python dev') || github.event_name == 'workflow_dispatch'"
strategy:
fail-fast: false
matrix:
runs-on: [ubuntu-latest, macos-latest]
pypy-version: ["3.7", "3.8", "3.9"]

steps:
- uses: actions/checkout@v2

- name: Setup Boost (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install libboost-dev

- name: Build and test
run: pipx run nox -s 'pypy_upstream(${{ matrix.pypy-version }})'
72 changes: 71 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
import os
import sys
from pathlib import Path

import nox

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

PYTHON_VERISONS = ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.7", "pypy3.8"]
DIR = Path(__file__).parent.resolve()

PYTHON_VERISONS = [
"3.6",
"3.7",
"3.8",
"3.9",
"3.10",
"3.11",
"pypy3.7",
"pypy3.8",
"pypy3.9",
]
PYPY_VERSIONS = ["3.7", "3.8", "3.9"]

if os.environ.get("CI", None):
nox.options.error_on_missing_interpreters = True
Expand Down Expand Up @@ -95,3 +110,58 @@ def build(session: nox.Session) -> None:
session.run(
"python", "-m", "build", *session.posargs, env={"PYBIND11_GLOBAL_SDIST": "1"}
)


@nox.session
@nox.parametrize("pypy", PYPY_VERSIONS, ids=PYPY_VERSIONS)
def pypy_upstream(session: nox.Session, pypy: str) -> None:
"""
Test against upstream PyPy (64-bit UNIX only)
"""
import tarfile
import urllib.request

binary = "linux64" if sys.platform.startswith("linux") else "osx64"
url = (
f"https://buildbot.pypy.org/nightly/py{pypy}/pypy-c-jit-latest-{binary}.tar.bz2"
)

tmpdir = session.create_tmp()
with session.chdir(tmpdir):
urllib.request.urlretrieve(url, "pypy.tar.bz2")
with tarfile.open("pypy.tar.bz2", "r:bz2") as tar:
tar.extractall()
(found,) = Path(tmpdir).glob("*/bin/pypy3")
pypy_prog = str(found.resolve())
pypy_dir = found.parent.parent

session.run(pypy_prog, "-m", "ensurepip", external=True)
session.run(pypy_prog, "-m", "pip", "install", "--upgrade", "pip", external=True)
session.run(
pypy_prog,
"-m",
"pip",
"install",
"pytest",
"numpy;python_version<'3.9' and platform_system=='Linux'",
"--only-binary=:all:",
external=True,
)

session.install("cmake", "ninja")
build_dir = session.create_tmp()
tmpdir = session.create_tmp()
session.run(
"cmake",
f"-S{DIR}",
f"-B{build_dir}",
"-DPYBIND11_FINDPYTHON=ON",
f"-DPython_ROOT={pypy_dir}",
"-GNinja",
"-DPYBIND11_WERROR=ON",
"-DDOWNLOAD_EIGEN=ON",
*session.posargs,
)
session.run("cmake", "--build", build_dir)
session.run("cmake", "--build", build_dir, "--target", "pytest")
session.run("cmake", "--build", build_dir, "--target", "test_cmake_build")
6 changes: 5 additions & 1 deletion tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ def ignore_pytest_unraisable_warning(f):


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