How to use the setuptools.Extension function in setuptools

To help you get started, we’ve selected a few setuptools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Magdoll / cDNA_Cupcake / setup.py View on Github external
from setuptools import setup, Extension, find_packages
import sys
import numpy as np
from Cython.Build import cythonize


__author__ = "etseng@pacb.com"
version = "12.1.0"

ext_modules = [
                Extension("cupcake.tofu.branch.intersection_unique",
                    ["cupcake/tofu/branch/intersection_unique.pyx"]),
                Extension("cupcake.tofu.branch.c_branch",
                         ["cupcake/tofu/branch/c_branch.pyx"]),
                Extension("cupcake.ice.find_ECE",
                    ["cupcake/ice/find_ECE.pyx"]),
              ]


setup(
    name = 'cupcake',
    version=version,
    author='Elizabeth Tseng',
    author_email='etseng@pacb.com',
    ext_modules = cythonize(ext_modules),
    include_dirs = [np.get_include()],
    zip_safe=False,
    packages = ['cupcake', 'cupcake.io', 'cupcake.ice',
                'cupcake.tofu', 'cupcake.tofu.branch', 'cupcake.tofu.counting',
                'cupcake2', 'cupcake2.io', 'cupcake2.ice2', 'cupcake2.tofu2',
                'phasing', 'phasing.io'],
github msmbuilder / msmbuilder / setup.py View on Github external
extensions.append(
    Extension('msmbuilder.hmm.gaussian',
              language='c++',
              sources=[pjoin(HMMDIR, 'gaussian.pyx'),
                       pjoin(HMMDIR, 'src/GaussianHMMFitter.cpp')],
              libraries=compiler.compiler_libraries_openmp,
              extra_compile_args=compiler.compiler_args_sse3
                                 + compiler.compiler_args_openmp,
              include_dirs=[np.get_include(),
                            HMMDIR,
                            pjoin(HMMDIR, 'src/include/'),
                            pjoin(HMMDIR, 'src/')]))

extensions.append(
    Extension('msmbuilder.hmm.vonmises',
              language='c++',
              sources=[pjoin(HMMDIR, 'vonmises.pyx'),
                       pjoin(HMMDIR, 'src/VonMisesHMMFitter.cpp'),
                       pjoin(HMMDIR, 'cephes/i0.c'),
                       pjoin(HMMDIR, 'cephes/chbevl.c')],
              libraries=compiler.compiler_libraries_openmp,
              extra_compile_args=compiler.compiler_args_sse3
                                 + compiler.compiler_args_openmp,
              include_dirs=[np.get_include(),
                            HMMDIR,
                            pjoin(HMMDIR, 'src/include/'),
                            pjoin(HMMDIR, 'src/'),
                            pjoin(HMMDIR, 'cephes/')]))

write_version_py(VERSION, ISRELEASED, filename='msmbuilder/version.py')
setup(name='msmbuilder',
github GreatFruitOmsk / cx_freeze / setup.py View on Github external
if sys.platform == "win32":
    libraries = ["imagehlp", "Shlwapi"]
else:
    libraries = []
utilModule = Extension("cx_Freeze.util", ["source/util.c"],
        libraries = libraries)

# build base executables
docFiles = "README.txt"
scripts = ["cxfreeze", "cxfreeze-quickstart"]
options = dict(bdist_rpm = dict(doc_files = docFiles),
        install = dict(optimize = 1))
depends = ["source/bases/Common.c"]
fullDepends = depends + [baseModulesFileName]
includeDirs = [baseModulesDir]
console = Extension("cx_Freeze.bases.Console", ["source/bases/Console.c"],
        depends = fullDepends, include_dirs = includeDirs)
consoleKeepPath = Extension("cx_Freeze.bases.ConsoleKeepPath",
        ["source/bases/ConsoleKeepPath.c"], depends = depends)
extensions = [utilModule, console, consoleKeepPath]
if sys.platform == "win32":
    scripts.append("cxfreeze-postinstall")
    options["bdist_msi"] = dict(install_script = "cxfreeze-postinstall")
    gui = Extension("cx_Freeze.bases.Win32GUI", ["source/bases/Win32GUI.c"],
            include_dirs = includeDirs, depends = fullDepends,
            libraries = ["user32"])
    extensions.append(gui)
    moduleInfo = find_cx_Logging()
    if moduleInfo is not None and sys.version_info[:2] < (3, 0):
        includeDir, libraryDir = moduleInfo
        includeDirs.append(includeDir)
        service = Extension("cx_Freeze.bases.Win32Service",
github pyrocko / pyrocko / setup.py View on Github external
sources=[op.join('src', 'ext', 'eikonal_ext.c')]),

        Extension(
            'parstack_ext',
            include_dirs=[get_python_inc(), numpy.get_include()],
            extra_compile_args=['-Wextra'] + omp_arg,
            extra_link_args=[] + omp_lib,
            sources=[op.join('src', 'ext', 'parstack_ext.c')]),

        Extension(
            'ahfullgreen_ext',
            include_dirs=[get_python_inc(), numpy.get_include()],
            extra_compile_args=['-Wextra'],
            sources=[op.join('src', 'ext', 'ahfullgreen_ext.c')]),

        Extension(
            'orthodrome_ext',
            include_dirs=[get_python_inc(), numpy.get_include()],
            extra_compile_args=['-Wextra'],
            sources=[op.join('src', 'ext', 'orthodrome_ext.c')]),

        Extension(
            "avl",
            sources=[op.join('src', 'ext', 'pyavl-1.12', 'avl.c'),
                     op.join('src', 'ext', 'pyavl-1.12', 'avlmodule.c')],
            define_macros=[('HAVE_AVL_VERIFY', None),
                           ('AVL_FOR_PYTHON', None)],
            include_dirs=[get_python_inc()],
            extra_compile_args=['-Wno-parentheses', '-Wno-uninitialized'],
            extra_link_args=[] if sys.platform != 'sunos5' else ['-Wl,-x']),
    ],
github scikit-cycuba / scikit-cycuba / setup.py View on Github external
CYTHONIZE = True
cwd = os.path.abspath(os.path.dirname(__file__))
cython_directory = os.path.join(cwd, 'cycuba')
extension_filenames =  [os.path.join(cython_directory, '_cycuba')]
extension_sources = []
for filename in extension_filenames:
    file_name_c = filename + '.c'
    if not os.path.isfile(filename) or CYTHONIZE:
        # Call Cython on the associated *.pyx file
        p = subprocess.call(['cython', filename + '.pyx'], cwd=cython_directory)
        if p != 0:
            raise RuntimeError("Cythonize failed!")
    extension_sources.append(file_name_c)

extensions = [Extension('_cycuba', extension_sources, libraries=['cuba'])]

setup(name='cycuba', version='0.1.0',
      description=
      'A Cython wrapper to the Cuba library (http://www.feynarts.de/cuba/)',
      long_description=None, author='C. Nathan Woods',
      author_email='woodscn@lanl.gov', license='BSD',
      ext_modules=extensions, packages = find_packages(),
      zip_safe=False
      )
github NREL / pysam / setup.py View on Github external
['src/StandAloneBattery.c'],
                  define_macros=defines,
                  include_dirs=[includepath],
                  library_dirs=[libpath],
                  libraries=libs,
                  extra_link_args=extra_link_args
                  ),
        Extension('PySAM.Thermalrate',
                  ['src/Thermalrate.c'],
                  define_macros=defines,
                  include_dirs=[includepath],
                  library_dirs=[libpath],
                  libraries=libs,
                  extra_link_args=extra_link_args
                  ),
        Extension('PySAM.Swh',
                  ['src/Swh.c'],
                  define_macros=defines,
                  include_dirs=[includepath],
                  library_dirs=[libpath],
                  libraries=libs,
                  extra_link_args=extra_link_args
                  ),
        Extension('PySAM.Geothermal',
                  ['src/Geothermal.c'],
                  define_macros=defines,
                  include_dirs=[includepath],
                  library_dirs=[libpath],
                  libraries=libs,
                  extra_link_args=extra_link_args
                  ),
        Extension('PySAM.GenericSystem',
github pywr / pywr / setup.py View on Github external
"pywr.parameters",
            "pywr.recorders",
            "pywr.notebook",
            "pywr.optimisation",
        ],
        package_data=package_data(),
        use_scm_version=True,
    )

    metadata["ext_modules"] = ext_modules = [
        Extension("pywr._core", ["pywr/_core.pyx"]),
        Extension("pywr._model", ["pywr/_model.pyx"]),
        Extension("pywr._component", ["pywr/_component.pyx"]),
        Extension("pywr.parameters._parameters", ["pywr/parameters/_parameters.pyx"]),
        Extension("pywr.parameters._polynomial", ["pywr/parameters/_polynomial.pyx"]),
        Extension("pywr.parameters._thresholds", ["pywr/parameters/_thresholds.pyx"]),
        Extension("pywr.parameters._control_curves", ["pywr/parameters/_control_curves.pyx"]),
        Extension("pywr.parameters._hydropower", ["pywr/parameters/_hydropower.pyx"]),
        Extension("pywr.recorders._recorders", ["pywr/recorders/_recorders.pyx"]),
        Extension("pywr.recorders._thresholds", ["pywr/recorders/_thresholds.pyx"]),
        Extension("pywr.recorders._hydropower", ["pywr/recorders/_hydropower.pyx"]),
    ]

    config = parse_optional_arguments()

    if config["glpk"]:
        ext_modules.append(
                Extension("pywr.solvers.cython_glpk", ["pywr/solvers/cython_glpk.pyx"], libraries=["glpk"],)
        )

    if config["lpsolve"]:
        if os.name == "nt":
