8000 TST: convert test_limited_api to meson · numpy/numpy@506b280 · GitHub
[go: up one dir, main page]

Skip to content

Commit 506b280

Browse files
committed
TST: convert test_limited_api to meson
1 parent bc0087e commit 506b280

File tree

4 files changed

+43
-53
lines changed

4 files changed

+43
-53
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
project('limited_api', 'c', 'cython')
2+
3+
py_mod = import('python')
4+
py3 = py_mod.find_installation(pure: false)
5+
6+
cc = meson.get_compiler('c')
7+
8+
npy_include_path = run_command(py3, ['-c',
9+
'import os; os.chdir(".."); import numpy; print(os.path.abspath(numpy.get_include()))'],
10+
check: true).stdout().strip()
11+
12+
py3.extension_module(
13+
'limited_api',
14+
'limited_api.c',
15+
install: false,
16+
c_args: [
17+
'-DNPY_NO_DEPRECATED_API=0', # Cython still uses old NumPy C API
18+
'-DPy_LIMITED_API=0x03060000',
19+
],
20+
include_directories: [npy_include_path],
21+
)

numpy/core/tests/examples/limited_api/setup.py

Copy file name to clipboard
Lines changed: 0 additions & 22 deletions
This file was deleted.

numpy/core/tests/test_cython.py

Lines changed: 8 additions & 12 deletions
< 8000 td data-grid-cell-id="diff-77fb17c954b6d12dab5aa5f47604b36c995641c8d1aed127680565a48a99e8f0-48-44-2" data-line-anchor="diff-77fb17c954b6d12dab5aa5f47604b36c995641c8d1aed127680565a48a99e8f0R44" data-selected="false" role="gridcell" style="background-color:var(--bgColor-default);padding-right:24px" tabindex="-1" valign="top" class="focusable-grid-cell diff-text-cell right-side-diff-cell left-side">
"--buildtype=release",
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,22 @@ def install_temp(tmp_path):
3636
if IS_WASM:
3737
pytest.skip("No subprocess")
3838

39-
import glob
40-
# build the examples in a temporary directory
4139
srcdir = os.path.join(os.path.dirname(__file__), 'examples', 'cython')
42-
build_dir = tmp_path / "cython"
43-
shutil.copytree(srcdir, build_dir)
44-
target_dir = build_dir / "build"
45-
os.makedirs(target_dir, exist_ok=True)
40+
build_dir = tmp_path / "build"
41+
os.makedirs(build_dir, exist_ok=True)
4642
if sys.platform == "win32":
4743
subprocess.check_call(["meson", "setup",
4844
49-
"--vsenv", str(build_dir)],
50-
cwd=target_dir,
45+
"--vsenv", str(srcdir)],
46+
cwd=build_dir,
5147
)
5248
else:
53-
subprocess.check_call(["meson", "setup", str(build_dir)],
54-
cwd=target_dir
49+
subprocess.check_call(["meson", "setup", str(srcdir)],
50+
cwd=build_dir
5551
)
56-
subprocess.check_call(["meson", "compile", "-vv"], cwd=target_dir)
52+
subprocess.check_call(["meson", "compile", "-vv"], cwd=build_dir)
5753

58-
sys.path.append(str(target_dir))
54+
sys.path.append(str(build_dir))
5955

6056
def test_is_timedelta64_object(install_temp):
6157
print(sys.path)

numpy/core/tests/test_limited_api.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,17 @@ def test_limited_api(tmp_path):
2323
here = os.path.dirname(__file__)
2424
ext_dir = os.path.join(here, "examples", "limited_api")
2525

26-
cytest = str(tmp_path / "limited_api")
27-
28-
shutil.copytree(ext_dir, cytest)
29-
# build the examples and "install" them into a temporary directory
30-
31-
install_log = str(tmp_path / "tmp_install_log.txt")
32-
subprocess.check_output(
33-
[
34-
sys.executable,
35-
"setup.py",
36-
"build",
37-
"install",
38-
"--prefix", str(tmp_path / "installdir"),
39-
"--single-version-externally-managed",
40-
"--record",
41-
install_log,
42-
],
43-
cwd=cytest,
44-
)
26+
target_dir = tmp_path / "build"
27+
os.makedirs(target_dir, exist_ok=True)
28+
29+
if sys.platform == "win32":
30+
subprocess.check_call(["meson", "setup",
31+
"--buildtype=release",
32+
"--vsenv", ext_dir],
33+
cwd=target_dir,
34+
)
35+
else:
36+
subprocess.check_call(["meson", "setup", ext_dir], cwd=target_dir)
37+
subprocess.check_call(["meson", "compile", "-vv"], cwd=target_dir)
38+
39+

0 commit comments

Comments
 (0)
0