|
1 | 1 | import os
|
| 2 | +import sys |
| 3 | +from pathlib import Path |
2 | 4 |
|
3 | 5 | import nox
|
4 | 6 |
|
5 | 7 | nox.needs_version = ">=2022.1.7"
|
6 | 8 | nox.options.sessions = ["lint", "tests", "tests_packaging"]
|
7 | 9 |
|
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"] |
9 | 24 |
|
10 | 25 | if os.environ.get("CI", None):
|
11 | 26 | nox.options.error_on_missing_interpreters = True
|
@@ -95,3 +110,58 @@ def build(session: nox.Session) -> None:
|
95 | 110 | session.run(
|
96 | 111 | "python", "-m", "build", *session.posargs, env={"PYBIND11_GLOBAL_SDIST": "1"}
|
97 | 112 | )
|
| 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") |
0 commit comments