예제 #1
0
def get_extension() -> Extension:
    """Get distutils extension object for this AMICI model package"""

    cxx_flags = ['-std=c++14']
    linker_flags = []

    add_coverage_flags_if_required(cxx_flags, linker_flags)
    add_debug_flags_if_required(cxx_flags, linker_flags)

    h5pkgcfg = get_hdf5_config()

    blaspkgcfg = get_blas_config()
    linker_flags.extend(blaspkgcfg.get('extra_link_args', []))

    libraries = [*get_amici_libs(), *blaspkgcfg['libraries']]
    if hdf5_enabled:
        libraries.extend(['hdf5_hl_cpp', 'hdf5_hl', 'hdf5_cpp', 'hdf5'])

    sources = ['swig/TPL_MODELNAME.i', *get_model_sources()]

    # compiler and linker flags for libamici
    if 'AMICI_CXXFLAGS' in os.environ:
        cxx_flags.extend(os.environ['AMICI_CXXFLAGS'].split(' '))
    if 'AMICI_LDFLAGS' in os.environ:
        linker_flags.extend(os.environ['AMICI_LDFLAGS'].split(' '))

    ext_include_dirs = [
        os.getcwd(),
        os.path.join(amici_path, 'include'),
        os.path.join(amici_path, 'ThirdParty/gsl'),
        os.path.join(amici_path, 'ThirdParty/sundials/include'),
        os.path.join(amici_path, 'ThirdParty/SuiteSparse/include'),
        *h5pkgcfg['include_dirs'], *blaspkgcfg['include_dirs']
    ]

    ext_library_dirs = [
        *h5pkgcfg['library_dirs'], *blaspkgcfg['library_dirs'],
        os.path.join(amici_path, 'libs')
    ]

    # Build shared object
    ext = Extension('TPL_MODELNAME._TPL_MODELNAME',
                    sources=sources,
                    include_dirs=ext_include_dirs,
                    libraries=libraries,
                    library_dirs=ext_library_dirs,
                    swig_opts=[
                        '-c++',
                        '-modern',
                        '-outdir',
                        'TPL_MODELNAME',
                        '-I%s' % os.path.join(amici_path, 'swig'),
                        '-I%s' % os.path.join(amici_path, 'include'),
                    ],
                    extra_compile_args=cxx_flags,
                    extra_link_args=linker_flags)
    return ext
