25
25
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
26
27
27
import sys
28
+ from os import (getcwd , environ , makedirs )
28
29
from os .path import join , exists , abspath , dirname
29
- from os import getcwd
30
- from os import environ
30
+ import importlib .machinery # requires Python >= 3.4
31
+ from distutils .dep_util import newer
32
+
33
+ def load_module (name , fn ):
34
+ """
35
+ Credit: numpy.compat.npy_load_module
36
+ """
37
+ return importlib .machinery .SourceFileLoader (name , fn ).load_module ()
38
+
39
+
40
+ def separator_join (sep , strs ):
41
+ """
42
+ Joins non-empty arguments strings with dot.
43
+
44
+ Credit: numpy.distutils.misc_util.dot_join
45
+ """
46
+ assert isinstance (strs , (list , tuple ))
47
+ assert isinstance (sep , str )
48
+ return sep .join ([si for si in strs if si ])
49
+
31
50
32
51
def configuration (parent_package = '' ,top_path = None ):
33
52
from numpy .distutils .misc_util import Configuration
@@ -52,7 +71,26 @@ def configuration(parent_package='',top_path=None):
52
71
wdir = join (pdir , 'src' )
53
72
mkl_info = get_info ('mkl' )
54
73
55
- sources = []
74
+ generate_umath_py = join (pdir , 'generate_umath.py' )
75
+ n = separator_join ('_' , (config .name , 'generate_umath' ))
76
+ generate_umath = load_module (n , generate_umath_py )
77
+ del n
78
+
79
+ def generate_umath_c (ext , build_dir ):
80
+ target_dir = join (build_dir , 'src' )
81
+ target = join (target_dir , '__umath_generated.c' )
82
+ if not exists (target_dir ):
83
+ print ("Folder {} was expected to exist, but creating" .format (target_dir ))
84
+ makedirs (target_dir )
85
+ script = generate_umath_py
86
+ if newer (script , target ):
87
+ with open (target , 'w' ) as f :
88
+ f .write (generate_umath .make_code (generate_umath .defdict ,
89
+ generate_umath .__file__ ))
90
+ config .add_include_dirs (target_dir )
91
+ return []
92
+
93
+ sources = [generate_umath_c ]
56
94
# try:
57
95
# from Cython.Build import cythonize
58
96
# sources = [join(pdir, '_pydfti.pyx')]
@@ -67,18 +105,20 @@ def configuration(parent_package='',top_path=None):
67
105
config .add_extension (
68
106
name = '_ufuncs' ,
69
107
sources = [
108
+ join (wdir , 'loops_intel.h.src' ),
109
+ join (wdir , 'loops_intel.c.src' ),
70
110
join (wdir , 'ufuncsmodule.c' ),
71
- join (wdir , 'loops_intel.c.src' )
72
111
] + sources ,
73
112
depends = [
74
- # join(wdir, 'mklfft.h'),
113
+ join (wdir , 'blocking_utils.h' ),
114
+ join (wdir , 'fast_loop_macros.h' ),
75
115
],
76
116
include_dirs = [wdir ] + mkl_include_dirs ,
77
117
libraries = mkl_libraries ,
78
118
library_dirs = mkl_library_dirs ,
79
119
extra_compile_args = [
80
- '-DNDEBUG' ,
81
- # '-ggdb', '-O0', '-Wall', '-Wextra', '-DDEBUG',
120
+ # '-DNDEBUG',
121
+ '-ggdb' , '-O0' , '-Wall' , '-Wextra' , '-DDEBUG' ,
82
122
]
83
123
)
84
124
0 commit comments