Skip to content

Commit 52b62f9

Browse files
committed
Moves the build system from setuptools to meson
* removes setup.py and generate_mklrand_c.py * updates pyproject.toml * adds meson.build
1 parent 65e6561 commit 52b62f9

File tree

6 files changed

+106
-170
lines changed

6 files changed

+106
-170
lines changed

conda-recipe-cf/meta.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ requirements:
1818
- {{ compiler('cxx') }}
1919
- {{ stdlib('c') }}
2020
host:
21+
- meson-python >=0.13.0
22+
- meson
23+
- pkg-config
2124
- python
2225
- python-gil # [py>=314]
23-
- setuptools >=77
2426
- mkl-devel
2527
- cython
2628
- numpy

conda-recipe/meta.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ requirements:
2121
- {{ compiler('cxx') }}
2222
- {{ stdlib('c') }}
2323
host:
24+
- meson-python >=0.13.0
25+
- meson
26+
- pkg-config
2427
- python
2528
- python-gil # [py>=314]
26-
- setuptools >=77
2729
- mkl-devel
2830
- cython
2931
{% if use_numpy_base %}

meson.build

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
project(
2+
'mkl_random',
3+
['c', 'cpp', 'cython'],
4+
version: run_command(
5+
'python', '-c',
6+
'import os; exec(open("mkl_random/_version.py").read()); print(__version__)',
7+
check: true
8+
).stdout().strip(),
9+
default_options: [
10+
'cpp_std=c++11',
11+
'buildtype=release',
12+
]
13+
)
14+
15+
py = import('python').find_installation(pure: false)
16+
py_dep = py.dependency()
17+
18+
# numpy includes
19+
np_dir = run_command(py,
20+
['-c', 'import numpy; print(numpy.get_include())'],
21+
check: true
22+
).stdout().strip()
23+
24+
inc_np = include_directories(np_dir, 'mkl_random/src')
25+
26+
# compiler/linker
27+
cpp = meson.get_compiler('cpp')
28+
cpp_args = [
29+
'-D_FILE_OFFSET_BITS=64',
30+
'-D_LARGEFILE_SOURCE=1',
31+
'-D_LARGEFILE64_SOURCE=1',
32+
'-DPY_ARRAY_UNIQUE_SYMBOL=mkl_random_ext',
33+
'-DNDEBUG'
34+
]
35+
link_args = []
36+
37+
if cpp.get_argument_syntax() == 'msvc'
38+
link_args += ['Advapi32.lib']
39+
else
40+
cpp_args += ['-Wno-unused-but-set-variable', '-Wno-unused-function']
41+
endif
42+
43+
mkl_dep = dependency('MKL', method: 'cmake',
44+
modules: ['MKL::MKL'],
45+
cmake_args: [
46+
'-DMKL_ARCH=intel64',
47+
'-DMKL_LINK=dynamic',
48+
'-DMKL_INTERFACE=ip64'
49+
],
50+
required: true
51+
)
52+
53+
py.extension_module(
54+
'mklrand',
55+
sources: [
56+
'mkl_random/mklrand.pyx',
57+
'mkl_random/src/mkl_distributions.cpp',
58+
'mkl_random/src/randomkit.cpp'
59+
],
60+
include_directories: inc_np,
61+
dependencies: [mkl_dep, py_dep],
62+
cpp_args: cpp_args,
63+
link_args: link_args,
64+
override_options: ['cython_language=cpp'],
65+
install: true,
66+
subdir: 'mkl_random'
67+
)
68+
69+
# install python sources
70+
71+
py.install_sources(
72+
[
73+
'mkl_random/__init__.py',
74+
'mkl_random/_init_helper.py',
75+
'mkl_random/_patch_numpy.py',
76+
'mkl_random/_version.py',
77+
],
78+
subdir: 'mkl_random'
79+
)
80+
81+
py.install_sources(
82+
[
83+
'mkl_random/interfaces/__init__.py',
84+
'mkl_random/interfaces/_numpy_random.py',
85+
'mkl_random/interfaces/numpy_random.py',
86+
],
87+
subdir: 'mkl_random/interfaces'
88+
)
89+
90+
install_subdir(
91+
'mkl_random/tests',
92+
install_dir: py.get_install_dir() / 'mkl_random'
93+
)

mkl_random/src/generate_mklrand_c.py

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

pyproject.toml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
2424
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2525

2626
[build-system]
27-
build-backend = "setuptools.build_meta"
28-
requires = ["setuptools>=77", "Cython", "numpy"]
27+
build-backend = "mesonpy"
28+
requires = [
29+
"meson-python>=0.13.0",
30+
"Cython",
31+
"numpy"
32+
]
2933

3034
[project]
31-
authors = [
32-
{name = "Intel Corporation", email = "scripting@intel.com"}
33-
]
35+
authors = [{name = "Intel Corporation"}]
3436
classifiers = [
3537
"Development Status :: 5 - Production/Stable",
3638
"Intended Audience :: Science/Research",
@@ -98,13 +100,3 @@ extension-pkg-allow-list = ["numpy", "mkl_random.mklrand"]
98100

99101
[tool.pylint.typecheck]
100102
generated-members = ["RandomState", "min", "max"]
101-
102-
[tool.setuptools]
103-
include-package-data = true
104-
packages = ["mkl_random", "mkl_random.interfaces"]
105-
106-
[tool.setuptools.dynamic]
107-
version = {attr = "mkl_random._version.__version__"}
108-
109-
[tool.setuptools.package-data]
110-
"mkl_random" = ["tests/**/*.py"]

setup.py

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

0 commit comments

Comments
 (0)