8000 BLD, TST: refactor test to use meson not setup.py, improve spin test -m ... by mattip · Pull Request #24153 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
TST: fix: using meson with windows, MSVC
  • Loading branch information
mattip committed Jul 13, 2023
commit e290d1ca2568599b0cf434a1f016e54b4da9e8cb
7 changes: 3 additions & 4 deletions numpy/core/tests/test_array_interface.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
import pytest
import numpy as np
from numpy.testing import extbuild
from numpy.testing import extbuild, IS_WASM


@pytest.fixture
Expand All @@ -12,6 +12,8 @@ def get_module(tmp_path):

if not sys.platform.startswith('linux'):
pytest.skip('link fails on cygwin')
if IS_WASM:
pytest.skip("Can't build module inside Wasm")

prologue = '''
#include <Python.h>
Expand Down Expand Up @@ -128,9 +130,6 @@ def get_module(tmp_path):
more_init=more_init)


# FIXME: numpy.testing.extbuild uses `numpy.distutils`, so this won't work on
# Python 3.12 and up.
@pytest.mark.skipif(sys.version_info >= (3, 12), reason="no numpy.distutils")
@pytest.mark.slow
def test_cstruct(get_module):

Expand Down
19 changes: 15 additions & 4 deletions numpy/random/tests/test_extending.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import shutil
import subprocess
import sys
import sysconfig
import textwrap
import warnings

Expand Down Expand Up @@ -105,8 +106,17 @@ def test_cython(tmp_path):
"""))
target_dir = build_dir / "build"
os.makedirs(target_dir, exist_ok=True)
subprocess.check_call(["meson", "setup", str(build_dir)], cwd=target_dir)
subprocess.check_call(["meson", "compile"], cwd=target_dir)
if sys.platform == "win32":
subprocess.check_call(["meson", "setup",
"--buildtype=release",
"--vsenv", str(build_dir)],
cwd=target_dir,
)
else:
subprocess.check_call(["meson", "setup", str(build_dir)],
cwd=target_dir
)
subprocess.check_call(["meson", "compile", "-vv"], cwd=target_dir)

# gh-16162: make sure numpy's __init__.pxd was used for cython
# not really part of this test, but it is a convenient place to check
Expand All @@ -121,8 +131,9 @@ def test_cython(tmp_path):
assert False, ("Could not find '{}' in C file, "
"wrong pxd used".format(txt_to_find))
# import without adding the directory to sys.path
so1 = sorted(glob.glob(str(target_dir / "extending.*")))[0]
so2 = sorted(glob.glob(str(target_dir / "extending_distributions.*")))[0]
suffix = sysconfig.get_config_var('EXT_SUFFIX')
so1 = (target_dir / "extending").with_suffix(suffix)
so2 = (target_dir / "extending_distributions").with_suffix(suffix)
spec1 = spec_from_file_location("extending", so1)
spec2 = spec_from_file_location("extending_distributions", so2)
extending = module_from_spec(spec1)
Expand Down
11 changes: 10 additions & 1 deletion numpy/testing/_private/extbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,16 @@ def build(cfile, outputfilename, compile_extra, link_extra,
name_suffix: 'dummy',
)
"""))
subprocess.check_call(["meson", "setup", "--vsenv", ".."], cwd=build_dir)
if sys.platform == "win32":
subprocess.check_call(["meson", "setup",
"--buildtype=release",
"--vsenv", ".."],
cwd=build_dir,
)
else:
subprocess.check_call(["meson", "setup", "--vsenv", ".."],
cwd=build_dir
)
subprocess.check_call(["meson", "compile"], cwd=build_dir)
os.rename(str(build_dir / so_name) + ".dummy", cfile.parent / so_name)

Expand Down
0