ext = Extension(**ext_args)
    config['ext_modules'].append(ext)

    sources = ['convolve.pyf','src/convolve.c']
    sources = [os.path.join(local_path,x) for x in sources]
    ext_args = {}
    dict_append(ext_args,
                name = dot_join(parent_package,package_name,'convolve'),
                sources = sources,
                libraries = ['dfftpack'])
    if fftw_info:
        dict_append(ext_args,**fftw_info)
    if djbfft_info:
        dict_append(ext_args,**djbfft_info)
    ext = Extension(**ext_args)
    config['ext_modules'].append(ext)

    return config

if __name__ == '__main__':
    from scipy_distutils.core import setup
    from fftpack_version import fftpack_version

    setup(version=fftpack_version,
          description='fftpack - Discrete Fourier Transform package',
          author='Pearu Peterson',
          author_email = '*****@*****.**',
          maintainer_email = '*****@*****.**',
          license = 'SciPy License (BSD Style)',
          **configuration(parent_path=''))
from scipy_distutils.core import setup, Extension

expand_sh = lambda path: expanduser(expandvars(path))

# Additional directories for libraries (besides the compiler's defaults)
fc_vendor = os.environ.get("FC_VENDOR", "Gnu").lower()
library_dirs = ["~/usr/lib/" + fc_vendor]

# Modify default arguments (if none are supplied) to install in ~/usr
if len(sys.argv) == 1:
    default_args = "install --home=~/usr"
    print "*** Adding default arguments to setup:", default_args
    sys.argv += default_args.split()  # it must be a list

# Additional options specific to f2py:
f2py_options = []
if debug_capi:
    f2py_options.append("--debug-capi")

# Define the extension module(s)
extension = Extension(
    name=name,
    sources=sources,
    libraries=libraries,
    library_dirs=map(expand_sh, library_dirs),
    f2py_options=f2py_options,
)

# Call the actual building/installation routine, in usual distutils form.
setup(name=name, description=description, author=author, author_email=author_email, ext_modules=[extension])
def get_package_config(name):
    sys.path.insert(0,os.path.join('scipy_core',name))
    try:
        mod = __import__('setup_'+name)
        config = mod.configuration()
    finally:
        del sys.path[0]
    return config

if __name__ == '__main__':
    extra_packages = []
    try: import scipy_base
    except ImportError: extra_packages.append('scipy_base')
    try: import scipy_test
    except ImportError: extra_packages.append('scipy_test')
    try: import scipy_distutils
    except ImportError:
        extra_packages.append('scipy_distutils')
        sys.path.insert(0,'scipy_core')

    from scipy_distutils.core import setup
    from scipy_distutils.misc_util import merge_config_dicts
    from special_version import special_version

    config_dict = merge_config_dicts([configuration(parent_path='')] + \
                                     map(get_package_config,extra_packages))

    setup(version=special_version,
          **config_dict)

Exemple #4
0
#!/usr/bin/env python


def configuration(parent_package='', parent_path=None):

    # The following three lines constitute minimal contents
    # of configuration(..) that is suitable for pure Python
    # packages.
    package = 'pad'
    from scipy_distutils.misc_util import default_config_dict
    config = default_config_dict(package, parent_package)

    return config


if __name__ == '__main__':
    from scipy_distutils.core import setup
    setup(**configuration())
