Skip to content

Commit f0ff78c

Browse files
Merge pull request #71 from IntelPython/cleanup/setup
Cleanup/setup
2 parents a25a98f + ae61ddd commit f0ff78c

File tree

5 files changed

+83
-148
lines changed

5 files changed

+83
-148
lines changed

.github/workflows/conda-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python: [3.8]
14+
python: [3.9]
1515
steps:
1616
- uses: actions/checkout@v2
1717
with:
@@ -59,7 +59,7 @@ jobs:
5959

6060
strategy:
6161
matrix:
62-
python: [3.8]
62+
python: [3.9]
6363
experimental: [false]
6464
runner: [ubuntu-latest]
6565
continue-on-error: ${{ matrix.experimental }}

mkl_fft/_numpy_fft.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1494,4 +1494,3 @@ def irfft2(a, s=None, axes=(-2, -1), norm=None):
14941494
check_norm(norm)
14951495
x = _float_utils.__downcast_float128_array(a)
14961496
return irfftn(x, s, axes, norm)
1497-

mkl_fft/_pydfti.pyx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,20 @@
2424
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2525
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2626

27-
from __future__ import absolute_import
27+
#cython: language_level=3
28+
29+
# imports
2830
import numpy as np
29-
cimport numpy as cnp
30-
try:
31-
from numpy.core.multiarray_tests import internal_overlap
32-
except ImportError:
33-
# Module has been renamed in NumPy 1.15
34-
from numpy.core._multiarray_tests import internal_overlap
31+
from numpy.core._multiarray_tests import internal_overlap
32+
from threading import local as threading_local
3533

34+
# cimports
35+
cimport numpy as cnp
3636
from libc.string cimport memcpy
3737
cimport cpython.pycapsule
3838
from cpython.exc cimport (PyErr_Occurred, PyErr_Clear)
3939
from cpython.mem cimport (PyMem_Malloc, PyMem_Free)
4040

41-
from threading import local as threading_local
4241

4342
# thread-local storage
4443
_tls = threading_local()

mkl_fft/setup.py

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

setup.py

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

2727
import io
28+
import os
2829
import re
30+
from os.path import join
31+
from Cython.Build import cythonize
32+
from setuptools import setup, Extension
33+
import numpy as np
34+
from numpy.distutils.conv_template import process_file as process_c_file
2935

