include_dirs=[np.get_include()]) for package in packages_list ] # long description from README file with open('README.md', encoding='utf-8') as f: DESCRIPTION = f.read() REQUIRED = open('requirements.txt').readlines() REQUIRES_PYTHON = '>=3.8' CYTHON_DEBUG = False if not os.getenv('CYTHON_DEBUG') else os.getenv( 'CYTHON_DEBUG') if CYTHON_DEBUG: from Cython.Compiler.Options import get_directive_defaults get_directive_defaults()['cache_builtins'] = False setup( name=PROJECT_NAME, version=VERSION, url='https://github.com/Drakkar-Software/OctoBot-Trading', license='LGPL-3.0', author='Drakkar-Software', author_email='*****@*****.**', description='OctoBot project trading package', packages=PACKAGES, include_package_data=True, long_description=DESCRIPTION, include_dirs=[np.get_include()], cmdclass={'build_ext': build_ext}, tests_require=["pytest"],
import os from os.path import abspath, dirname, join from setuptools import setup, Extension if os.getenv('USE_CYTHON'): USE_CYTHON = True else: USE_CYTHON = False ext = '.pyx' if USE_CYTHON else '.c' if os.getenv('CYTHON_TRACE'): macros = [('CYTHON_TRACE', '1')] from Cython.Compiler.Options import get_directive_defaults get_directive_defaults()['linetrace'] = True else: macros = [] if os.getenv('CYTHON_PROFILE'): from Cython.Compiler.Options import get_directive_defaults get_directive_defaults()['profile'] = True ext_modules = [ Extension('kerl.kerl', ['kerl/kerl' + ext], define_macros=macros), Extension('kerl.conv', ['kerl/conv' + ext], define_macros=macros), ] setup_dir = abspath(dirname(__file__)) with open(join(setup_dir, 'requirements.txt')) as fp: install_requires = fp.readlines()
#!/usr/bin/env python3 from distutils.core import setup from distutils.extension import Extension from Cython import __version__ from Cython.Distutils import build_ext #from Cython.Build import cythonize import numpy as np from LoLIM.utilities import GSL_include, GSL_library_dir from Cython.Compiler.Options import get_directive_defaults directive_defaults = get_directive_defaults() CT = [] # CT =[('CYTHON_TRACE', '1')] # directive_defaults['linetrace'] = True # directive_defaults['binding'] = True # directive_defaults['profile'] = True print('cython version', __version__) # ext = Extension("cython_beamforming_tools", ["cython_beamforming_tools.pyx"], # include_dirs=[np.get_include(), # GSL_include()], # library_dirs=[GSL_library_dir()], # libraries=["gsl", 'blas'], # define_macros=CT # ) # # setup(ext_modules=[ext],
def compile_cython_modules(profile=False, coverage=False, compile_more=False, cython_with_refnanny=False): source_root = os.path.abspath(os.path.dirname(__file__)) compiled_modules = [ "Cython.Plex.Scanners", "Cython.Plex.Actions", "Cython.Plex.Machines", "Cython.Plex.Transitions", "Cython.Plex.DFA", "Cython.Compiler.Scanning", "Cython.Compiler.Visitor", "Cython.Compiler.FlowControl", "Cython.Runtime.refnanny", "Cython.Compiler.FusedNode", "Cython.Tempita._tempita", ] if compile_more: compiled_modules.extend([ "Cython.StringIOTree", "Cython.Compiler.Code", "Cython.Compiler.Lexicon", "Cython.Compiler.Parsing", "Cython.Compiler.Pythran", "Cython.Build.Dependencies", "Cython.Compiler.ParseTreeTransforms", "Cython.Compiler.Nodes", "Cython.Compiler.ExprNodes", "Cython.Compiler.ModuleNode", "Cython.Compiler.Optimize", ]) from distutils.spawn import find_executable from distutils.sysconfig import get_python_inc pgen = find_executable( 'pgen', os.pathsep.join([ os.environ['PATH'], os.path.join(get_python_inc(), '..', 'Parser') ])) if not pgen: sys.stderr.write( "Unable to find pgen, not compiling formal grammar.\n") else: parser_dir = os.path.join(os.path.dirname(__file__), 'Cython', 'Parser') grammar = os.path.join(parser_dir, 'Grammar') subprocess.check_call([ pgen, os.path.join(grammar), os.path.join(parser_dir, 'graminit.h'), os.path.join(parser_dir, 'graminit.c'), ]) cst_pyx = os.path.join(parser_dir, 'ConcreteSyntaxTree.pyx') if os.stat(grammar)[stat.ST_MTIME] > os.stat(cst_pyx)[stat.ST_MTIME]: mtime = os.stat(grammar)[stat.ST_MTIME] os.utime(cst_pyx, (mtime, mtime)) compiled_modules.extend([ "Cython.Parser.ConcreteSyntaxTree", ]) defines = [] if cython_with_refnanny: defines.append(('CYTHON_REFNANNY', '1')) if coverage: defines.append(('CYTHON_TRACE', '1')) extensions = [] for module in compiled_modules: source_file = os.path.join(source_root, *module.split('.')) if os.path.exists(source_file + ".py"): pyx_source_file = source_file + ".py" else: pyx_source_file = source_file + ".pyx" dep_files = [] if os.path.exists(source_file + '.pxd'): dep_files.append(source_file + '.pxd') if '.refnanny' in module: defines_for_module = [] else: defines_for_module = defines extensions.append( Extension(module, sources=[pyx_source_file], define_macros=defines_for_module, depends=dep_files)) # XXX hack around setuptools quirk for '*.pyx' sources extensions[-1].sources[0] = pyx_source_file from Cython.Distutils.build_ext import new_build_ext from Cython.Compiler.Options import get_directive_defaults get_directive_defaults().update( language_level=2, binding=False, always_allow_keywords=False, autotestdict=False, ) if profile: get_directive_defaults()['profile'] = True sys.stderr.write("Enabled profiling for the Cython binary modules\n") if coverage: get_directive_defaults()['linetrace'] = True sys.stderr.write( "Enabled line tracing and profiling for the Cython binary modules\n" ) # not using cythonize() directly to let distutils decide whether building extensions was requested add_command_class("build_ext", new_build_ext) setup_args['ext_modules'] = extensions
def compile_cython_modules(profile=False, compile_more=False, cython_with_refnanny=False): source_root = os.path.abspath(os.path.dirname(__file__)) compiled_modules = [ "Cython.Plex.Scanners", "Cython.Plex.Actions", "Cython.Compiler.Lexicon", "Cython.Compiler.Scanning", "Cython.Compiler.Parsing", "Cython.Compiler.Visitor", "Cython.Compiler.FlowControl", "Cython.Compiler.Code", "Cython.Runtime.refnanny", # "Cython.Compiler.FusedNode", "Cython.Tempita._tempita", ] if compile_more: compiled_modules.extend([ "Cython.Build.Dependencies", "Cython.Compiler.ParseTreeTransforms", "Cython.Compiler.Nodes", "Cython.Compiler.ExprNodes", "Cython.Compiler.ModuleNode", "Cython.Compiler.Optimize", ]) from distutils.spawn import find_executable from distutils.sysconfig import get_python_inc pgen = find_executable( 'pgen', os.pathsep.join([os.environ['PATH'], os.path.join(get_python_inc(), '..', 'Parser')])) if not pgen: sys.stderr.write("Unable to find pgen, not compiling formal grammar.\n") else: parser_dir = os.path.join(os.path.dirname(__file__), 'Cython', 'Parser') grammar = os.path.join(parser_dir, 'Grammar') subprocess.check_call([ pgen, os.path.join(grammar), os.path.join(parser_dir, 'graminit.h'), os.path.join(parser_dir, 'graminit.c'), ]) cst_pyx = os.path.join(parser_dir, 'ConcreteSyntaxTree.pyx') if os.stat(grammar)[stat.ST_MTIME] > os.stat(cst_pyx)[stat.ST_MTIME]: mtime = os.stat(grammar)[stat.ST_MTIME] os.utime(cst_pyx, (mtime, mtime)) compiled_modules.extend([ "Cython.Parser.ConcreteSyntaxTree", ]) defines = [] if cython_with_refnanny: defines.append(('CYTHON_REFNANNY', '1')) extensions = [] for module in compiled_modules: source_file = os.path.join(source_root, *module.split('.')) if os.path.exists(source_file + ".py"): pyx_source_file = source_file + ".py" else: pyx_source_file = source_file + ".pyx" dep_files = [] if os.path.exists(source_file + '.pxd'): dep_files.append(source_file + '.pxd') if '.refnanny' in module: defines_for_module = [] else: defines_for_module = defines extensions.append(Extension( module, sources=[pyx_source_file], define_macros=defines_for_module, depends=dep_files)) # XXX hack around setuptools quirk for '*.pyx' sources extensions[-1].sources[0] = pyx_source_file if sys.version_info[:2] == (3, 2): # Python 3.2: can only run Cython *after* running 2to3 build_ext = _defer_cython_import_in_py32(source_root, profile) else: from Cython.Distutils import build_ext if profile: from Cython.Compiler.Options import get_directive_defaults get_directive_defaults()['profile'] = True sys.stderr.write("Enabled profiling for the Cython binary modules\n") # not using cythonize() here to let distutils decide whether building extensions was requested add_command_class("build_ext", build_ext) setup_args['ext_modules'] = extensions
use_cython = False if use_cython: suffix = '.pyx' else: suffix = '.c' ext_modules = [] for modname in ['dicttoolz', 'functoolz', 'itertoolz', 'recipes', 'utils']: ext_modules.append(Extension('cytoolz.' + modname.replace('/', '.'), ['cytoolz/' + modname + suffix])) if use_cython: try: from Cython.Compiler.Options import get_directive_defaults directive_defaults = get_directive_defaults() except ImportError: # for Cython < 0.25 from Cython.Compiler.Options import directive_defaults directive_defaults['embedsignature'] = True directive_defaults['binding'] = True ext_modules = cythonize(ext_modules) setup( name='cytoolz', version=VERSION, description=('Cython implementation of Toolz: ' 'High performance functional utilities'), ext_modules=ext_modules, long_description=(open('README.rst').read() if os.path.exists('README.rst')
from distutils.core import setup from distutils.extension import Extension from Cython.Build import cythonize from Cython.Distutils import build_ext import numpy as np from Cython.Compiler.Options import get_directive_defaults get_directive_defaults()['binding'] = True get_directive_defaults()['linetrace'] = True extensions = [ Extension("weights", ["spectacle/weights.pyx"], define_macros=[('CYTHON_TRACE', '1')]) ] setup( name='spectacle', version='0.1', author='Christopher Lovell', cmdclass={'build_ext': build_ext}, packages=['spectacle'], ext_modules=cythonize(extensions), include_dirs=[np.get_include()], )
import os from glob import glob from os.path import basename, join, splitext from setuptools import find_packages, setup from Cython.Distutils.extension import Extension from Cython.Distutils import build_ext version = '0.1.8' package_data = [] from Cython.Compiler.Options import get_directive_defaults get_directive_defaults()['linetrace'] = True get_directive_defaults()['binding'] = True if sys.platform == 'win32': libs = [] extra_link_args = ['/debug', '/Zi'] bison2pyscript = 'utils/bison2py' bisondynlibModule = 'src/bison/c/bisondynlib-win32.c' extra_compile_args = ['/Od', '/Zi', '-D__builtin_expect(a,b)=(a)', '/DCYTHON_TRACE=1'] for root, dirs, files in os.walk('src/bison/winflexbison'): package_data.extend(join(root.replace('src/bison/', ''), f) for f in files) elif sys.platform.startswith('linux'): # python2 reports "linux2" libs = ['dl'] extra_link_args = []