Skip to content

Commit

Permalink
Merge pull request #3338 from davidhewitt/3.12-numpy
Browse files Browse the repository at this point in the history
ci: avoid failure to build numpy on 3.12
  • Loading branch information
davidhewitt authored Jul 23, 2023
2 parents 16848cd + d395fe8 commit 3e4acaa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
13 changes: 8 additions & 5 deletions pytests/noxfile.py
Original file line number Diff line number Diff line change
@@ -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)
15 changes: 4 additions & 11 deletions pytests/tests/test_sequence.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pytest
import platform

from pyo3_pytests import sequence

Expand All @@ -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]

0 comments on commit 3e4acaa

Please sign in to comment.