def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration('convolve',parent_package,top_path, package_path='lib') config.add_extension('_correlate', sources=["src/_correlatemodule.c"], define_macros = [('NUMPY', '1')], include_dirs = [numpy.get_numarray_include()]) config.add_extension('_lineshape', sources=["src/_lineshapemodule.c"], define_macros = [('NUMPY', '1')], include_dirs = [numpy.get_numarray_include()]) config.add_data_dir('tests') return config
def get_dirac(): link_args = ['-framework', 'Carbon'] if is_mac else [] compile_args = [] if is_windows else ['-Wno-unused'] pydirac = os.path.join('external', 'pydirac225') lib_sources = [ os.path.join(pydirac, 'diracmodule.cpp'), os.path.join(pydirac, 'source', 'Dirac_LE.cpp') ] platform = os.uname()[0] if hasattr(os, 'uname') else 'Windows' libname = 'Dirac64' if platform == 'Linux' and os.uname( )[-1] == 'x86_64' else 'Dirac' return Extension( 'dirac', sources=lib_sources, extra_compile_args=compile_args, include_dirs=[ 'source', numpy.get_include(), numpy.get_numarray_include() ], libraries=[libname], library_dirs=[os.path.join(pydirac, 'libs', platform)], extra_link_args=link_args, )
def get_soundtouch(): sources = ['AAFilter.cpp', 'FIFOSampleBuffer.cpp', 'FIRFilter.cpp', 'RateTransposer.cpp', 'SoundTouch.cpp', 'TDStretch.cpp', 'BPMDetect.cpp', 'PeakFinder.cpp', 'mmx_optimized.cpp', 'sse_optimized.cpp' ] extra_compile_args = [] if is_linux or is_mac: sources += ['cpu_detect_x86_gcc.cpp'] extra_compile_args = ['-O3', '-Wno-unused'] else: sources += ['cpu_detect_x86_win.cpp', '3dnow_win.cpp'] pysoundtouch = os.path.join('external', 'pysoundtouch14', 'libsoundtouch') lib_sources = [os.path.join(pysoundtouch, i) for i in sources] lib_sources += [os.path.join('external', 'pysoundtouch14', 'soundtouchmodule.cpp')] return Extension('soundtouch', sources = lib_sources, extra_compile_args = extra_compile_args, include_dirs = [numpy.get_include(), numpy.get_numarray_include()] )
def get_soundtouch(): sources = [ 'AAFilter.cpp', 'FIFOSampleBuffer.cpp', 'FIRFilter.cpp', 'RateTransposer.cpp', 'SoundTouch.cpp', 'TDStretch.cpp', 'BPMDetect.cpp', 'PeakFinder.cpp', 'mmx_optimized.cpp', 'sse_optimized.cpp' ] extra_compile_args = [] if is_linux or is_mac: sources += ['cpu_detect_x86_gcc.cpp'] extra_compile_args = ['-fcheck-new', '-O3', '-Wno-unused'] else: sources += ['cpu_detect_x86_win.cpp', '3dnow_win.cpp'] pysoundtouch = os.path.join('external', 'pysoundtouch14', 'libsoundtouch') lib_sources = [os.path.join(pysoundtouch, i) for i in sources] lib_sources += [ os.path.join('external', 'pysoundtouch14', 'soundtouchmodule.cpp') ] return Extension( 'soundtouch', sources=lib_sources, extra_compile_args=extra_compile_args, include_dirs=[numpy.get_include(), numpy.get_numarray_include()])
def get_action(): cAction = os.path.join('external', 'cAction') compile_args = [] if is_windows else ['-Wno-unused'] return Extension("cAction", sources = [os.path.join(cAction, 'actionmodule.cpp')], extra_compile_args = compile_args, include_dirs = [numpy.get_include(), numpy.get_numarray_include()], )
def test_include_dirs(self): """As a sanity check, just test that get_include and get_numarray_include include something reasonable. Somewhat related to ticket #1405.""" include_dirs = [np.get_include(), np.get_numarray_include()] for path in include_dirs: assert_(isinstance(path, (str, unicode))) assert_(path != '')
def test_include_dirs(self): """As a sanity check, just test that get_include and get_numarray_include include something reasonable. Somewhat related to ticket #1405.""" include_dirs = [np.get_include(), np.get_numarray_include()] for path in include_dirs: assert_(isinstance(path, str)) assert_(path != '')
def get_action(): cAction = os.path.join('external', 'cAction') compile_args = [] if is_windows else ['-Wno-unused'] return Extension( "cAction", sources=[os.path.join(cAction, 'actionmodule.cpp')], extra_compile_args=compile_args, include_dirs=[numpy.get_include(), numpy.get_numarray_include()], )
def get_dirac(): link_args = ['-framework', 'Carbon'] if is_mac else [] compile_args = [] if is_windows else ['-Wno-unused'] pydirac = os.path.join('external', 'pydirac225') lib_sources = [os.path.join(pydirac, 'diracmodule.cpp'), os.path.join(pydirac, 'source', 'Dirac_LE.cpp')] platform = os.uname()[0] if hasattr(os, 'uname') else 'Windows' libname = 'Dirac64' if platform == 'Linux' and os.uname()[-1] == 'x86_64' else 'Dirac' return Extension('dirac', sources = lib_sources, extra_compile_args = compile_args, include_dirs = ['source', numpy.get_include(), numpy.get_numarray_include()], libraries = [libname], library_dirs = [os.path.join(pydirac, 'libs', platform)], extra_link_args = link_args, )
# created 4/21/2010 by Jason # http://docs.python.org/extending/building.html from distutils.core import setup, Extension import os import numpy platform = os.uname()[0] if hasattr(os, 'uname') else 'Windows' link_args = ['-framework', 'Carbon'] if platform == 'Darwin' else [] dirac = Extension( "dirac", sources = ['diracmodule.cpp', 'source/Dirac_LE.cpp'], extra_compile_args = [], include_dirs = ['source', numpy.get_include(), numpy.get_numarray_include()], libraries = ['Dirac'], library_dirs = [os.path.join('libs', platform)], extra_link_args = link_args, depends=[__file__] # force rebuild whenever this script is changed. ) setup( name="dirac", version = '0.1', description = 'Python interface to Dirac LE', author = 'Tristan Jehan', author_email = '*****@*****.**', url = 'http://code.echonest.com/p/echo-nest-remix', ext_modules=[dirac], requires=['numpy'] )
# created 5/11/2010 by Jason from distutils.core import setup, Extension import os, sys import numpy cAction = Extension( "cAction", sources=['actionmodule.cpp'], extra_compile_args=[], include_dirs=[numpy.get_include(), numpy.get_numarray_include()], depends=[__file__] # force rebuild whenever this script is changed. ) setup(name="cAction", version='0.1', description='c implementation of algorithms from action.py', author='Jason Sundram', author_email='*****@*****.**', url='http://code.echonest.com/p/echo-nest-remix', ext_modules=[cAction], requires=['numpy'])
def compileAutoLib(self, libsources=[], libdirs=[]): """compileAutoLib generates a python extension DLL with continuer and vector field compiled and linked. libsources list allows additional library sources to be linked. libdirs list allows additional directories to be searched for precompiled libraries.""" if os.path.isfile( os.path.join(os.getcwd(), "_auto" + self._vf_filename_ext + self._dllext)): # then DLL file already exists and we can't overwrite it at this # time proceed = False print("\n") print( "-----------------------------------------------------------") print("Present limitation of Python: Cannot rebuild library") print("without exiting Python and deleting the shared library") print(" " + str( os.path.join(os.getcwd(), "_auto" + self._vf_filename_ext + self._dllext))) print("by hand! If you made any changes to the system you should") print("not proceed with running the integrator until you quit") print("and rebuild.") print( "-----------------------------------------------------------") print("\n") else: proceed = True if not proceed: print("Did not compile shared library.") return if self._autoMod is not None: self.forceAutoLibRefresh() vffile = os.path.join(self._compilation_tempdir, self._vf_file) try: ifacefile_orig = open( os.path.join(self._compilation_sourcedir, "automod.i"), 'r') ifacefile_copy = open( os.path.join(self._compilation_tempdir, "auto_" + self._vf_file[:-2] + ".i"), 'w') firstline = ifacefile_orig.readline() ifacefile_copy.write('%module auto_' + self._vf_file[:-2] + '\n') iffilestr = ifacefile_orig.read() ifacefile_copy.write(iffilestr) ifacefile_orig.close() ifacefile_copy.close() except IOError: print("automod.i copying error in auto compilation directory") raise swigfile = os.path.join(self._compilation_tempdir, "auto" + self._vf_filename_ext + ".i") automodfile = os.path.join(self._compilation_sourcedir, "automod.c") interfacefile = os.path.join(self._compilation_sourcedir, "interface.c") # source files if not (all([ os.path.isfile(os.path.join(self._compilation_tempdir, sf)) for sf in [ 'auto' + self._vf_filename_ext + '_wrap.o', 'auto' + self._vf_filename_ext + '.py', '_auto' + self._vf_filename_ext + '.def' ] ])): modfilelist = [swigfile] else: modfilelist = [] # FOR DIST (ADD) modfilelist.extend([os.path.join(self._compilation_sourcedir, "../src/"+x) \ for x in ['auto.c','autlib1.c','autlib2.c','autlib3.c','autlib4.c','autlib5.c', \ 'eispack.c', 'conpar.c','setubv.c','reduce.c','dmatrix.c','fcon.c','libf2c/cabs.c','libf2c/d_lg10.c', \ 'libf2c/i_nint.c','libf2c/pow_di.c','libf2c/r_lg10.c','libf2c/z_exp.c','libf2c/d_imag.c', \ 'libf2c/d_sign.c','libf2c/i_dnnt.c','libf2c/pow_dd.c','libf2c/pow_ii.c','libf2c/z_abs.c', \ 'libf2c/z_log.c']]) modfilelist.extend([automodfile, interfacefile, vffile]) # FOR DIST (SUBTRACT) #modfilelist.extend(libsources) # script args script_args = [ '-q', 'build', '--build-lib=.', #+os.getcwd(), # '-t/', '-tauto_temp', #+self._compilation_tempdir, '--build-base=auto_temp' ] #+self._compilation_sourcedir] if self.gensys._compiler != '': script_args.append('-c' + str(self.gensys._compiler)) # include directories for libraries narraydir = get_numarray_include() npydir = get_include() incdirs = [ narraydir, npydir, os.getcwd(), os.path.join(self._compilation_sourcedir, "include"), self._compilation_tempdir, os.path.join(_pydstool_path, "PyCont/auto/src/include") ] incdirs.extend(libdirs) # libraries # FOR DIST (SUBTRACT) #libdirs.append(os.path.join(_pydstool_path, "PyCont/auto/lib")) #libsources.append('auto2000') # Use distutils to perform the compilation of the selected files rout.start() # redirect stdout try: distobject = setup( name="Auto 2000 continuer", author="PyDSTool (automatically generated)", script_args=script_args, ext_modules=[ Extension("_auto" + self._vf_filename_ext, sources=modfilelist, include_dirs=incdirs, extra_compile_args=utils.extra_arch_arg( ['-w', '-D__PYTHON__', '-std=c99']), extra_link_args=utils.extra_arch_arg(['-w']), library_dirs=libdirs + ['./'], libraries=libsources) ]) except: print("\nError occurred in generating Auto system...") print(sys.exc_info()[0], sys.exc_info()[1]) raise RuntimeError rout.stop() # restore stdout try: # move library files into the user's CWD distdestdir = distutil_destination() if swigfile in modfilelist or not \ os.path.isfile(os.path.join(self._compilation_tempdir, "auto"+self._vf_filename_ext+".py")): shutil.move( os.path.join(os.getcwd(), self._compilation_tempdir, distdestdir, "auto_temp", "auto" + self._vf_filename_ext + ".py"), os.path.join(os.getcwd(), "auto" + self._vf_filename_ext + ".py")) except: print("\nError occurred in generating Auto system") print("(while moving library extension modules to CWD)") print(sys.exc_info()[0], sys.exc_info()[1]) raise RuntimeError
try: import numpy print numpy.get_numarray_include() print numpy.get_include() except: pass
""" Distutils script for iqe_wrapper. Yasuhiko Sakakibara - [email protected] Eric Jeschke - [email protected] """ import numpy from distutils.core import setup, Extension import sys if not hasattr(sys, 'version_info') or sys.version_info < (2,2,0,'alpha',0): raise SystemExit, "Python 2.2 or later required to build this module." incs = ["./"] incs.append(numpy.get_numarray_include()) extension = Extension("iqe", ['iqefunc.c', 'indexx.c', 'mrqfit.c', 'gaussj.c', 'covsrt.c', 'sort.c', 'iqe_wrapper.c' ], include_dirs=incs, library_dirs=["./"], libraries =['m']) setup(name = "iqe", version = "0.2", description = "A python wrapper for the eso librtd library functions.",
from distutils.core import setup from distutils.extension import Extension from Cython.Distutils import build_ext import numpy as np extension_modules = Extension( "scipy_tools", sources=["scipy_tools.pyx"], language="c++", ) setup(cmdclass={'build_ext': build_ext}, ext_modules=[extension_modules], include_dirs=[np.get_numarray_include(), np.get_include()])
def compileAutoLib(self, libsources=[], libdirs=[]): """compileAutoLib generates a python extension DLL with continuer and vector field compiled and linked. libsources list allows additional library sources to be linked. libdirs list allows additional directories to be searched for precompiled libraries.""" if os.path.isfile(os.path.join(os.getcwd(), "_auto"+self._vf_filename_ext+self._dllext)): # then DLL file already exists and we can't overwrite it at this # time proceed = False print("\n") print("-----------------------------------------------------------") print("Present limitation of Python: Cannot rebuild library") print("without exiting Python and deleting the shared library") print(" " + str(os.path.join(os.getcwd(), "_auto"+self._vf_filename_ext+self._dllext))) print("by hand! If you made any changes to the system you should") print("not proceed with running the integrator until you quit") print("and rebuild.") print("-----------------------------------------------------------") print("\n") else: proceed = True if not proceed: print("Did not compile shared library.") return if self._autoMod is not None: self.forceAutoLibRefresh() vffile = os.path.join(self._compilation_tempdir, self._vf_file) try: ifacefile_orig = open(os.path.join(self._compilation_sourcedir, "automod.i"), 'r') ifacefile_copy = open(os.path.join(self._compilation_tempdir, "auto_"+self._vf_file[:-2]+".i"), 'w') firstline = ifacefile_orig.readline() ifacefile_copy.write('%module auto_'+self._vf_file[:-2]+'\n') iffilestr = ifacefile_orig.read() ifacefile_copy.write(iffilestr) ifacefile_orig.close() ifacefile_copy.close() except IOError: print("automod.i copying error in auto compilation directory") raise swigfile = os.path.join(self._compilation_tempdir, "auto"+self._vf_filename_ext+".i") automodfile = os.path.join(self._compilation_sourcedir, "automod.c") interfacefile = os.path.join(self._compilation_sourcedir, "interface.c") # source files if not (all([os.path.isfile(os.path.join(self._compilation_tempdir, sf)) for sf in ['auto'+self._vf_filename_ext+'_wrap.o', 'auto'+self._vf_filename_ext+'.py', '_auto'+self._vf_filename_ext+'.def']])): modfilelist = [swigfile] else: modfilelist = [] # FOR DIST (ADD) modfilelist.extend([os.path.join(self._compilation_sourcedir, "../src/"+x) \ for x in ['auto.c','autlib1.c','autlib2.c','autlib3.c','autlib4.c','autlib5.c', \ 'eispack.c', 'conpar.c','setubv.c','reduce.c','dmatrix.c','fcon.c','libf2c/cabs.c','libf2c/d_lg10.c', \ 'libf2c/i_nint.c','libf2c/pow_di.c','libf2c/r_lg10.c','libf2c/z_exp.c','libf2c/d_imag.c', \ 'libf2c/d_sign.c','libf2c/i_dnnt.c','libf2c/pow_dd.c','libf2c/pow_ii.c','libf2c/z_abs.c', \ 'libf2c/z_log.c']]) modfilelist.extend([automodfile, interfacefile, vffile]) # FOR DIST (SUBTRACT) #modfilelist.extend(libsources) # script args script_args = ['-q', 'build', '--build-lib=.', #+os.getcwd(), # '-t/', '-tauto_temp', #+self._compilation_tempdir, '--build-base=auto_temp'] #+self._compilation_sourcedir] if self.gensys._compiler != '': script_args.append('-c'+str(self.gensys._compiler)) # include directories for libraries narraydir = get_numarray_include() npydir = get_include() incdirs = [narraydir, npydir, os.getcwd(), os.path.join(self._compilation_sourcedir,"include"), self._compilation_tempdir, os.path.join(_pydstool_path,"PyCont/auto/src/include")] incdirs.extend(libdirs) # libraries # FOR DIST (SUBTRACT) #libdirs.append(os.path.join(_pydstool_path, "PyCont/auto/lib")) #libsources.append('auto2000') # Use distutils to perform the compilation of the selected files rout.start() # redirect stdout try: distobject = setup(name = "Auto 2000 continuer", author = "PyDSTool (automatically generated)", script_args = script_args, ext_modules = [Extension("_auto"+self._vf_filename_ext, sources=modfilelist, include_dirs=incdirs, extra_compile_args=utils.extra_arch_arg(['-w', '-D__PYTHON__', '-std=c99']), extra_link_args=utils.extra_arch_arg(['-w']), library_dirs=libdirs+['./'], libraries=libsources)]) except: rout.stop() print("\nError occurred in generating Auto system...") print(sys.exc_info()[0], sys.exc_info()[1]) raise RuntimeError rout.stop() # restore stdout try: # move library files into the user's CWD distdestdir = distutil_destination() if swigfile in modfilelist or not \ os.path.isfile(os.path.join(self._compilation_tempdir, "auto"+self._vf_filename_ext+".py")): shutil.move(os.path.join(os.getcwd(), self._compilation_tempdir, distdestdir, "auto_temp", "auto"+self._vf_filename_ext+".py"), os.path.join(os.getcwd(), "auto"+self._vf_filename_ext+".py")) except: print("\nError occurred in generating Auto system") print("(while moving library extension modules to CWD)") print(sys.exc_info()[0], sys.exc_info()[1]) raise RuntimeError
# created 5/11/2010 by Jason from distutils.core import setup, Extension import os, sys import numpy cAction = Extension("cAction", sources = ['actionmodule.cpp'], extra_compile_args = [], include_dirs = [numpy.get_include(), numpy.get_numarray_include()], depends=[__file__] # force rebuild whenever this script is changed. ) setup( name="cAction", version = '0.1', description = 'c implementation of algorithms from action.py', author = 'Jason Sundram', author_email = '*****@*****.**', url = 'http://code.echonest.com/p/echo-nest-remix', ext_modules=[cAction], requires=['numpy'] )