ci: avoid failure to build numpy on 3.12

This commit is contained in:
David Hewitt 2023-07-22 21:38:57 +01:00
parent e75d773f0a
commit d395fe8653
2 changed files with 12 additions and 16 deletions

View File

@ -1,21 +1,24 @@
import nox
import platform
from nox.command import CommandFailed
nox.options.sessions = ["test"]
@nox.session
def test(session):
def test(session: nox.Session):
session.install("-rrequirements-dev.txt")
if platform.system() == "Linux" and platform.python_implementation() == "CPython":
session.install("numpy>=1.16")
try:
session.install("--only-binary=numpy", "numpy>=1.16")
except CommandFailed:
# No binary wheel for numpy available on this platform
pass
session.install("maturin")
session.run_always("maturin", "develop")
session.run("pytest", *session.posargs)
@nox.session
def bench(session):
def bench(session: nox.Session):
session.install("-rrequirements-dev.txt")
session.install(".")
session.run("pytest", "--benchmark-enable", "--benchmark-only", *session.posargs)

View File

@ -1,5 +1,4 @@
import pytest
import platform
from pyo3_pytests import sequence
@ -21,21 +20,15 @@ def test_vec_from_str():
sequence.vec_to_vec_pystring("123")
@pytest.mark.skipif(
platform.system() != "Linux" or platform.python_implementation() != "CPython",
reason="Binary NumPy wheels are not available for all platforms and Python implementations",
)
def test_vec_from_array():
import numpy
# binary numpy wheel not available on all platforms
numpy = pytest.importorskip("numpy")
assert sequence.vec_to_vec_i32(numpy.array([1, 2, 3])) == [1, 2, 3]
@pytest.mark.skipif(
platform.system() != "Linux" or platform.python_implementation() != "CPython",
reason="Binary NumPy wheels are not available for all platforms and Python implementations",
)
def test_rust_array_from_array():
import numpy
# binary numpy wheel not available on all platforms
numpy = pytest.importorskip("numpy")
assert sequence.array_to_array_i32(numpy.array([1, 2, 3])) == [1, 2, 3]