|
25 | 25 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26 | 26 |
|
27 | 27 | import io
|
| 28 | +import os |
28 | 29 | 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 |
29 | 35 |
|
30 | 36 | with io.open('mkl_fft/_version.py', 'rt', encoding='utf8') as f:
|
31 | 37 | version = re.search(r'__version__ = \'(.*?)\'', f.read()).group(1)
|
|
42 | 48 | License :: OSI Approved
|
43 | 49 | Programming Language :: C
|
44 | 50 | Programming Language :: Python
|
45 |
| -Programming Language :: Python :: 2 |
46 |
| -Programming Language :: Python :: 2.7 |
47 | 51 | 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 |
50 | 56 | Programming Language :: Python :: Implementation :: CPython
|
51 | 57 | Topic :: Software Development
|
52 | 58 | Topic :: Scientific/Engineering
|
|
56 | 62 | Operating System :: MacOS
|
57 | 63 | """
|
58 | 64 |
|
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() |
61 | 78 |
|
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']) |
67 | 82 |
|
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) |
69 | 86 |
|
70 |
| - config.version = VERSION |
| 87 | + with open(processed_mklfft_fn, 'w') as fid: |
| 88 | + fid.write(src_processed) |
71 | 89 |
|
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 | + ] |
73 | 110 |
|
74 | 111 |
|
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