from Cython.Distutils import build_ext as cython_build_ext from distutils.extension import Extension as DistutilsExtension if 'build_ext' in setup_args['cmdclass']: raise ValueError('We need to put the Cython build_ext in ' 'cmd_classes, but it is already defined.') setup_args['cmdclass']['build_ext'] = cython_build_ext include_dirs.append(numpy.get_include()) libraries.append(numpy.get_include()) ext_modules.append( DistutilsExtension( "shapely.vectorized._vectorized", sources=["shapely/vectorized/_vectorized.pyx"], include_dirs=include_dirs, library_dirs=library_dirs, libraries=libraries, extra_link_args=extra_link_args, )) except ImportError: log.info("Numpy or Cython not available, shapely.vectorized submodule " "not being built.") try: # try building with speedups existing_build_ext = setup_args['cmdclass'].\ get('build_ext', distutils_build_ext) setup_args['cmdclass']['build_ext'] = \ construct_build_ext(existing_build_ext) setup(ext_modules=ext_modules, **setup_args) except BuildFailed as ex: