Skip to content

Commit 43c32e6

Browse files
committed
fixes from review
1 parent 9236be9 commit 43c32e6

File tree

5 files changed

+47
-107
lines changed

5 files changed

+47
-107
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
project('random-build-examples', 'c', 'cpp', 'cython')
2+
3+
py_mod = import('python')
4+
py3 = py_mod.find_installation(pure: false)
5+
6+
cc = meson.get_compiler('c')
7+
cy = meson.get_compiler('cython')
8+
9+
if not cy.version().version_compare('>=0.29.35')
10+
error('tests requires Cython >= 0.29.35')
11+
endif
12+
13+
_numpy_abs = run_command(py3, ['-c',
14+
'import os; os.chdir(".."); import numpy; print(os.path.abspath(numpy.get_include() + "../../.."))'],
15+
check: true).stdout().strip()
16+
17+
npymath_path = _numpy_abs / 'core' / 'lib'
18+
npy_include_path = _numpy_abs / 'core' / 'include'
19+
npyrandom_path = _numpy_abs / 'random' / 'lib'
20+
npymath_lib = cc.find_library('npymath', dirs: npymath_path)
21+
npyrandom_lib = cc.find_library('npyrandom', dirs: npyrandom_path)
22+
23+
py3.extension_module(
24+
'extending_distributions',
25+
'extending_distributions.pyx',
26+
install: false,
27+
include_directories: [npy_include_path],
28+
dependencies: [npyrandom_lib, npymath_lib],
29+
)
30+
py3.extension_module(
31+
'extending',
32+
'extending.pyx',
33+
install: false,
34+
include_directories: [npy_include_path],
35+
dependencies: [npyrandom_lib, npymath_lib],
36+
)
37+
py3.extension_module(
38+
'extending_cpp',
39+
'extending_distributions.pyx',
40+
install: false,
41+
override_options : ['cython_language=cpp'],
42+
cython_args: ['--module-name', 'extending_cpp'],
43+
include_directories: [npy_include_path],
44+
dependencies: [npyrandom_lib, npymath_lib],
45+
)

numpy/random/_examples/cython/setup.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

numpy/random/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ py.install_sources(
152152
[
153153
'_examples/cython/extending.pyx',
154154
'_examples/cython/extending_distributions.pyx',
155-
'_examples/cython/setup.py',
155+
'_examples/cython/meson.build',
156156
],
157157
subdir: 'numpy/random/_examples/cython'
158158
)

numpy/random/tests/test_extending.py

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -58,61 +58,6 @@ def test_cython(tmp_path):
5858
srcdir = os.path.join(os.path.dirname(__file__), '..')
5959
shutil.copytree(srcdir, tmp_path / 'random')
6060
build_dir = tmp_path / 'random' / '_examples' / 'cython'
61-
# We don't want a wheel build, so do the steps in a controlled way
62-
# The meson.build file is not copied as part of the build, so generate it
63-
with open(build_dir / "meson.build", "wt", encoding="utf-8") as fid:
64-
get_inc = ('import os; os.chdir(".."); import numpy; '
65-
'print(os.path.abspath(numpy.get_include() + "../../.."))')
66-
fid.write(textwrap.dedent(f"""\
67-
project('random-build-examples', 'c', 'cpp', 'cython')
68-
69-
# https://mesonbuild.com/Python-module.html
70-
py_mod = import('python')
71-
py3 = py_mod.find_installation(pure: false)
72-
py3_dep = py3.dependency()
73-
74-
py_mod = import('python')
75-
py = py_mod.find_installation(pure: false)
76-
cc = meson.get_compiler('c')
77-
cy = meson.get_compiler('cython')
78-
79-
if not cy.version().version_compare('>=0.29.35')
80-
error('tests requires Cython >= 0.29.35')
81-
endif
82-
83-
_numpy_abs = run_command(py3, ['-c', '{get_inc}'],
84-
check: true).stdout().strip()
85-
86-
npymath_path = _numpy_abs / 'core' / 'lib'
87-
npy_include_path = _numpy_abs / 'core' / 'include'
88-
npyrandom_path = _numpy_abs / 'random' / 'lib'
89-
npymath_lib = cc.find_library('npymath', dirs: npymath_path)
90-
npyrandom_lib = cc.find_library('npyrandom', dirs: npyrandom_path)
91-
92-
py.extension_module(
93-
'extending_distributions',
94-
'extending_distributions.pyx',
95-
install: false,
96-
include_directories: [npy_include_path],
97-
dependencies: [npyrandom_lib, npymath_lib],
98-
)
99-
py.extension_module(
100-
'extending',
101-
'extending.pyx',
102-
install: false,
103-
include_directories: [npy_include_path],
104-
dependencies: [npyrandom_lib, npymath_lib],
105-
)
106-
py.extension_module(
107-
'extending_cpp',
108-
'extending_distributions.pyx',
109-
install: false,
110-
override_options : ['cython_language=cpp'],
111-
cython_args: ['--module-name', 'extending_cpp'],
112-
include_directories: [npy_include_path],
113-
dependencies: [npyrandom_lib, npymath_lib],
114-
)
115-
"""))
11661
target_dir = build_dir / "build"
11762
os.makedirs(target_dir, exist_ok=True)
11863
if sys.platform == "win32":

tools/travis-test.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,7 @@ setup_base()
8080

8181
run_test()
8282
{
83-
# meson has a hard dependency on ninja, and we need meson to build
84-
# c-extensions in tests. There is a hack ninja PyPI package used in
85-
# build_requirements.txt for macOS, windows, linux but it cannot be in
86-
# test_requirements.txt since pyodide, which uses test_requirements.txt, does
87-
# not have it.
83+
# see note in pyproject.toml for why ninja is installed as a test requirement
8884
PYTHONOPTIMIZE="" $PIP install ninja
8985

9086
# Install the test dependencies.

0 commit comments

Comments
 (0)