How to use the setuptools.extension.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 yt-project / yt / setup.py View on Github external
include_dirs=["yt/utilities/lib/"],
              libraries=std_libs,
              depends=["yt/utilities/lib/fixed_interpolator.h"]),
    Extension("yt.utilities.lib.mesh_triangulation",
              ["yt/utilities/lib/mesh_triangulation.pyx"],
              depends=["yt/utilities/lib/mesh_triangulation.h"]),
    Extension("yt.utilities.lib.pixelization_routines",
              ["yt/utilities/lib/pixelization_routines.pyx",
               "yt/utilities/lib/pixelization_constants.c"],
              include_dirs=["yt/utilities/lib/"],
              libraries=std_libs,
              depends=["yt/utilities/lib/pixelization_constants.h"]),
    Extension("yt.utilities.lib.primitives",
              ["yt/utilities/lib/primitives.pyx"],
              libraries=std_libs),
    Extension("yt.utilities.lib.cosmology_time",
              ["yt/utilities/lib/cosmology_time.pyx"]),
    Extension("yt.utilities.lib.origami",
              ["yt/utilities/lib/origami.pyx",
               "yt/utilities/lib/origami_tags.c"],
              include_dirs=["yt/utilities/lib/"],
              depends=["yt/utilities/lib/origami_tags.h"]),
    Extension("yt.utilities.lib.grid_traversal",
              ["yt/utilities/lib/grid_traversal.pyx",
               "yt/utilities/lib/fixed_interpolator.c"],
              include_dirs=["yt/utilities/lib/"],
              libraries=std_libs,
              depends=["yt/utilities/lib/fixed_interpolator.h"]),
    Extension("yt.utilities.lib.image_samplers",
              ["yt/utilities/lib/image_samplers.pyx",
               "yt/utilities/lib/fixed_interpolator.c"],
              include_dirs=["yt/utilities/lib/"],
github sbusard / pynusmv / src / setup.py View on Github external
['pynusmv/nusmv/wff/wff.i'],
                depends = [ 'nusmv/nusmv-config.h',
                            'nusmv/src/utils/defs.h',
                            'nusmv/src/wff/wff.h',
                            'lib/libnusmv.so',
                            
                            'pynusmv/nusmv/typedefs.tpl',
                            
                            'pynusmv/nusmv/wff/wff.py',
                            'pynusmv/nusmv/wff/wff_wrap.c'],
                swig_opts = swig_opts, libraries = libraries,
                library_dirs = library_dirs, include_dirs = include_dirs,
                runtime_library_dirs = runtime_library_dirs)
    )
extensions.append(
     Extension('pynusmv.nusmv.wff.w2w._w2w',
                ['pynusmv/nusmv/wff/w2w/w2w.i'],
                depends = [ 'nusmv/nusmv-config.h',
                            'nusmv/src/utils/defs.h',
                            'nusmv/src/wff/w2w/w2w.h',
                            'lib/libnusmv.so',
                            
                            'pynusmv/nusmv/typedefs.tpl',
                            
                            'pynusmv/nusmv/wff/w2w/w2w.py',
                            'pynusmv/nusmv/wff/w2w/w2w_wrap.c'],
                swig_opts = swig_opts, libraries = libraries,
                library_dirs = library_dirs, include_dirs = include_dirs,
                runtime_library_dirs = runtime_library_dirs)
    )
github Ryex / Rabbyt / setup.py View on Github external
return os.path.splitext(path)[0] + new_suffix



# Setuptools doesn't pass the extension to swig_sources, so until it is
# fixed we need to do a little hack.

_old_swig_sources = build_ext.swig_sources
def swig_sources(self, sources, extension=None):
    # swig_sources only uses the extension for looking up the swig_options,
    # so we're fine with passing it a dummy.
    if extension is None:  extension = Extension("dummy", [])
    return _old_swig_sources(self, sources, extension)
build_ext.swig_sources = swig_sources

