Skip to content

Commit

Permalink
Merge pull request numpy#25141 from seberg/cytest
Browse files Browse the repository at this point in the history
TST: Explicitly pass NumPy path to cython during tests (also speed them up)
  • Loading branch information
mattip authored Nov 15, 2023
2 parents 0f61000 + 3fc43d3 commit b3d71f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions numpy/_core/tests/examples/cython/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ npy_include_path = run_command(py, [
'import os; os.chdir(".."); import numpy; print(os.path.abspath(numpy.get_include()))'
], check: true).stdout().strip()

npy_path = run_command(py, [
'-c',
'import os; os.chdir(".."); import numpy; print(os.path.dirname(numpy.__file__).removesuffix("numpy"))'
], check: true).stdout().strip()

# TODO: This is a hack due to gh-25135, where cython may not find the right
# __init__.pyd file.
add_project_arguments('-I', npy_path, language : 'cython')

py.extension_module(
'checks',
'checks.pyx',
Expand Down
6 changes: 3 additions & 3 deletions numpy/_core/tests/test_cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
pytestmark = pytest.mark.skipif(cython is None, reason="requires cython")


@pytest.fixture
def install_temp(tmp_path):
@pytest.fixture(scope='module')
def install_temp(tmpdir_factory):
# Based in part on test_cython from random.tests.test_extending
if IS_WASM:
pytest.skip("No subprocess")

srcdir = os.path.join(os.path.dirname(__file__), 'examples', 'cython')
build_dir = tmp_path / "build"
build_dir = tmpdir_factory.mktemp("cython_test") / "build"
os.makedirs(build_dir, exist_ok=True)
try:
subprocess.check_call(["meson", "--version"])
Expand Down

0 comments on commit b3d71f7

Please sign in to comment.