@@ -24,23 +24,6 @@ def is_platform_windows():
24
24
return sys .platform == 'win32' or sys .platform == 'cygwin'
25
25
26
26
27
- def is_platform_linux ():
28
- return sys .platform == 'linux2'
29
-
30
-
31
- def is_platform_mac ():
32
- return sys .platform == 'darwin'
33
-
34
-
35
- min_cython_ver = '0.28.2'
36
- try :
37
- import Cython
38
- ver = Cython .__version__
39
- _CYTHON_INSTALLED = ver >= LooseVersion (min_cython_ver )
40
- except ImportError :
41
- _CYTHON_INSTALLED = False
42
-
43
-
44
27
min_numpy_ver = '1.9.0'
45
28
setuptools_kwargs = {
46
29
'install_requires' : [
@@ -53,24 +36,29 @@ def is_platform_mac():
53
36
}
54
37
55
38
39
+ min_cython_ver = '0.28.2'
40
+ try :
41
+ import Cython
42
+ ver = Cython .__version__
43
+ _CYTHON_INSTALLED = ver >= LooseVersion (min_cython_ver )
44
+ except ImportError :
45
+ _CYTHON_INSTALLED = False
46
+
47
+ # The import of Extension must be after the import of Cython, otherwise
48
+ # we do not get the appropriately patched class.
49
+ # See https://cython.readthedocs.io/en/latest/src/reference/compilation.html
56
50
from distutils .extension import Extension # noqa:E402
57
51
from distutils .command .build import build # noqa:E402
58
- from distutils .command .build_ext import build_ext as _build_ext # noqa:E402
59
52
60
53
try :
61
54
if not _CYTHON_INSTALLED :
62
55
raise ImportError ('No supported version of Cython installed.' )
63
- try :
64
- from Cython .Distutils .old_build_ext import old_build_ext as _build_ext # noqa:F811,E501
65
- except ImportError :
66
- # Pre 0.25
67
- from Cython .Distutils import build_ext as _build_ext
56
+ from Cython .Distutils .old_build_ext import old_build_ext as _build_ext
68
57
cython = True
69
58
except ImportError :
59
+ from distutils .command .build_ext import build_ext as _build_ext
70
60
cython = False
71
-
72
-
73
- if cython :
61
+ else :
74
62
try :
75
63
try :
76
64
from Cython import Tempita as tempita
@@ -103,27 +91,30 @@ def is_platform_mac():
103
91
104
92
105
93
class build_ext (_build_ext ):
106
- def build_extensions (self ):
94
+ @classmethod
95
+ def render_templates (cls , pxifiles ):
96
+ for pxifile in pxifiles :
97
+ # build pxifiles first, template extension must be .pxi.in
98
+ assert pxifile .endswith ('.pxi.in' )
99
+ outfile = pxifile [:- 3 ]
107
100
108
- # if builing from c files, don't need to
109
- # generate template output
110
- if cython :
111
- for pxifile in _pxifiles :
112
- # build pxifiles first, template extension must be .pxi.in
113
- assert pxifile .endswith ('.pxi.in' )
114
- outfile = pxifile [:- 3 ]
115
-
116
- if (os .path .exists (outfile ) and
117
- os .stat (pxifile ).st_mtime < os .stat (outfile ).st_mtime ):
118
- # if .pxi.in is not updated, no need to output .pxi
119
- continue
101
+ if (os .path .exists (outfile ) and
102
+ os .stat (pxifile ).st_mtime < os .stat (outfile ).st_mtime ):
103
+ # if .pxi.in is not updated, no need to output .pxi
104
+ continue
120
105
121
- with open (pxifile , "r" ) as f :
122
- tmpl = f .read ()
123
- pyxcontent = tempita .sub (tmpl )
106
+ with open (pxifile , "r" ) as f :
107
+ tmpl = f .read ()
108
+ pyxcontent = tempita .sub (tmpl )
124
109
125
- with open (outfile , "w" ) as f :
126
- f .write (pyxcontent )
110
+ with open (outfile , "w" ) as f :
111
+ f .write (pyxcontent )
112
+
113
+ def build_extensions (self ):
114
+ # if building from c files, don't need to
115
+ # generate template output
116
+ if cython :
117
+ self .render_templates (_pxifiles )
127
118
128
119
numpy_incl = pkg_resources .resource_filename ('numpy' , 'core/include' )
129
120
@@ -360,7 +351,6 @@ def run(self):
360
351
class CheckingBuildExt (build_ext ):
361
352
"""
362
353
Subclass build_ext to get clearer report if Cython is necessary.
363
-
364
354
"""
365
355
366
356
def check_cython_extensions (self , extensions ):
@@ -379,9 +369,11 @@ def build_extensions(self):
379
369
380
370
381
371
class CythonCommand (build_ext ):
382
- """Custom distutils command subclassed from Cython.Distutils.build_ext
372
+ """
373
+ Custom distutils command subclassed from Cython.Distutils.build_ext
383
374
to compile pyx->c, and stop there. All this does is override the
384
- C-compile method build_extension() with a no-op."""
375
+ C-compile method build_extension() with a no-op.
376
+ """
385
377
def build_extension (self , ext ):
386
378
pass
387
379
@@ -445,7 +437,6 @@ def srcpath(name=None, suffix='.pyx', subdir='src'):
445
437
lib_depends .append ('pandas/_libs/src/util.pxd' )
446
438
else :
447
439
lib_depends = []
448
- plib_depends = []
449
440
450
441
common_include = ['pandas/_libs/src/klib' , 'pandas/_libs/src' ]
451
442
@@ -471,8 +462,6 @@ def pxd(name):
471
462
472
463
tseries_depends = np_datetime_headers + ['pandas/_libs/tslibs/np_datetime.pxd' ]
473
464
474
- # some linux distros require it
475
- libraries = ['m' ] if not is_platform_windows () else []
476
465
477
466
ext_data = {
478
467
'_libs.algos' : {
0 commit comments