@@ -311,7 +311,6 @@ class CheckSDist(sdist_class):
311311 'pandas/_libs/missing.pyx' ,
312312 'pandas/_libs/reduction.pyx' ,
313313 'pandas/_libs/testing.pyx' ,
314- 'pandas/_libs/window.pyx' ,
315314 'pandas/_libs/skiplist.pyx' ,
316315 'pandas/_libs/sparse.pyx' ,
317316 'pandas/_libs/parsers.pyx' ,
@@ -331,19 +330,28 @@ class CheckSDist(sdist_class):
331330 'pandas/_libs/writers.pyx' ,
332331 'pandas/io/sas/sas.pyx' ]
333332
333+ _cpp_pyxfiles = ['pandas/_libs/window.pyx' ,
334+ 'pandas/io/msgpack/_packer.pyx' ,
335+ 'pandas/io/msgpack/_unpacker.pyx' ]
336+
334337 def initialize_options (self ):
335338 sdist_class .initialize_options (self )
336339
337340 def run (self ):
338341 if 'cython' in cmdclass :
339342 self .run_command ('cython' )
340343 else :
341- for pyxfile in self ._pyxfiles :
342- cfile = pyxfile [:- 3 ] + 'c'
343- msg = ("C-source file '{source}' not found.\n "
344- "Run 'setup.py cython' before sdist." .format (
345- source = cfile ))
346- assert os .path .isfile (cfile ), msg
344+ # If we are not running cython then
345+ # compile the extensions correctly
346+ pyx_files = [(self ._pyxfiles , 'c' ), (self ._cpp_pyxfiles , 'cpp' )]
347+
348+ for pyxfiles , extension in pyx_files :
349+ for pyxfile in pyxfiles :
350+ sourcefile = pyxfile [:- 3 ] + extension
351+ msg = ("{extension}-source file '{source}' not found.\n "
352+ "Run 'setup.py cython' before sdist." .format (
353+ source = sourcefile , extension = extension ))
354+ assert os .path .isfile (sourcefile ), msg
347355 sdist_class .run (self )
348356
349357
@@ -417,6 +425,11 @@ def get_tag(self):
417425 cmdclass ['build_src' ] = DummyBuildSrc
418426 cmdclass ['build_ext' ] = CheckingBuildExt
419427
428+ if sys .byteorder == 'big' :
429+ endian_macro = [('__BIG_ENDIAN__' , '1' )]
430+ else :
431+ endian_macro = [('__LITTLE_ENDIAN__' , '1' )]
432+
420433lib_depends = ['inference' ]
421434
422435
@@ -453,6 +466,7 @@ def pxd(name):
453466 'pandas/_libs/src/datetime/np_datetime_strings.h' ]
454467np_datetime_sources = ['pandas/_libs/src/datetime/np_datetime.c' ,
455468 'pandas/_libs/src/datetime/np_datetime_strings.c' ]
469+
456470tseries_depends = np_datetime_headers + ['pandas/_libs/tslibs/np_datetime.pxd' ]
457471
458472# some linux distros require it
@@ -618,17 +632,42 @@ def pxd(name):
618632 '_libs.window' : {
619633 'pyxfile' : '_libs/window' ,
620634 'pxdfiles' : ['_libs/skiplist' , '_libs/src/util' ],
621- 'language' : 'c++' },
635+ 'language' : 'c++' ,
636+ 'suffix' : '.cpp' },
622637 '_libs.writers' : {
623638 'pyxfile' : '_libs/writers' ,
624639 'pxdfiles' : ['_libs/src/util' ]},
625640 'io.sas._sas' : {
626- 'pyxfile' : 'io/sas/sas' }}
641+ 'pyxfile' : 'io/sas/sas' },
642+ 'io.msgpack._packer' : {
643+ 'macros' : endian_macro ,
644+ 'depends' : ['pandas/_libs/src/msgpack/pack.h' ,
645+ 'pandas/_libs/src/msgpack/pack_template.h' ],
646+ 'include' : ['pandas/_libs/src/msgpack' ] + common_include ,
647+ 'language' : 'c++' ,
648+ 'suffix' : '.cpp' ,
649+ 'pyxfile' : 'io/msgpack/_packer' ,
650+ 'subdir' : 'io/msgpack' },
651+ 'io.msgpack._unpacker' : {
652+ 'depends' : ['pandas/_libs/src/msgpack/unpack.h' ,
653+ 'pandas/_libs/src/msgpack/unpack_define.h' ,
654+ 'pandas/_libs/src/msgpack/unpack_template.h' ],
655+ 'macros' : endian_macro ,
656+ 'include' : ['pandas/_libs/src/msgpack' ] + common_include ,
657+ 'language' : 'c++' ,
658+ 'suffix' : '.cpp' ,
659+ 'pyxfile' : 'io/msgpack/_unpacker' ,
660+ 'subdir' : 'io/msgpack'
661+ }
662+ }
627663
628664extensions = []
629665
630666for name , data in ext_data .items ():
631- sources = [srcpath (data ['pyxfile' ], suffix = suffix , subdir = '' )]
667+ source_suffix = suffix if suffix == '.pyx' else data .get ('suffix' , '.c' )
668+
669+ sources = [srcpath (data ['pyxfile' ], suffix = source_suffix , subdir = '' )]
670+
632671 pxds = [pxd (x ) for x in data .get ('pxdfiles' , [])]
633672 if suffix == '.pyx' and pxds :
634673 sources .extend (pxds )
@@ -642,46 +681,11 @@ def pxd(name):
642681 depends = data .get ('depends' , []),
643682 include_dirs = include ,
644683 language = data .get ('language' , 'c' ),
684+ define_macros = data .get ('macros' , []),
645685 extra_compile_args = extra_compile_args )
646686
647687 extensions .append (obj )
648688
649- # ----------------------------------------------------------------------
650- # msgpack
651-
652- if sys .byteorder == 'big' :
653- macros = [('__BIG_ENDIAN__' , '1' )]
654- else :
655- macros = [('__LITTLE_ENDIAN__' , '1' )]
656-
657- msgpack_include = ['pandas/_libs/src/msgpack' ] + common_include
658- msgpack_suffix = suffix if suffix == '.pyx' else '.cpp'
659- unpacker_depends = ['pandas/_libs/src/msgpack/unpack.h' ,
660- 'pandas/_libs/src/msgpack/unpack_define.h' ,
661- 'pandas/_libs/src/msgpack/unpack_template.h' ]
662-
663- packer_ext = Extension ('pandas.io.msgpack._packer' ,
664- depends = ['pandas/_libs/src/msgpack/pack.h' ,
665- 'pandas/_libs/src/msgpack/pack_template.h' ],
666- sources = [srcpath ('_packer' ,
667- suffix = msgpack_suffix ,
668- subdir = 'io/msgpack' )],
669- language = 'c++' ,
670- include_dirs = msgpack_include ,
671- define_macros = macros ,
672- extra_compile_args = extra_compile_args )
673- unpacker_ext = Extension ('pandas.io.msgpack._unpacker' ,
674- depends = unpacker_depends ,
675- sources = [srcpath ('_unpacker' ,
676- suffix = msgpack_suffix ,
677- subdir = 'io/msgpack' )],
678- language = 'c++' ,
679- include_dirs = msgpack_include ,
680- define_macros = macros ,
681- extra_compile_args = extra_compile_args )
682- extensions .append (packer_ext )
683- extensions .append (unpacker_ext )
684-
685689# ----------------------------------------------------------------------
686690# ujson
687691
0 commit comments