예제 #2
0
def main():
    # Extra compiler flags
    cxx_flags = []
    amici_module_linker_flags = []
    define_macros = []

    add_openmp_flags(cxx_flags=cxx_flags, ldflags=amici_module_linker_flags)

    blaspkgcfg = get_blas_config()
    amici_module_linker_flags.extend(blaspkgcfg['extra_link_args'])
    amici_module_linker_flags.extend(f'-l{lib}'
                                     for lib in blaspkgcfg['libraries'])
    define_macros.extend(blaspkgcfg['define_macros'])

    extension_sources = [
        'amici/amici_wrap.cxx',  # swig interface
    ]

    h5pkgcfg = get_hdf5_config()

    if h5pkgcfg['found']:
        # Manually add linker flags. The libraries passed to Extension will
        # end up in front of the clibs in the linker line and not after, where
        # they are required.
        print("HDF5 library found. Building AMICI with HDF5 support.")
        amici_module_linker_flags.extend([
            f'-l{lib}'
            for lib in ['hdf5_hl_cpp', 'hdf5_hl', 'hdf5_cpp', 'hdf5']
        ])
        define_macros.extend(h5pkgcfg['define_macros'])
    else:
        print("HDF5 library NOT found. Building AMICI WITHOUT HDF5 support.")
        define_macros.append(('AMICI_SWIG_WITHOUT_HDF5', None))

    add_coverage_flags_if_required(
        cxx_flags,
        amici_module_linker_flags,
    )

    add_debug_flags_if_required(
        cxx_flags,
        amici_module_linker_flags,
    )

    # compiler and linker flags for libamici
    if 'AMICI_CXXFLAGS' in os.environ:
        cxx_flags.extend(os.environ['AMICI_CXXFLAGS'].split(' '))
    if 'AMICI_LDFLAGS' in os.environ:
        amici_module_linker_flags.extend(
            os.environ['AMICI_LDFLAGS'].split(' '))

    libamici = setup_clibs.get_lib_amici(h5pkgcfg=h5pkgcfg,
                                         blaspkgcfg=blaspkgcfg,
                                         extra_compiler_flags=cxx_flags)
    libsundials = setup_clibs.get_lib_sundials(extra_compiler_flags=cxx_flags)
    libsuitesparse = setup_clibs.get_lib_suite_sparse(
        extra_compiler_flags=cxx_flags + ['-DDLONG'])

    # Readme as long package description to go on PyPi
    # (https://pypi.org/project/amici/)
    with open(os.path.join(os.path.dirname(__file__), "README.md"),
              "r",
              encoding="utf-8") as fh:
        long_description = fh.read()

    # Build shared object
    amici_module = Extension(
        name='amici._amici',
        sources=extension_sources,
        include_dirs=[
            'amici/include', 'amici/ThirdParty/gsl/',
            *libsundials[1]['include_dirs'],
            *libsuitesparse[1]['include_dirs'], *h5pkgcfg['include_dirs'],
            *blaspkgcfg['include_dirs'],
            np.get_include()
        ],
        # Cannot use here, see above
        # libraries=[
        #    'hdf5_hl_cpp', 'hdf5_hl', 'hdf5_cpp', 'hdf5'
        # ],
        define_macros=define_macros,
        library_dirs=[
            *h5pkgcfg['library_dirs'],
            *blaspkgcfg['library_dirs'],
            'amici/libs',  # clib target directory
        ],
        extra_compile_args=cxx_flags,
        extra_link_args=amici_module_linker_flags)
    # Monkey-patch extension (see
    # `custom_commands.set_compiler_specific_extension_options`)
    amici_module.extra_compile_args_mingw32 = ['-std=c++14']
    amici_module.extra_compile_args_unix = ['-std=c++14']
    amici_module.extra_compile_args_msvc = ['/std:c++14']

    # Install
    setup(
        name='amici',
        cmdclass={
            'install': AmiciInstall,
            'sdist': AmiciSDist,
            'build_ext': AmiciBuildExt,
            'build_clib': AmiciBuildCLib,
            'install_lib': AmiciInstallLib,
            'develop': AmiciDevelop,
        },
        version=__version__,
        description='Advanced multi-language Interface to CVODES and IDAS',
        long_description=long_description,
        long_description_content_type="text/markdown",
        url='https://github.com/AMICI-dev/AMICI',
        author='Fabian Froehlich, Jan Hasenauer, Daniel Weindl and '
        'Paul Stapor',
        author_email='*****@*****.**',
        license='BSD',
        libraries=[libamici, libsundials, libsuitesparse],
        ext_modules=[amici_module],
        py_modules=[
            # the swig interface
            'amici/amici',
        ],
        packages=find_packages(),
        package_dir={'amici': 'amici'},
        entry_points={
            'console_scripts': [
                'amici_import_petab = amici.petab_import:main',
                # for backwards compatibility
                'amici_import_petab.py = amici.petab_import:main'
            ]
        },
        install_requires=[
            'sympy>=1.6.0', 'python-libsbml', 'h5py', 'pandas', 'pkgconfig',
            'wurlitzer'
        ],
        setup_requires=['setuptools>=40.6.3'],
        python_requires='>=3.6',
        extras_require={
            'petab': ['petab==0.1.7'],
            'pysb': ['pysb>=1.11.0']
        },
        package_data={
            'amici': [
                'amici/include/amici/*',
                'src/*template*',
                'swig/*',
                'libs/*',
                'amici.py',
                'setup.py.template',
            ],
        },
        zip_safe=False,
        include_package_data=True,
        exclude_package_data={
            '': ['README.txt'],
        },
        test_suite="tests",
        classifiers=[
            'Development Status :: 5 - Production/Stable',
            'Intended Audience :: Science/Research',
            'License :: OSI Approved :: BSD License',
            'Operating System :: POSIX :: Linux',
            'Operating System :: MacOS :: MacOS X',
            'Programming Language :: Python',
            'Programming Language :: C++',
            'Topic :: Scientific/Engineering :: Bio-Informatics',
        ],
    )
