Skip to content

Commit b181add

Browse files
committed
Add pyproject.toml and migrate from setup.py
1 parent e07417f commit b181add

File tree

2 files changed

+92
-70
lines changed

2 files changed

+92
-70
lines changed

pyproject.toml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env python
2+
# Copyright (c) 2017-2025, Intel Corporation
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are met:
6+
#
7+
# * Redistributions of source code must retain the above copyright notice,
8+
# this list of conditions and the following disclaimer.
9+
# * Redistributions in binary form must reproduce the above copyright
10+
# notice, this list of conditions and the following disclaimer in the
11+
# documentation and/or other materials provided with the distribution.
12+
# * Neither the name of Intel Corporation nor the names of its contributors
13+
# may be used to endorse or promote products derived from this software
14+
# without specific prior written permission.
15+
#
16+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
[build-system]
28+
requires = ["setuptools>=64.0.0", "Cython", "numpy"]
29+
build-backend = "setuptools.build_meta"
30+
31+
[project]
32+
name = "mkl_random"
33+
dynamic = ["version"]
34+
description = "NumPy-based Python interface to Intel (R) MKL Random Number Generation functionality"
35+
readme = { file = "README.md", content-type = "text/markdown" }
36+
requires-python = ">=3.9,<3.13"
37+
license = { text = "BSD" }
38+
authors = [
39+
{ name = "Intel Corporation", email = "[email protected]" }
40+
]
41+
keywords=["MKL", "VSL", "true randomness", "pseudorandomness",
42+
"Philox", "MT-19937", "SFMT-19937", "MT-2203", "ARS-5",
43+
"R-250", "MCG-31",]
44+
45+
classifiers = [
46+
"Development Status :: 5 - Production/Stable",
47+
"Intended Audience :: Science/Research",
48+
"Intended Audience :: Developers",
49+
"License :: OSI Approved",
50+
"Programming Language :: C",
51+
"Programming Language :: Python",
52+
"Programming Language :: Python :: 3",
53+
"Programming Language :: Python :: 3.9",
54+
"Programming Language :: Python :: 3.10",
55+
"Programming Language :: Python :: 3.11",
56+
"Programming Language :: Python :: 3.12",
57+
"Programming Language :: Python :: Implementation :: CPython",
58+
"Topic :: Software Development",
59+
"Topic :: Scientific/Engineering",
60+
"Operating System :: Microsoft :: Windows",
61+
"Operating System :: POSIX",
62+
"Operating System :: Unix",
63+
]
64+
dependencies = ["numpy >=1.26.4", "mkl"]
65+
66+
[project.optional-dependencies]
67+
test = ["pytest"]
68+
69+
[project.urls]
70+
Homepage = "http://github.com/IntelPython/mkl_random"
71+
Download = "http://github.com/IntelPython/mkl_random"
72+
73+
[tool.setuptools]
74+
packages = ["mkl_random"]
75+
include-package-data = true
76+
77+
[tool.setuptools.package-data]
78+
"mkl_random" = ["tests/*.py"]
79+
80+
[tool.setuptools.dynamic]
81+
version = {attr = "mkl_random._version.__version__"}

setup.py

Lines changed: 11 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,12 @@
2626

2727
import os
2828
import sys
29-
import io
30-
import re
3129
from os.path import join
3230
import Cython.Build
3331
from setuptools import setup, Extension
3432
import numpy as np
3533