class Extension(BaseExtension):
    def __init__(self, name, sources, libraries=()):

        transform = {}
        exclude = []
        compile_args = ["-O3"]
        link_args = []
        if sys.platform == "win32":
            transform = {'GL':'opengl32', 'GLU':'glu32'}
            exclude = ['m']
            compile_args.append("-fno-strict-aliasing")

        libraries = [transform.get(l,l) for l in libraries if l not in exclude]


        if sys.platform == "darwin" and "GL" in libraries:
            compile_args.extend(['-fno-common', '-I',
github gerberlab / mitre / setup.py View on Github external
from setuptools import setup
from setuptools.extension import Extension
from setuptools.command.build_ext import build_ext
import pkg_resources

USE_CYTHON = False

ext = '.pyx' if USE_CYTHON else '.c'
extensions = [
    Extension("efficient_likelihoods",
              ["mitre/efficient_likelihoods" + ext],
              include_dirs=[])
]

if USE_CYTHON:
    from Cython.Build import cythonize
    extensions = cythonize(extensions)

def readme():
    with open('README') as f:
        return f.read()

####
# Subclass build_ext so that we can avoid trying to
# access numpy.h until numpy has been installed.
# Code from pandas setup.py
github inconvergent / differential-line / setup.py View on Github external
try:
  from setuptools import setup
  from setuptools.extension import Extension
except Exception:
  from distutils.core import setup
  from distutils.extension import Extension

from Cython.Build import cythonize
from Cython.Distutils import build_ext
import numpy

_extra = [ '-fopenmp' , '-O3', '-ffast-math']


extensions = [
  Extension('segments',
            sources = ['./src/segments.pyx'],
            extra_compile_args = _extra
  ),
  Extension('differentialLine',
            sources = ['./src/differentialLine.pyx'],
            extra_compile_args = _extra,
            extra_link_args = ['-fopenmp']
  )
]

setup(
  name = "differential-line",
  version = '0.1.0',
  author = '@inconvergent',
  install_requires = ['numpy', 'cython'],
  license = 'MIT',
github USEPA / WNTR / setup.py View on Github external
aml_core_ext = Extension("wntr.sim.aml._evaluator",
                                 sources=[evaluator_i, evaluator_cxx],
                                 language="c++",
                                 extra_compile_args=[],
                                 include_dirs=[numpy_include, src_files],
                                 library_dirs=[],
                                 libraries=[],
                                 swig_opts = ['-c++', '-builtin'])
        network_isolation_ext = Extension("wntr.sim.network_isolation._network_isolation",
                                          sources=[network_isolation_i, network_isolation_cxx],
                                          language="c++",
                                          include_dirs=[numpy_include, network_isolation_dir],
                                          extra_compile_args=[],
                                          swig_opts=['-c++', '-builtin'])
    else:
        aml_core_ext = Extension("wntr.sim.aml._evaluator",
                                 sources=[evaluator_cxx, evaluator_wrap_cxx],
                                 language="c++",
                                 extra_compile_args=[],
                                 include_dirs=[numpy_include, src_files],
                                 library_dirs=[],
                                 libraries=[])
        network_isolation_ext = Extension("wntr.sim.network_isolation._network_isolation",
                                          sources=[network_isolation_cxx, network_isolation_wrap_cxx],
                                          language="c++",
                                          include_dirs=[numpy_include, network_isolation_dir],
                                          extra_compile_args=[])


    extension_modules.append(aml_core_ext)
    extension_modules.append(network_isolation_ext)
github mondeja / pymarketcap / setup.py View on Github external
def declare_cython_extension(ext_name, libraries=None):
    """Declare a Cython extension module for setuptools.

    Args:
        ext_name (str):
            Absolute module name, e.g. use `mylibrary.mypackage.mymodule`
            for the Cython source file `mylibrary/mypackage/mymodule.pyx`.
        libraries (list):
            Libraries needed to build the extension.

    Returns (object):
        Extension object that can be passed to ``setuptools.setup``.
    """
    ext_path = ext_name.replace(".", os.path.sep) + ".pyx"

    return Extension(ext_name, [ext_path], libraries=libraries)
github bashtage / randomgen / randomgen / examples / cython / setup.py View on Github external
# python setup.py build_ext -i
from distutils.core import setup
from os.path import join

from Cython.Build import cythonize
import numpy as np
from setuptools.extension import Extension

extending = Extension(
    "extending", sources=["extending.pyx"], include_dirs=[np.get_include()]
)
distributions = Extension(
    "extending_distributions",
    sources=[
        "extending_distributions.pyx",
        join("..", "..", "..", "randomgen", "src", "distributions", "distributions.c"),
    ],
    include_dirs=[np.get_include()],
)
low_level = Extension(
    "low_level", sources=["low_level.pyx"], include_dirs=[np.get_include()]
)

extensions = [extending, distributions, low_level]
github iseekwonderful / PyPathway / setup.py View on Github external
'jinja2',
    'requests>=1.0',
    'ipython',
    'jupyter',
    'echarts-python',
    'numpy>=1.13.0',
    'h5py',
]

# c extension for fast node swap.
c_ext = Extension("pypathway.utils._node", ["./pypathway/src/node_src/_chi2.c", "./pypathway/src/node_src/heap.c",
                                            "./pypathway/src/node_src/randpick.c", "./pypathway/src/node_src/main.c"],
                  extra_compile_args=["-std=c99"] if not sys.platform == 'darwin' else None)

# c extension for magi pathway select
selects = Extension('pypathway.utils._select', ["./pypathway/src/select/_chi2.c",
                                                 "./pypathway/src/select/color_coding.c",
                                                 "./pypathway/src/select/PPI_Graph.c"],
                    extra_compile_args=["-std=c99"] if not sys.platform == 'darwin' else None)

# c extension for magi cluster
cluster = Extension('pypathway.utils._cluster', ["./pypathway/src/cluster/_chi2.c",
                                                 "./pypathway/src/cluster/clustering.cpp",
                                                 "./pypathway/src/cluster/PPI_Graph.cpp"],
                    extra_compile_args=["-std=c99"] if not sys.platform == 'darwin' else None)

# c extension for fast strong connected component
fast_scc = Extension("pypathway.analysis.modelling.third_party.hotnet2.hotnet2.fast_scc", [
    "pypathway/analysis/modelling/third_party/hotnet2/hotnet2/c_ext_src/fast_scc.c",
    "pypathway/analysis/modelling/third_party/hotnet2/hotnet2/c_ext_src/basic.c",
    "pypathway/analysis/modelling/third_party/hotnet2/hotnet2/c_ext_src/data_structure.c",
    "pypathway/analysis/modelling/third_party/hotnet2/hotnet2/c_ext_src/graphic.c",
github sbusard / pynusmv / src / setup.py View on Github external
'nusmv/src/opt/opt.h',
                            'nusmv/src/opt/OptsHandler.h',
                            'lib/libnusmv.so',
                            
                            'pynusmv/nusmv/typedefs.tpl',
                            
                            'pynusmv/nusmv/opt/opt.py',
                            'pynusmv/nusmv/opt/opt_wrap.c'],
                swig_opts = swig_opts, libraries = libraries,
                library_dirs = library_dirs, include_dirs = include_dirs,
                runtime_library_dirs = runtime_library_dirs)
    )
    
# parser modules
extensions.append(
     Extension('pynusmv.nusmv.parser._parser',
                ['pynusmv/nusmv/parser/parser.i'],
                depends = [ 'nusmv/nusmv-config.h',
                            'nusmv/src/node/node.h',
                            'nusmv/src/utils/defs.h',
                            'nusmv/src/parser/grammar.h',
                            'nusmv/src/parser/parser.h',
                            'nusmv/src/parser/symbols.h',
                            'lib/libnusmv.so',
                            
                            'pynusmv/nusmv/typedefs.tpl',
                            
                            'pynusmv/nusmv/parser/parser.py',
                            'pynusmv/nusmv/parser/parser_wrap.c'],
                swig_opts = swig_opts, libraries = libraries,
                library_dirs = library_dirs, include_dirs = include_dirs,
                runtime_library_dirs = runtime_library_dirs)