Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TST: Explicitly pass NumPy path to cython during tests (also speed them up) #25203

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

Merged
merged 2 commits into from
Nov 20, 2023
Merged
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
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 @@ -28,14 +28,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