Exemple #5
0
def run_compile():
    """
    Do it all in one call!
    """
    import tempfile,os,shutil

    i = sys.argv.index('-c')
    del sys.argv[i]

    remove_build_dir = 0
    try: i = sys.argv.index('--build-dir')
    except ValueError: i=None
    if i is not None:
        build_dir = sys.argv[i+1]
        del sys.argv[i+1]
        del sys.argv[i]
    else:
        remove_build_dir = 1
        build_dir = os.path.join(tempfile.mktemp())

    sysinfo_flags = filter(re.compile(r'[-][-]link[-]').match,sys.argv[1:])
    sys.argv = filter(lambda a,flags=sysinfo_flags:a not in flags,sys.argv)
    if sysinfo_flags:
        sysinfo_flags = [f[7:] for f in sysinfo_flags]

    f2py_flags = filter(re.compile(r'[-][-]((no[-]|)(wrap[-]functions|lower)|debug[-]capi|quiet)|[-]include').match,sys.argv[1:])
    sys.argv = filter(lambda a,flags=f2py_flags:a not in flags,sys.argv)
    f2py_flags2 = []
    fl = 0
    for a in sys.argv[1:]:
        if a in ['only:','skip:']:
            fl = 1
        elif a==':':
            fl = 0
        if fl or a==':':
            f2py_flags2.append(a)
    if f2py_flags2 and f2py_flags2[-1]!=':':
        f2py_flags2.append(':')
    f2py_flags.extend(f2py_flags2)

    sys.argv = filter(lambda a,flags=f2py_flags2:a not in flags,sys.argv)
    
    flib_flags = filter(re.compile(r'[-][-]((f(90)?compiler([-]exec|)|compiler)=|help[-]compiler)').match,sys.argv[1:])
    sys.argv = filter(lambda a,flags=flib_flags:a not in flags,sys.argv)
    fc_flags = filter(re.compile(r'[-][-]((f(77|90)(flags|exec)|opt|arch)=|(debug|noopt|noarch|help[-]fcompiler))').match,sys.argv[1:])
    sys.argv = filter(lambda a,flags=fc_flags:a not in flags,sys.argv)

    if scipy_distutils_version[:5]>='0.2.2':
        del_list = []
        for s in flib_flags:
            v = '--help-compiler'
            if s==v:
                nv = '--help-fcompiler'
                print v,'is depreciated. Use',nv,'instead.'
                fc_flags.append(nv)
                del_list.append(s)
                continue
            v = '--fcompiler='
            if s[:len(v)]==v:
                import scipy_distutils.fcompiler
                allowed_keys = scipy_distutils.fcompiler.fcompiler_class.keys()
                nv = ov = s[len(v):].lower()
                if ov not in allowed_keys:
                    vmap = {} # XXX
                    try:
                        nv = vmap[ov]
                    except KeyError:
                        if ov not in vmap.values():
                            print 'Unknown vendor: "%s"' % (s[len(v):])
                    nv = ov
                i = flib_flags.index(s)
                flib_flags[i] = '--fcompiler=' + nv
                continue
            v = '--fcompiler-exec='
            if s[:len(v)]==v:
                fc_flags.append('--f77exec='+s[len(v):])
                print v+' is depreciated. Use "%s" instead.' % (fc_flags[-1])
                del_list.append(s)
                continue
            v = '--f90compiler-exec='
            if s[:len(v)]==v:
                fc_flags.append('--f90exec='+s[len(v):])
                print v+' is depreciated. Use "%s" instead.' % (fc_flags[-1])
                del_list.append(s)
                continue
        for s in del_list:
            i = flib_flags.index(s)
            del flib_flags[i]
        assert len(flib_flags)<=2,`flib_flags`
    setup_flags = filter(re.compile(r'[-][-](verbose)').match,sys.argv[1:])
    sys.argv = filter(lambda a,flags=setup_flags:a not in flags,sys.argv)
    if '--quiet' in f2py_flags:
        setup_flags.append('--quiet')

    modulename = 'untitled'
    sources = sys.argv[1:]
    if '-m' in sys.argv:
        i = sys.argv.index('-m')
        modulename = sys.argv[i+1]
        del sys.argv[i+1],sys.argv[i]
        sources = sys.argv[1:]
    elif scipy_distutils_version[:5]>='0.2.2':
        from scipy_distutils.command.build_src import get_f2py_modulename
        pyf_files,sources = filter_files('','[.]pyf([.]src|)',sources)
        sources = pyf_files + sources
        for f in pyf_files:
            modulename = get_f2py_modulename(f)
            if modulename:
                break

    extra_objects, sources = filter_files('','[.](o|a|so)',sources)
    include_dirs, sources = filter_files('-I','',sources,remove_prefix=1)
    library_dirs, sources = filter_files('-L','',sources,remove_prefix=1)
    libraries, sources = filter_files('-l','',sources,remove_prefix=1)
    undef_macros, sources = filter_files('-U','',sources,remove_prefix=1)
    define_macros, sources = filter_files('-D','',sources,remove_prefix=1)
    using_numarray = 0
    for i in range(len(define_macros)):
        name_value = string.split(define_macros[i],'=',1)
        if len(name_value)==1:
            name_value.append(None)
            if name_value[0]=='NUMARRAY':
                using_numarray = 1
        if len(name_value)==2:
            define_macros[i] = tuple(name_value)
        else:
            print 'Invalid use of -D:',name_value

    from scipy_distutils.system_info import get_info
    num_include_dir = None
    if using_numarray:
        try:
            import numarray
            n = 'numarray'
            p = get_prefix(numarray)
            import numarray.numinclude as numinclude
            include_dirs.append(numinclude.include_dir)
        except ImportError:
            print 'Failed to import numarray:',sys.exc_value
            raise ImportError,'Must have numarray installed.'
        num_info = get_info('numarray')
    else:
        try:
            import Numeric
            n = 'Numeric'
            p = get_prefix(Numeric)
        except ImportError:
            print 'Failed to import Numeric:',sys.exc_value
            raise ImportError,'Must have Numeric installed.'
        num_info = get_info('NumPy')
    if num_info:
        include_dirs.extend(num_info.get('include_dirs',[]))

    from scipy_distutils.core import setup,Extension
    ext_args = {'name':modulename,'sources':sources,
                'include_dirs': include_dirs,
                'library_dirs': library_dirs,
                'libraries': libraries,
                'define_macros': define_macros,
                'undef_macros': undef_macros,
                'extra_objects': extra_objects,
                'f2py_options': f2py_flags,
                }

    if sysinfo_flags:
        from scipy_distutils.misc_util import dict_append
        for n in sysinfo_flags:
            i = get_info(n)
            if not i:
                outmess('No %s resources found in system'\
                        ' (try `f2py --help-link`)\n' % (`n`))
            dict_append(ext_args,**i)

    ext = Extension(**ext_args)
    sys.argv = [sys.argv[0]] + setup_flags
    sys.argv.extend(['build',
                     '--build-temp',build_dir,
                     '--build-base',build_dir,
                     '--build-platlib','.'])
    if fc_flags:
        sys.argv.extend(['config_fc']+fc_flags)
    if flib_flags:
        if scipy_distutils_version[:5]>='0.2.2':
            sys.argv.extend(['build_ext']+flib_flags)
        else:
            sys.argv.extend(['build_flib']+flib_flags)

    setup(ext_modules = [ext])

    if remove_build_dir and os.path.exists(build_dir):
        outmess('Removing build directory %s\n'%(build_dir))
        shutil.rmtree(build_dir)
    # iterative methods
    methods = ['BiCGREVCOM.f.src',
               'BiCGSTABREVCOM.f.src',
               'CGREVCOM.f.src',
               'CGSREVCOM.f.src',
#               'ChebyREVCOM.f.src',
               'GMRESREVCOM.f.src',
#               'JacobiREVCOM.f.src',
               'QMRREVCOM.f.src',
#               'SORREVCOM.f.src'
               ]
    Util = ['STOPTEST2.f.src','getbreak.f.src']
    sources = Util + methods + ['_iterative.pyf.src']
    ext_args = {
        'name': dot_join(parent_package,package,'_iterative'),
        'sources': [local_join('iterative',x) for x in sources]
        }
    dict_append(ext_args, **lapack_opt)
    ext = Extension(**ext_args)
    config['ext_modules'].append(ext)    

    return config

