def get_extensions(is_test): compile_args = [] link_args = [] compile_args.append("-std=c++11") compile_args.append("-I{}".format(numpy.get_include())) bindings_sources = [os.path.join(PYTHON_BINDINGS_PATH, "precice") + ".pyx"] test_sources = [os.path.join(PYTHON_BINDINGS_PATH, "test", "test_bindings_module" + ".pyx")] if not is_test: link_args.append("-lprecice") if is_test: bindings_sources.append(os.path.join(PYTHON_BINDINGS_PATH, "test", "SolverInterface.cpp")) test_sources.append(os.path.join(PYTHON_BINDINGS_PATH, "test", "SolverInterface.cpp")) return [ Extension( "precice", sources=bindings_sources, libraries=[], language="c++", extra_compile_args=compile_args, extra_link_args=link_args ), Extension( "test_bindings_module", sources=test_sources, libraries=[], language="c++", extra_compile_args=compile_args, extra_link_args=link_args ) ]
def generate_extension(): extra_compile_args = [] extra_link_args = [] define_macros = [] libs = [] if sys.platform.startswith('linux'): libs.append('dl') # extra_compile_args.append('-DCYTHON_TRACE=1') elif sys.platform.startswith('darwin'): # libs.append('dl') cfg = sysconfig.get_config_vars() cfg['LDSHARED'] = cfg['LDSHARED'].replace('-bundle', '-dynamiclib') pass else: print('Sorry, your platform is not supported.') sys.exit(1) SOURCES = [ 'src/pyFlexBison/cython/core.pyx', ] return Extension('pyFlexBison.libcore_', sources=SOURCES, extra_compile_args=extra_compile_args, libraries=libs, extra_link_args=extra_link_args, **cython_args)
def extensions(): for f in files: path = os.path.relpath(f, 'src') name, _ = os.path.splitext(path) yield Extension(name.replace('/', '.'), [f], extra_compile_args=["-g", "-O0"], cython_directives={'language_level': 3})
def cuda_extensions(): cuda_dir = os.getenv('CUDA_PREFIX', '/usr/local/cuda') cuda_include_dir = os.path.join(cuda_dir, 'include') cuda_library_dir = os.path.join(cuda_dir, 'lib64') if not os.path.exists(cuda_library_dir): # Use lib if lib64 does not exist cuda_library_dir = os.path.join(cuda_dir, 'lib') library_dirs = [cuda_library_dir] prefix = os.getenv('INSTALL_PREFIX') if prefix is not None: library_dirs.append(os.path.join(prefix, 'lib')) cudarray_dir = './cudarray' cudarray_include_dir = './include' include_dirs = [ cuda_include_dir, cudarray_include_dir, numpy.get_include() ] cython_include_dirs = ['./cudarray/wrap'] extra_compile_args = ['-O3', '-fPIC', '-Wall', '-Wfatal-errors'] libraries = ['cudart', 'cudarray'] extra_link_args = ['-fPIC'] language = 'c++' def make_extension(name): return Extension( name='cudarray.wrap.' + name, sources=[os.path.join(cudarray_dir, 'wrap', name + '.pyx')], language=language, include_dirs=include_dirs, cython_include_dirs=cython_include_dirs, extra_compile_args=extra_compile_args, library_dirs=library_dirs, libraries=libraries, extra_link_args=extra_link_args, ) ext_names = [ 'cudart', 'array_data', 'array_ops', 'elementwise', 'reduction', 'blas', 'random', 'nnet', 'image' ] exts = list(map(make_extension, ext_names)) if os.getenv('CUDNN_ENABLED') == '1': cudnn_ext = Extension( name='cudarray.wrap.cudnn', sources=[os.path.join(cudarray_dir, 'wrap', 'cudnn.pyx')], language=language, include_dirs=include_dirs, cython_include_dirs=cython_include_dirs, extra_compile_args=['-DCUDNN_ENABLED'] + extra_compile_args, library_dirs=library_dirs, libraries=libraries + ['cudnn'], extra_link_args=extra_link_args, ) exts.append(cudnn_ext) return exts
def make_extension(name): return Extension( name='cudarray.wrap.' + name, sources=[os.path.join(cudarray_dir, 'wrap', name + '.pyx')], language=language, include_dirs=include_dirs, cython_include_dirs=cython_include_dirs, extra_compile_args=extra_compile_args, library_dirs=library_dirs, libraries=libraries, extra_link_args=extra_link_args, )
def get_extensions(mpi_compiler_wrapper, is_test): compile_args = [] link_args = [] mpi_compile_args, mpi_link_args = determine_mpi_args(mpi_compiler_wrapper) compile_args += mpi_compile_args compile_args.append("-Wall") compile_args.append("-std=c++11") link_args += mpi_link_args bindings_sources = [os.path.join(PYTHON_BINDINGS_PATH, APPNAME) + ".pyx"] test_sources = [ os.path.join(PYTHON_BINDINGS_PATH, "test", "test_bindings_module" + ".pyx") ] if not is_test: link_args.append("-lprecice") if is_test: bindings_sources.append( os.path.join(PYTHON_BINDINGS_PATH, "test", "SolverInterface.cpp")) test_sources.append( os.path.join(PYTHON_BINDINGS_PATH, "test", "SolverInterface.cpp")) return [ Extension(APPNAME, sources=bindings_sources, libraries=[], language="c++", extra_compile_args=compile_args, extra_link_args=link_args), Extension("test_bindings_module", sources=test_sources, libraries=[], language="c++", extra_compile_args=compile_args, extra_link_args=link_args) ]
def get_extensions(mpi_compiler_wrapper): mpi_compile_args, mpi_link_args = determine_mpi_args(mpi_compiler_wrapper) compile_args = ["-Wall", "-std=c++11"] + mpi_compile_args link_args = ["-lprecice"] + mpi_link_args return [ Extension( APPNAME, sources=[os.path.join(PYTHON_BINDINGS_PATH, APPNAME) + ".pyx"], libraries=[], language="c++", extra_compile_args=compile_args, extra_link_args=link_args) ]
def get_ext_modules(): module_prefix = "sqlalchemy.cyextension." source_prefix = "lib/sqlalchemy/cyextension/" ext_modules = [] for file in cython_files: name, _ = os.path.splitext(file) ext_modules.append( Extension( module_prefix + name, sources=[source_prefix + file], extra_compile_args=extra_compile_args, cython_directives=cython_directives, )) return ext_modules
def CythonExtension(*args, **kwargs): depends = kwargs.setdefault('depends', []) # Doesn't truely apply to everything, but most of the modules import these. depends.extend([ 'pyrex/python.pxi', 'pyrex/libc.pxd', 'pyrex/pyrex_helpers.pyx', 'include/pyrex_helpers.h', ]) include_dirs = kwargs.setdefault('include_dirs', []) include_dirs.append('include') pyrex_include_dirs = kwargs.setdefault('pyrex_include_dirs', []) pyrex_include_dirs.append('pyrex') return Extension(*args, **kwargs)
def find_ext(self): from Cython.Distutils.extension import Extension ret = [] for package in ('pyasn1',): for root, _, files in os.walk(os.path.join(SETUP_DIRNAME, package)): commonprefix = os.path.commonprefix([SETUP_DIRNAME, root]) for filename in files: full = os.path.join(root, filename) if not filename.endswith(('.py', '.c')): continue if filename in ('__init__.py',): continue relpath = os.path.join(root, filename).split(commonprefix)[-1][1:] if relpath in ('pyasn1/codec/ber/encoder.py',): # We have issues when cython compiling asn1, skipt it continue module = os.path.splitext(relpath)[0].replace(os.sep, '.') ret.append(Extension(module, [full])) return ret
def create_extension(module): global USING_CYTHON, extension_kwargs name = ".".join(module["path"]) path = os.path.join(*module["path"]) language = module.get("language", "c") multisource = module.get("multisource", False) if USING_CYTHON: extension = "pyx" elif language == "c": extension = "c" elif language == "c++": extension = "cpp" if multisource: sources = find_files(path, extension) else: sources = [path + "." + extension] return Extension(name, sources, language=language, **extension_kwargs)
} cython_args = { 'cython_directives': cython_directives, 'cython_compile_time_env': { 'EMBEDDED_LIB': _embedded_lib, 'HAVE_AGENT_FWD': _have_agent_fwd, }} \ if USING_CYTHON else {} if USING_CYTHON: sys.stdout.write("Cython arguments: %s%s" % (cython_args, os.linesep)) extensions = [ Extension(sources[i].split('.')[0].replace(os.path.sep, '.'), sources=[sources[i]], include_dirs=["libssh2/include"], libraries=_libs, extra_compile_args=_comp_args, **cython_args) for i in range(len(sources)) ] package_data = {'ssh2': ['*.pxd']} if ON_WINDOWS: package_data['ssh2'].extend([ 'libeay32.dll', 'ssleay32.dll', ]) cmdclass = versioneer.get_cmdclass() if USING_CYTHON: cmdclass['build_ext'] = build_ext
#Build an extension with the sources ext_name = pyx_file.rsplit('.', 1)[0].replace('/', '.') name = ext_name.rsplit('.', 1)[0] pxd = pxd_file.split('PDSim/', 1)[1].split('/')[1] if name in package_pxd_files: package_pxd_files[name].append(pxd) else: package_pxd_files[name] = [pxd] ext_module_list.append( Extension( ext_name, sources, language='c++', define_macros=[ ('SWIG', None) ], # Workaround to remove dependency on rapidjson in Configuration.h cython_c_in_temp=True)) package_data = package_pxd_files setup( name='PDSim', version=version, author="Ian Bell", author_email='*****@*****.**', url='http://pdsim.sourceforge.net', requires=['quantities' ], # post-install quantities will be automatically installed description=
cython_args = {'cython_directives': cython_directives} if USING_CYTHON else {} _libs = ['ssh2'] if platform.system() != 'Windows' else [ # For libssh2 OpenSSL backend on Windows. # Windows native WinCNG is used by default. # 'libeay32', 'ssleay32', 'Ws2_32', 'libssh2', 'user32' ] _comp_args = ["-O3"] if platform.system() != 'Windows' else None extensions = [ Extension('pssh.native.ssh2', sources=['pssh/native/ssh2.pyx'], include_dirs=["libssh2/include"], libraries=_libs, extra_compile_args=_comp_args, **cython_args) ] cmdclass = versioneer.get_cmdclass() if USING_CYTHON: cmdclass['build_ext'] = build_ext setup( name='parallel-ssh', version=versioneer.get_version(), cmdclass=cmdclass, description='Asynchronous parallel SSH library', long_description=open('README.rst').read(), author='Panos Kittenis',
from setuptools import find_packages from distutils.core import setup from Cython.Distutils.extension import Extension from Cython.Distutils import build_ext from Cython.Build import cythonize import galaxy_ml VERSION = galaxy_ml.__version__ PROJECT_ROOT = dirname(realpath(__file__)) with open(join(PROJECT_ROOT, 'requirements.txt'), 'r') as f: install_reqs = f.read().splitlines() genome_module = Extension( "galaxy_ml.externals.selene_sdk.sequences._sequence", ["galaxy_ml/externals/selene_sdk/sequences/_sequence.pyx"], include_dirs=[np.get_include()]) genomic_features_module = Extension( "galaxy_ml.externals.selene_sdk.targets._genomic_features", ["galaxy_ml/externals/selene_sdk/targets/_genomic_features.pyx"], include_dirs=[np.get_include()]) ext_modules = [genome_module, genomic_features_module] cmdclass = {'build_ext': build_ext} long_description = """ This library contains APIs for [Galaxy](https://github.com/galaxyproject/galaxy) machine learning tools(Galaxy-ML).
executable="/bin/bash", cwd=SCRIPT_DIR) compiler = distutils.ccompiler.new_compiler() distutils.sysconfig.customize_compiler(compiler) BLACKLISTED_COMPILER_SO = ['-Wp,-D_FORTIFY_SOURCE=2'] build_ext.compiler = compiler ext_modules = [ Extension(name=DALI_CORE_MODULE, sources=[join(SCRIPT_DIR, "cython", "dali", "core.pyx")] + list(find_extension_files(DALI_CORE_DIR, ".cpp")), library_dirs=[], language='c++', extra_compile_args=['-std=c++11'], extra_link_args=robbed["LINK_ARGS"], libraries=[], extra_objects=[], include_dirs=[np.get_include()] + robbed["DALI_AND_DEPS_INCLUDE_DIRS"]) ] ################################################################################ ## PREPROCSSOR - HOW TO SHRINK DALI CYTHON CODE THREEFOLD ## ################################################################################ def run_preprocessor(): """ Generate python files using a file prepocessor (essentially macros
if USING_CYTHON else {} if USING_CYTHON: sys.stdout.write("Cython arguments: %s%s" % (cython_args, os.linesep)) runtime_library_dirs = ["$ORIGIN/."] if not SYSTEM_LIBSSH2 else None _lib_dir = os.path.abspath( "./src/src") if not SYSTEM_LIBSSH2 else "/usr/local/lib" include_dirs = ["libssh2/include" ] if ON_RTD or not SYSTEM_LIBSSH2 else ["/usr/local/include"] extensions = [ Extension(sources[i].split('.')[0].replace(os.path.sep, '.'), sources=[sources[i]], include_dirs=include_dirs, libraries=_libs, library_dirs=[_lib_dir], runtime_library_dirs=runtime_library_dirs, extra_compile_args=_comp_args, **cython_args) for i in range(len(sources)) ] package_data = {'ssh2': ['*.pxd', 'libssh2.so*']} if ON_WINDOWS: package_data['ssh2'].extend([ 'libeay32.dll', 'ssleay32.dll', ]) cmdclass = versioneer.get_cmdclass() if USING_CYTHON:
with opn("README.md", "r", "utf-8") as file: return file.read() SCR_DIR = "sources" if USING_CYTHON: sources = [SCR_DIR + "/lib/sgm.cpp", SCR_DIR + "/sgm_wrapper.pyx"] else: sources = [SCR_DIR + "/lib/sgm.cpp", SCR_DIR + "/sgm_wrapper.cpp"] ext_1 = Extension( "libSGM.sgm_wrapper", sources, language="c++", library_dirs=[], libraries=[], include_dirs=[numpy.get_include(), SCR_DIR + "/lib/sgm.hpp"], extra_compile_args=["-O3", "-fopenmp", "-std=c++11"], extra_link_args=["-lgomp"], ) extensions = [ext_1] try: from sphinx.setup_command import BuildDoc CMDCLASS.update({"build_sphinx": BuildDoc}) except ImportError: print("WARNING: sphinx not available. Doc cannot be built") os.environ["CC"] = shutil.which("gcc")
from Cython.Build import cythonize from Cython.Distutils.extension import Extension #from distutils.core import setup from datetime import datetime #import multiprocessing import sys import os if __name__ == "__main__": # set up instruction count insCnt = str(sys.argv[1]) extensions = [] for i in range(1, 9): extensions.append( Extension("lib%s_%d" % (insCnt, i), ["lib%s_%d.py" % (insCnt, i)])) # set up thread threads = int(sys.argv[2]) print "Start process %s instructions with %d threads" % (insCnt, threads) del sys.argv[1] del sys.argv[1] # start work ... start = datetime.now() ext_modules = cythonize(extensions, force=True, nthreads=threads) end = datetime.now() print "delay is: " + str(end - start)
'cython_compile_time_env': { 'ON_WINDOWS': ON_WINDOWS, }} \ if USING_CYTHON else {} runtime_library_dirs = ["$ORIGIN/."] if not SYSTEM_LIBSSH else None _lib_dir = os.path.abspath( "./local/lib") if not SYSTEM_LIBSSH else "/usr/local/lib" include_dirs = ["./local/include"] if (ON_WINDOWS or ON_RTD) or \ not SYSTEM_LIBSSH else ["/usr/local/include"] extensions = [ Extension(sources[i].split('.')[0].replace(os.path.sep, '.'), sources=[sources[i]], include_dirs=include_dirs, libraries=_libs, library_dirs=[_lib_dir], runtime_library_dirs=runtime_library_dirs, extra_compile_args=_comp_args, **cython_args) for i in range(len(sources)) ] package_data = {'ssh': ['*.pxd', 'libssh.so*']} if ON_WINDOWS: package_data['ssh'].extend([ 'libcrypto*.dll', 'libssl*.dll', 'ssh.dll', 'msvc*.dll', 'vcruntime*.dll', ])
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # import Cython.Compiler.Options Cython.Compiler.Options.annotate = True from distutils.core import setup from Cython.Distutils.extension import Extension from Cython.Distutils import build_ext extensions = [ Extension( "netif", ["netif.pyx", "ifmedia.c"], extra_compile_args=["-g"], ) ] setup(name='netif', version='1.0', packages=[''], package_data={'': ['*.html', '*.c']}, cmdclass={'build_ext': build_ext}, ext_modules=extensions)
import os from glob import glob with open('README.md') as f: readme = f.read() with open('LICENSE') as f: license = f.read() from Cython.Distutils.extension import Extension from Cython.Distutils import build_ext ext = 'pyx' sources = glob('spykesim/*.%s' % (ext,)) extensions = [ Extension(source.split('.')[0].replace(os.path.sep, '.'), sources=[source], ) for source in sources] cmdclass = {'build_ext': build_ext} import numpy setup( name='spykesim', version='1.2.5', description='Python module that offers functions for measuring the similarity between two segmented multi-neuronal spiking activities.', long_description=readme, author='Keita Watanabe', author_email='*****@*****.**', install_requires=['scipy', 'joblib', 'tqdm', 'h5py'], url='https://github.com/KeitaW/spikesim', license=license,
print('using cython', USE_CYTHON) # make sure numpy is installed before we try to build # the extenion class build_ext(_build_ext): def finalize_options(self): super().finalize_options() import numpy self.include_dirs.append(numpy.get_include()) # if we have cython, use the cython file if not the c file ext = '.pyx' if USE_CYTHON else '.c' extensions = [ Extension('eventio.header', sources=['eventio/header' + ext]), Extension('eventio.var_int', sources=['eventio/var_int' + ext]), Extension( 'eventio.simtel.parsing', sources=['eventio/simtel/parsing' + ext] ), ] cmdclass = {'build_ext': build_ext} # give a nice error message if people cloned the # repository and do not have cython installed if ext == '.c': sources = [] for ext in extensions: sources.extend(ext.sources) if not all(os.path.isfile(s) for s in sources):
#!/usr/bin/env python # -*- coding: utf-8 -*- from distutils.core import setup from Cython.Distutils.extension import Extension from Cython.Distutils import build_ext ext_modules = [ Extension("main", ["main.py"]), Extension("audio", ["audio.py"]), Extension("peakDetector", ["peakDetector.py"]), Extension("solenoid", ["solenoid.py"]), Extension("OSCserver", ["OSCserver.py"]), ] for e in ext_modules: e.cython_directives = {"language_level": "3"} setup( name='GMEM-client', cmdclass={'build_ext': build_ext}, ext_modules=ext_modules, )
"${FREEBSD_SRC}/cddl/contrib/opensolaris/head", "${FREEBSD_SRC}/sys/cddl/contrib/opensolaris/uts/common", "${FREEBSD_SRC}/cddl/contrib/opensolaris/lib/libnvpair", "${FREEBSD_SRC}/cddl/contrib/opensolaris/lib/libuutil/common", "${FREEBSD_SRC}/cddl/contrib/opensolaris/lib/libzfs/common", "${FREEBSD_SRC}/cddl/contrib/opensolaris/lib/libzfs_core/common" ] system_includes = [os.path.expandvars(x) for x in system_includes] freebsd_version = int(subprocess.check_output("uname -K", shell=True).strip()) setup( name='libzfs', version='1.0', packages=[''], package_data={'': ['*.html', '*.c']}, cmdclass={'build_ext': build_ext}, ext_modules=[ Extension( "libzfs", ["libzfs.pyx"], libraries=["nvpair", "zfs", "zfs_core", "uutil", "geom"], extra_compile_args=["-DNEED_SOLARIS_BOOLEAN", "-D_XPG6", "-g", "-O0"], cython_include_dirs=["./pxd"], cython_compile_time_env={'FREEBSD_VERSION': freebsd_version, 'TRUEOS': os.getenv('TRUEOS')}, include_dirs=system_includes, extra_link_args=["-g"], ) ] )
encoding='utf-8') as readme: long_description = readme.read() try: from Cython.Distutils.extension import Extension from Cython.Distutils import build_ext except ImportError: from setuptools.extension import Extension USING_CYTHON = False else: USING_CYTHON = True ext = '.pyx' if USING_CYTHON else '.c' genome_module = Extension("selene_sdk.sequences._sequence", ["selene_sdk/sequences/_sequence" + ext], include_dirs=[np.get_include()]) genomic_features_module = Extension( "selene_sdk.targets._genomic_features", ["selene_sdk/targets/_genomic_features" + ext], include_dirs=[np.get_include()]) ext_modules = [genome_module, genomic_features_module] cmdclass = {'build_ext': build_ext} if USING_CYTHON else {} setup(name="selene-sdk", version="0.3.0", long_description=long_description, long_description_content_type='text/markdown', description=("framework for developing sequence-level "
# Setup project for compilation ## Henrique X. Goulart import sys import json import os import multiprocessing from setuptools import setup from Cython.Build import cythonize from Cython.Distutils.extension import Extension from Cython.Distutils import build_ext NB_COMPILE_JOBS = multiprocessing.cpu_count() ext_modules = [ Extension('pam', ['src/pam.py']), Extension('img_to_vec', ['src/img_to_vec.py']), Extension('declarative', ['src/declarative.py']), Extension('spatial', ['src/spatial.py']) ] def setup_given_extensions(extensions): setup(name='msc', cmdclass={'build_ext': build_ext}, ext_modules=cythonize(extensions)) def setup_extensions_in_sequential(): setup_given_extensions(ext_modules)
) try: import config except ImportError: raise ImportError('Please execute configure script first') libraries = ['nvpair', 'zfs', 'zfs_core', 'uutil'] if platform.system().lower() == 'freebsd': libraries.append('geom') setup(name='libzfs', version='1.0', packages=[''], package_data={'': ['*.html', '*.c']}, setup_requires=[ 'setuptools>=18.0', 'Cython', ], cmdclass={'build_ext': build_ext}, ext_modules=[ Extension( "libzfs", ["libzfs.pyx"], libraries=libraries, extra_compile_args=config.CFLAGS, cython_include_dirs=["./pxd"], extra_link_args=["-g"], ) ])
import sys from distutils.core import setup from Cython.Distutils.extension import Extension from Cython.Distutils import build_ext ext_modules = [] ext_modules.append( Extension('jsonparser', ['./jsonparser.pyx'], language='c++')) setup(name='json-parser python wrapper', cmdclass={'build_ext': build_ext}, ext_modules=ext_modules)
from distutils.core import setup from Cython.Distutils.extension import Extension from Cython.Distutils import build_ext os.environ['CC'] = 'clang' os.environ.setdefault('DESTDIR', '/') cflags = [ '-g', '-fblocks', '-Wno-sometimes-uninitialized', os.path.expandvars('-I${CMAKE_SOURCE_DIR}/include') ] ldflags = [ os.path.expandvars('-L..'), os.path.expandvars('-Wl,-rpath'), os.path.expandvars('-Wl,${CMAKE_PREFIX}/lib'), '-ladcusb', ] setup(name='adcusb', version='1.0', packages=[''], package_data={'': ['*.html', '*.c', 'adcusb.pxd']}, cmdclass={'build_ext': build_ext}, ext_modules=[ Extension("adcusb", ["adcusb.pyx"], extra_compile_args=cflags, extra_link_args=ldflags, include_dirs=[np.get_include()]) ])