예제 #3
0
def get_extension() -> Extension:
    """Get distutils extension object for this AMICI model package"""

    cxx_flags = []
    linker_flags = []

    if compiledWithOpenMP():
        # Only build model with OpenMP support if AMICI base packages was built
        #  that way
        add_openmp_flags(cxx_flags=cxx_flags, ldflags=linker_flags)

    add_coverage_flags_if_required(cxx_flags, linker_flags)
    add_debug_flags_if_required(cxx_flags, linker_flags)

    h5pkgcfg = get_hdf5_config()

    blaspkgcfg = get_blas_config()
    linker_flags.extend(blaspkgcfg.get('extra_link_args', []))

    libraries = [*get_amici_libs(), *blaspkgcfg['libraries']]
    if hdf5_enabled:
        libraries.extend(['hdf5_hl_cpp', 'hdf5_hl', 'hdf5_cpp', 'hdf5'])

    sources = [
        os.path.join("swig", "Boehm_JProteomeRes2014.i"), *get_model_sources()
    ]

    # compiler and linker flags for libamici
    if 'AMICI_CXXFLAGS' in os.environ:
        cxx_flags.extend(os.environ['AMICI_CXXFLAGS'].split(' '))
    if 'AMICI_LDFLAGS' in os.environ:
        linker_flags.extend(os.environ['AMICI_LDFLAGS'].split(' '))

    ext_include_dirs = [
        os.getcwd(),
        os.path.join(amici_path, 'include'),
        os.path.join(amici_path, "ThirdParty", "gsl"),
        os.path.join(amici_path, "ThirdParty", "sundials", "include"),
        os.path.join(amici_path, "ThirdParty", "SuiteSparse", "include"),
        *h5pkgcfg['include_dirs'], *blaspkgcfg['include_dirs']
    ]

    ext_library_dirs = [
        *h5pkgcfg['library_dirs'], *blaspkgcfg['library_dirs'],
        os.path.join(amici_path, 'libs')
    ]

    # Build shared object
    ext = Extension('Boehm_JProteomeRes2014._Boehm_JProteomeRes2014',
                    sources=sources,
                    include_dirs=ext_include_dirs,
                    libraries=libraries,
                    library_dirs=ext_library_dirs,
                    swig_opts=[
                        '-c++',
                        '-modern',
                        '-outdir',
                        'Boehm_JProteomeRes2014',
                        '-I%s' % os.path.join(amici_path, 'swig'),
                        '-I%s' % os.path.join(amici_path, 'include'),
                    ],
                    extra_compile_args=cxx_flags,
                    extra_link_args=linker_flags)

    # see `set_compiler_specific_extension_options`
    ext.extra_compile_args_mingw32 = ['-std=c++14']
    ext.extra_compile_args_unix = ['-std=c++14']
    ext.extra_compile_args_msvc = ['/std:c++14']

    return ext