if __name__ == '__main__':
    from scipy_distutils.core import setup
    from linalg_version import linalg_version

    setup(version=linalg_version,
          **configuration(parent_path=''))
library_dirs = ["~/usr/lib/" + fc_vendor]

# Modify default arguments (if none are supplied) to install in ~/usr
if len(sys.argv) == 1:
    default_args = 'install --home=~/usr'
    print '*** Adding default arguments to setup:', default_args
    sys.argv += default_args.split()  # it must be a list

# Additional options specific to f2py:
f2py_options = []
if debug_capi:
    f2py_options.append('--debug-capi')

# Define the extension module(s)
extension = Extension(
    name=name,
    sources=sources,
    libraries=libraries,
    library_dirs=map(expand_sh, library_dirs),
    f2py_options=f2py_options,
)

# Call the actual building/installation routine, in usual distutils form.
setup(
    name=name,
    description=description,
    author=author,
    author_email=author_email,
    ext_modules=[extension],
)
Exemple #8
0
#!/usr/bin/env python

def configuration(parent_package='', parent_path=None):

    # The following three lines constitute minimal contents
    # of configuration(..) that is suitable for pure Python
    # packages.
    package = 'pad'
    from scipy_distutils.misc_util import default_config_dict
    config = default_config_dict(package,parent_package)

    return config

if __name__ == '__main__':
    from scipy_distutils.core import setup
    setup(**configuration())
#!/usr/bin/env python
# File: setup_example.py

from scipy_distutils.core import Extension

ext1 = Extension(name = 'scalar',
                 sources = ['scalar.f'])
ext2 = Extension(name = 'fib2',
                 sources = ['fib2.pyf','fib1.f'])

if __name__ == "__main__":
    from scipy_distutils.core import setup
    setup(name = 'f2py_example',
          description       = "F2PY Users Guide examples",
          author            = "Pearu Peterson",
          author_email      = "*****@*****.**",
          ext_modules = [ext1,ext2]
          )
# End of setup_example.py