21
21
from setuptools .extension import Extension
22
22
from setuptools import find_packages
23
23
from setuptools .command .test import test as TestCommand
24
- from Cython .Build import cythonize
25
- import sys , os , platform
24
+ import sys
25
+ import os
26
+ import platform
26
27
27
28
28
29
if platform .system ().lower () == 'darwin' :
@@ -75,15 +76,38 @@ def run_tests(self):
75
76
'--cov-report' , 'xml' ,
76
77
'--cov-report' , 'html' ,
77
78
'--junitxml' , 'junit.xml' ,
78
- ])
79
+ ])
79
80
errno = pytest .main (args )
80
81
sys .exit (errno )
81
82
82
- # Cython lz4
83
- compress = Extension ('arctic._compress' ,
84
- sources = ["src/_compress.pyx" , "src/lz4.c" , "src/lz4hc.c" ],
85
- extra_compile_args = ['-fopenmp' , '-fpermissive' ], # Avoid compiling error with prange. Similar to http://stackoverflow.com/questions/36577182/unable-to-assign-value-to-array-in-prange
86
- extra_link_args = ['-fopenmp' ])
83
+
84
+ class defer_cythonize (list ):
85
+ def __init__ (self , callback ):
86
+ self ._list , self .callback = None , callback
87
+
88
+ def c_list (self ):
89
+ if self ._list is None :
90
+ self ._list = self .callback ()
91
+ return self ._list
92
+
93
+ def __iter__ (self ):
94
+ for elem in self .c_list ():
95
+ yield elem
96
+
97
+ def __getitem__ (self , ii ):
98
+ return self .c_list ()[ii ]
99
+
100
+ def __len__ (self ):
101
+ return len (self .c_list ())
102
+
103
+
104
+ def extensions ():
105
+ from Cython .Build import cythonize
106
+ return cythonize (Extension ('arctic._compress' ,
107
+ sources = ["src/_compress.pyx" , "src/lz4.c" , "src/lz4hc.c" ],
108
+ extra_compile_args = ['-fopenmp' , '-fpermissive' ], # Avoid compiling error with prange. Similar to http://stackoverflow.com/questions/36577182/unable-to-assign-value-to-array-in-prange
109
+ extra_link_args = ['-fopenmp' ]))
110
+
87
111
88
112
setup (
89
113
name = "arctic" ,
@@ -97,21 +121,22 @@ def run_tests(self):
97
121
packages = find_packages (exclude = ['tests' , 'tests.*' , 'benchmarks' ]),
98
122
long_description = '\n ' .join ((long_description , changelog )),
99
123
cmdclass = {'test' : PyTest },
100
- ext_modules = cythonize ( compress ),
124
+ ext_modules = defer_cythonize ( extensions ),
101
125
setup_requires = ["six" ,
102
- "Cython " ,
126
+ "cython " ,
103
127
"numpy" ,
104
128
"setuptools-git" ,
105
- ],
106
- install_requires = ["decorator" ,
129
+ ],
130
+ install_requires = ["cython" ,
131
+ "decorator" ,
107
132
"enum34" ,
108
133
"mockextras" ,
109
134
"pandas" ,
110
135
"pymongo>=3.0" ,
111
136
"python-dateutil" ,
112
137
"pytz" ,
113
138
"tzlocal" ,
114
- ],
139
+ ],
115
140
tests_require = ["mock" ,
116
141
"mockextras" ,
117
142
"pytest" ,
@@ -120,7 +145,7 @@ def run_tests(self):
120
145
"pytest-timeout" ,
121
146
"pytest-xdist" ,
122
147
"lz4"
123
- ],
148
+ ],
124
149
entry_points = {'console_scripts' : [
125
150
'arctic_init_library = arctic.scripts.arctic_init_library:main' ,
126
151
'arctic_list_libraries = arctic.scripts.arctic_list_libraries:main' ,
0 commit comments