github python-useful-helpers / logwrap / setup.py View on Github external
with open(os.path.join(os.path.dirname(__file__), PACKAGE_NAME, "__init__.py")) as f:
    SOURCE = f.read()

with open("requirements.txt") as f:
    REQUIRED = f.read().splitlines()

with open("README.rst") as f:
    LONG_DESCRIPTION = f.read()


# noinspection PyCallingNonCallable
if cythonize is not None:
    if "win32" != sys.platform:
        REQUIRES_OPTIMIZATION = [
            setuptools.Extension("logwrap.class_decorator", ["logwrap/class_decorator.pyx"]),
            setuptools.Extension("logwrap.repr_utils", ["logwrap/repr_utils.pyx"]),
            setuptools.Extension("logwrap.log_wrap", ["logwrap/log_wrap.pyx"]),
            setuptools.Extension("logwrap.__init__", ["logwrap/__init__.pyx"]),
            setuptools.Extension("logwrap.log_on_access", ["logwrap/log_on_access.py"]),
        ]
        INTERFACES = ["class_decorator.pxd", "log_wrap.pxd", "repr_utils.pxd"]
    else:
        REQUIRES_OPTIMIZATION = [
            setuptools.Extension("logwrap.class_decorator", ["logwrap/class_decorator.pyx"]),
            setuptools.Extension("logwrap.repr_utils", ["logwrap/repr_utils.pyx"]),
            setuptools.Extension("logwrap.log_on_access", ["logwrap/log_on_access.py"]),
        ]
        INTERFACES = ["class_decorator.pxd", "repr_utils.pxd"]

    EXT_MODULES = cythonize(
        module_list=REQUIRES_OPTIMIZATION,
github SiLab-Bonn / pylandau / setup.py View on Github external
__builtins__.__NUMPY_SETUP__ = False
        import numpy
        self.include_dirs.append(numpy.get_include())

# Check if cython exists, then use it. Otherwise compile already cythonized cpp file
have_cython = False
try:
    from Cython.Build import cythonize
    have_cython = True
except ImportError:
    pass

if have_cython:
    cpp_extension = cythonize(Extension('pylandau', ['pyLandau/cpp/pylandau.pyx']))
else:
    cpp_extension = [Extension('pylandau',
                               sources=['pyLandau/cpp/pylandau.cpp'],
                               language="c++")]

version = '2.1.1'
author = 'David-Leon Pohl'
author_email = 'pohl@physik.uni-bonn.de'

install_requires = ['cython', 'numpy'] # scipy
setup_requires = ['numpy', 'cython']

setup(
    name='pylandau',
    version=version,
    description='A Landau PDF definition to be used in Python.',
    url='https://github.com/SiLab-Bonn/pyLandau',
    license='GNU LESSER GENERAL PUBLIC LICENSE Version 2.1',
github pygbe / pygbe / setup.py View on Github external
include_dirs=[numpy.get_include()],
                          extra_compile_args=['-fPIC', '-O3', '-funroll-loops', '-msse3', '-fopenmp'],
                ),
                Extension("_direct",
                          sources=["pygbe/tree/direct.i", "pygbe/tree/direct.cpp"],
                          swig_opts=['-c++','-py3'],
                          include_dirs=[numpy.get_include()],
                          extra_compile_args=['-fPIC', '-O3', '-funroll-loops', '-msse3', '-fopenmp'],
                ),
                Extension("_calculateMultipoles",
                          sources=["pygbe/tree/calculateMultipoles.i", "pygbe/tree/calculateMultipoles.cpp"],
                          swig_opts=['-c++','-py3'],
                          include_dirs=[numpy.get_include()],
                          extra_compile_args=['-fPIC', '-O3', '-funroll-loops', '-msse3', '-fopenmp'],
                ),
                Extension("_semi_analyticalwrap",
                          sources=["pygbe/util/semi_analyticalwrap.i", "pygbe/util/semi_analyticalwrap.cpp"],
                          swig_opts=['-c++','-py3'],
                          include_dirs=[numpy.get_include()],
                          extra_compile_args=['-fPIC', '-O3', '-funroll-loops', '-msse3', '-fopenmp'],
                ),
                ],
            )
    setup(**setupkw)