36-
37-
with io.open('mkl_random/_version.py', 'rt', encoding='utf8') as f:
38-
version = re.search(r'__version__ = \'(.*?)\'', f.read()).group(1)
39-
40-
with open("README.md", "r", encoding="utf-8") as file:
41-
long_description = file.read()
42-
43-
VERSION = version
44-
45-
CLASSIFIERS = CLASSIFIERS = """\
46-
Development Status :: 5 - Production/Stable
47-
Intended Audience :: Science/Research
48-
Intended Audience :: Developers
49-
License :: OSI Approved
50-
Programming Language :: C
51-
Programming Language :: Python
52-
Programming Language :: Python :: 3
53-
Programming Language :: Python :: 3.9
54-
Programming Language :: Python :: 3.10
55-
Programming Language :: Python :: 3.11
56-
Programming Language :: Python :: 3.12
57-
Programming Language :: Python :: Implementation :: CPython
58-
Topic :: Software Development
59-
Topic :: Scientific/Engineering
60-
Operating System :: Microsoft :: Windows
61-
Operating System :: POSIX
62-
Operating System :: Unix
63-
Operating System :: MacOS
64-
"""
34+
sys.path.insert(0, os.path.dirname(__file__)) # Ensures local imports work
6535

6636

6737
def extensions():
@@ -101,23 +71,23 @@ def extensions():
10171
exts = [
10272
Extension(
10373
"mkl_random.mklrand",
104-
[
105-
os.path.join("mkl_random", "mklrand.pyx"),
106-
os.path.join("mkl_random", "src", "mkl_distributions.cpp"),
107-
os.path.join("mkl_random", "src", "randomkit.cpp"),
74+
sources = [
75+
join("mkl_random", "mklrand.pyx"),
76+
join("mkl_random", "src", "mkl_distributions.cpp"),
77+
join("mkl_random", "src", "randomkit.cpp"),
10878
],
10979
depends = [
110-
os.path.join("mkl_random", "src", "mkl_distributions.hpp"),
111-
os.path.join("mkl_random", "src", "randomkit.h"),
112-
os.path.join("mkl_random", "src", "numpy_multiiter_workaround.h")
80+
join("mkl_random", "src", "mkl_distributions.hpp"),
81+
join("mkl_random", "src", "randomkit.h"),
82+
join("mkl_random", "src", "numpy_multiiter_workaround.h")
11383
],
114-
include_dirs = [os.path.join("mkl_random", "src"), np.get_include()] + mkl_include_dirs,
84+
include_dirs = [join("mkl_random", "src"), np.get_include()] + mkl_include_dirs,
11585
libraries = libs,
11686
library_dirs = lib_dirs,
11787
extra_compile_args = eca + [
11888
# "-ggdb", "-O0", "-Wall", "-Wextra",
11989
],
120-
define_macros=defs + [("NDEBUG",None),], # [("DEBUG", None),]
90+
define_macros=defs + [("NDEBUG", None)], # [("DEBUG", None),]
12191
language="c++"
12292
)
12393
]
@@ -126,36 +96,7 @@ def extensions():
12696

12797

12898
setup(
129-
name = "mkl_random",
130-
maintainer = "Intel Corp.",
131-
maintainer_email = "[email protected]",
132-
description = "NumPy-based Python interface to Intel (R) MKL Random Number Generation functionality",
133-
version = version,
134-
include_package_data=True,
135-
ext_modules=extensions(),
13699
cmdclass={'build_ext': Cython.Build.build_ext},
100+
ext_modules=extensions(),
137101
zip_safe=False,
138-
long_description = long_description,
139-
long_description_content_type="text/markdown",
140-
url = "http://github.com/IntelPython/mkl_random",
141-
author = "Intel Corporation",
142-
download_url = "http://github.com/IntelPython/mkl_random",
143-
license = "BSD",
144-
classifiers = [_f for _f in CLASSIFIERS.split('\n') if _f],
145-
platforms = ["Windows", "Linux", "Mac OS-X"],
146-
test_suite = "pytest",
147-
python_requires = '>=3.7',
148-
setup_requires=["Cython",],
149-
install_requires = ["numpy >=1.16"],
150-
packages=[
151-
"mkl_random",
152-
],
153-
package_data={
154-
"mkl_random" : [
155-
"tests/*.*",
156-
]
157-
},
158-
keywords=["MKL", "VSL", "true randomness", "pseudorandomness",
159-
"Philox", "MT-19937", "SFMT-19937", "MT-2203", "ARS-5",
160-
"R-250", "MCG-31",],
161102
)

0 commit comments

Comments
 (0)