예제 #4
0
파일: setup.py 프로젝트: ICB-DCM/parPE
def main():
    # Extra compiler flags
    cxx_flags = []
    amici_module_linker_flags = []
    define_macros = []

    add_openmp_flags(cxx_flags=cxx_flags, ldflags=amici_module_linker_flags)

    blaspkgcfg = get_blas_config()
    amici_module_linker_flags.extend(blaspkgcfg['extra_link_args'])
    amici_module_linker_flags.extend(f'-l{lib}'
                                     for lib in blaspkgcfg['libraries'])
    define_macros.extend(blaspkgcfg['define_macros'])

    extension_sources = [
        'amici/amici_wrap.cxx',  # swig interface
    ]

    h5pkgcfg = get_hdf5_config()

    if h5pkgcfg['found']:
        # Manually add linker flags. The libraries passed to Extension will
        # end up in front of the clibs in the linker line and not after, where
        # they are required.
        print("HDF5 library found. Building AMICI with HDF5 support.")
        amici_module_linker_flags.extend([
            f'-l{lib}'
            for lib in ['hdf5_hl_cpp', 'hdf5_hl', 'hdf5_cpp', 'hdf5']
        ])
        define_macros.extend(h5pkgcfg['define_macros'])
    else:
        print("HDF5 library NOT found. Building AMICI WITHOUT HDF5 support.")
        define_macros.append(('AMICI_SWIG_WITHOUT_HDF5', None))

    add_coverage_flags_if_required(
        cxx_flags,
        amici_module_linker_flags,
    )

    add_debug_flags_if_required(
        cxx_flags,
        amici_module_linker_flags,
    )

    # compiler and linker flags for libamici
    if 'AMICI_CXXFLAGS' in os.environ:
        cxx_flags.extend(os.environ['AMICI_CXXFLAGS'].split(' '))
    if 'AMICI_LDFLAGS' in os.environ:
        amici_module_linker_flags.extend(
            os.environ['AMICI_LDFLAGS'].split(' '))

    libamici = setup_clibs.get_lib_amici(h5pkgcfg=h5pkgcfg,
                                         blaspkgcfg=blaspkgcfg,
                                         extra_compiler_flags=cxx_flags)
    libsundials = setup_clibs.get_lib_sundials(extra_compiler_flags=cxx_flags)
    libsuitesparse = setup_clibs.get_lib_suite_sparse(
        extra_compiler_flags=cxx_flags + ['-DDLONG'])

    # Readme as long package description to go on PyPi
    # (https://pypi.org/project/amici/)
    with open(os.path.join(os.path.dirname(__file__), "README.md"),
              "r",
              encoding="utf-8") as fh:
        long_description = fh.read()

    # Build shared object
    amici_module = Extension(
        name='amici._amici',
        sources=extension_sources,
        include_dirs=[
            'amici/include', 'amici/ThirdParty/gsl/',
            *libsundials[1]['include_dirs'],
            *libsuitesparse[1]['include_dirs'], *h5pkgcfg['include_dirs'],
            *blaspkgcfg['include_dirs'],
            np.get_include()
        ],
        # Cannot use here, see above
        # libraries=[
        #    'hdf5_hl_cpp', 'hdf5_hl', 'hdf5_cpp', 'hdf5'
        # ],
        define_macros=define_macros,
        library_dirs=[
            *h5pkgcfg['library_dirs'],
            *blaspkgcfg['library_dirs'],
            'amici/libs',  # clib target directory
        ],
        extra_compile_args=cxx_flags,
        extra_link_args=amici_module_linker_flags)
    # Monkey-patch extension (see
    # `custom_commands.set_compiler_specific_extension_options`)
    amici_module.extra_compile_args_mingw32 = ['-std=c++14']
    amici_module.extra_compile_args_unix = ['-std=c++14']
    amici_module.extra_compile_args_msvc = ['/std:c++14']

    # Install
    setup(
        cmdclass={
            'install': AmiciInstall,
            'sdist': AmiciSDist,
            'build_ext': AmiciBuildExt,
            'build_clib': AmiciBuildCLib,
            'install_lib': AmiciInstallLib,
            'develop': AmiciDevelop,
        },
        long_description=long_description,
        long_description_content_type="text/markdown",
        libraries=[libamici, libsundials, libsuitesparse],
        ext_modules=[amici_module],
    )