3036
with io.open('mkl_fft/_version.py', 'rt', encoding='utf8') as f:
3137
version = re.search(r'__version__ = \'(.*?)\'', f.read()).group(1)
@@ -42,11 +48,11 @@
4248
License :: OSI Approved
4349
Programming Language :: C
4450
Programming Language :: Python
45-
Programming Language :: Python :: 2
46-
Programming Language :: Python :: 2.7
4751
Programming Language :: Python :: 3
48-
Programming Language :: Python :: 3.5
49-
Programming Language :: Python :: 3.6
52+
Programming Language :: Python :: 3.7
53+
Programming Language :: Python :: 3.8
54+
Programming Language :: Python :: 3.9
55+
Programming Language :: Python :: 3.10
5056
Programming Language :: Python :: Implementation :: CPython
5157
Topic :: Software Development
5258
Topic :: Scientific/Engineering
@@ -56,46 +62,73 @@
5662
Operating System :: MacOS
5763
"""
5864

59-
def configuration(parent_package='',top_path=None):
60-
from numpy.distutils.misc_util import Configuration
65+
def extensions():
66+
mkl_root = os.environ.get('MKLROOT', None)
67+
if mkl_root:
68+
mkl_info = {
69+
'include_dirs': [join(mkl_root, 'include')],
70+
'library_dirs': [join(mkl_root, 'lib'), join(mkl_root, 'lib', 'intel64')],
71+
'libraries': ['mkl_rt']
72+
}
73+
else:
74+
try:
75+
mkl_info = get_info('mkl')
76+
except:
77+
mkl_info = dict()
6178

62-
config = Configuration(None, parent_package, top_path)
63-
config.set_options(ignore_setup_xxx_py=True,
64-
assume_default_configuration=True,
65-
delegate_options_to_subpackages=True,
66-
quiet=True)
79+
mkl_include_dirs = mkl_info.get('include_dirs', [])
80+
mkl_library_dirs = mkl_info.get('library_dirs', [])
81+
mkl_libraries = mkl_info.get('libraries', ['mkl_rt'])
6782

68-
config.add_subpackage('mkl_fft')
83+
mklfft_templ = os.path.join("mkl_fft", "src", "mklfft.c.src")
84+
processed_mklfft_fn = os.path.join("mkl_fft", "src", "mklfft.c")
85+
src_processed = process_c_file(mklfft_templ)
6986

70-
config.version = VERSION
87+
with open(processed_mklfft_fn, 'w') as fid:
88+
fid.write(src_processed)
7189

72-
return config
90+
return [
91+
Extension(
92+
"mkl_fft._pydfti",
93+
[
94+
os.path.join("mkl_fft", "_pydfti.pyx"),
95+
os.path.join("mkl_fft", "src", "mklfft.c"),
96+
],
97+
depends = [
98+
os.path.join("mkl_fft", "src", 'mklfft.h'),
99+
os.path.join("mkl_fft", "src", "multi_iter.h")
100+
],
101+
include_dirs = [os.path.join("mkl_fft", "src"), np.get_include()] + mkl_include_dirs,
102+
libraries = mkl_libraries,
103+
library_dirs = mkl_library_dirs,
104+
extra_compile_args = [
105+
'-DNDEBUG',
106+
# '-ggdb', '-O0', '-Wall', '-Wextra', '-DDEBUG',
107+
]
108+
)
109+
]
73110

74111

75-
def setup_package():
76-
from setuptools import setup
77-
from numpy.distutils.core import setup
78-
metadata = dict(
79-
name = 'mkl_fft',
80-
maintainer = "Intel Corp.",
81-
maintainer_email = "scripting@intel.com",
82-
description = "MKL-based FFT transforms for NumPy arrays",
83-
long_description = long_description,
84-
long_description_content_type="text/markdown",
85-
url = "http://github.com/IntelPython/mkl_fft",
86-
author = "Intel Corporation",
87-
download_url = "http://github.com/IntelPython/mkl_fft",
88-
license = 'BSD',
89-
classifiers = [_f for _f in CLASSIFIERS.split('\n') if _f],
90-
platforms = ["Windows", "Linux", "Mac OS-X"],
91-
test_suite = 'nose.collector',
92-
python_requires = '>=3.6',
93-
install_requires = ['numpy >=1.16'],
94-
configuration = configuration
95-
)
96-
setup(**metadata)
97-
98-
return None
99-
100-
if __name__ == '__main__':
101-
setup_package()
112+
setup(
113+
name = "mkl_fft",
114+
maintainer = "Intel Corp.",
115+
maintainer_email = "scripting@intel.com",
116+
description = "MKL-based FFT transforms for NumPy arrays",
117+
version = version,
118+
include_package_data=True,
119+
ext_modules=extensions(),
120+
zip_safe=False,
121+
long_description = long_description,
122+
long_description_content_type="text/markdown",
123+
url = "http://github.com/IntelPython/mkl_fft",
124+
author = "Intel Corporation",
125+
download_url = "http://github.com/IntelPython/mkl_fft",
126+
license = "BSD",
127+
classifiers = [_f for _f in CLASSIFIERS.split('\n') if _f],
128+
platforms = ["Windows", "Linux", "Mac OS-X"],
129+
test_suite = "pytest",
130+
python_requires = '>=3.7',
131+
setup_requires=["Cython",],
132+
install_requires = ["numpy >=1.16"],
133+
keywords=["DFTI", "FFT", "Fourier", "MKL",],
134+
)

0 commit comments

Comments
 (0)