本文整理汇总了Python中setuptools.Extension类的典型用法代码示例。如果您正苦于以下问题:Python Extension类的具体用法?Python Extension怎么用?Python Extension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Extension类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, *args, **kwargs):
from numpy import get_include
from numpy.distutils.misc_util import get_info
kwargs.update(get_info('npymath'))
kwargs['include_dirs'] += [get_include()]
Extension.__init__(self, *args, **kwargs)
示例2: __init__
def __init__(self, *args, **kwargs):
if 'error' in kwargs:
self.error = kwargs['error']
del kwargs['error']
args = ('Cannot be built', [])
_Extension.__init__(self, *args, **kwargs)
示例3: __init__
def __init__(self, *args, **kwargs):
self._include_dirs = []
eprsrcdir = kwargs.pop('eprsrcdir', None)
Extension.__init__(self, *args, **kwargs)
if not any('epr_' in src for src in self.sources):
self.sources.extend(self._extra_sources(eprsrcdir))
self.setup_requires_cython = False
示例4: __init__
def __init__(self, *args, **kwargs):
Extension.__init__(self, *args, **kwargs)
self.cython_directives = {
'c_string_encoding': 'utf-8',
'profile': 'USE_PROFILE' in environ,
'embedsignature': 'USE_EMBEDSIGNATURE' in environ}
# XXX with pip, setuptools is imported before distutils, and change
# our pyx to c, then, cythonize doesn't happen. So force again our
# sources
self.sources = args[1]
示例5: __init__
def __init__(self, key, **opts):
self.boodler_key = key
modname = 'boodle.cboodle_'+key
ls = ['audev-'+key, 'cboodle-'+key, 'noteq', 'sample']
ls = [ ('src/cboodle/' + val + '.c') for val in ls ]
avail = opts.pop('available', None)
if (avail):
self.ext_available = avail
Extension.__init__(self, modname, ls, **opts)
示例6: __init__
def __init__(self, name):
# Describe the extension
sources = [
'rl/readline.c',
'rl/stringarray.c',
'rl/unicode.c',
'rl/iterator.c',
'rl/modulestate.c',
]
Extension.__init__(self, name, sources)
# Use include and library dirs from Python build
self.use_include_dirs()
self.use_library_dirs()
# Use Mac Python library dir
if sys.platform == 'darwin':
if sys_path_contains('/Library/Frameworks/Python.framework'):
self.library_dirs.append(
'/Library/Frameworks/Python.framework/Versions/%d.%d/lib' % sys.version_info[:2])
self.use_static_readline()
self.suppress_warnings()
self.strip_debug_symbols()
示例7: __init__
def __init__(self, *args, **kwargs):
self.libraries = []
self.define_macros = []
# Python 2 has this as an old-style class for some reason
# so super() doesn't work.
_Extension.__init__(self, *args, **kwargs) # pylint:disable=no-member,non-parent-init-called
示例8: print
print("Done!")
if not os.path.isdir(SQLPARSER_DIR):
download_library()
# check again (the user might have downloaded the library)
if os.path.isdir(SQLPARSER_DIR):
parsebridge = Extension('sqlparser',
sources = ['Parser.c', 'Statement.c', 'Node.c', 'ENodeType.c', 'parsebridgemodule.c',
SQLPARSER_DIR + 'ext/node_visitor/node_visitor.c',
SQLPARSER_DIR + 'ext/expr_traverse/expr_traverse.c',
SQLPARSER_DIR + 'ext/modifysql/modifysql.c' ],
include_dirs = [ SQLPARSER_DIR + 'core/',
SQLPARSER_DIR + 'ext/collection/includes/',
SQLPARSER_DIR + 'ext/expr_traverse/',
SQLPARSER_DIR + 'ext/modifysql/',
SQLPARSER_DIR + 'ext/node_visitor/' ],
library_dirs = [ SQLPARSER_DIR + '/lib/' ],
libraries = [ 'gspcollection', 'gspcore' ],
define_macros = [ ('_CRT_SECURE_NO_WARNINGS', None), ('DONT_FIX_FRAGMENTS', None), ],
extra_compile_args = ['-Wno-strict-prototypes'],
)
if sys.platform == 'win32' or sys.platform == 'win64':
parsebridge.extra_link_args = [ '/MANIFEST', '/DEBUG' ]
parsebridge.extra_compile_args = [ '/Zi' ]
setup (name = 'sqlparser',
version = '1.0',
description = 'A package for parsing SQL queries',
示例9: __init__
def __init__(self, *args, **kwargs):
self.avx2_defs = kwargs.pop("avx2_defs", {})
Extension.__init__(self, *args, **kwargs)
示例10: build_extensions
#.........这里部分代码省略.........
for d in os.environ[k].split(os.path.pathsep):
_add_directory(library_dirs, d)
prefix = dsc.get_config_var("prefix")
if prefix:
_add_directory(library_dirs, os.path.join(prefix, "lib"))
_add_directory(include_dirs, os.path.join(prefix, "include"))
if sys.platform == "darwin":
# fink installation directories
_add_directory(library_dirs, "/sw/lib")
_add_directory(include_dirs, "/sw/include")
# darwin ports installation directories
_add_directory(library_dirs, "/opt/local/lib")
_add_directory(include_dirs, "/opt/local/include")
# if Homebrew is installed, use its lib and include directories
import subprocess
try:
prefix = subprocess.check_output(
['brew', '--prefix']
).strip().decode('latin1')
except:
# Homebrew not installed
prefix = None
if prefix:
# add Homebrew's include and lib directories
_add_directory(library_dirs, os.path.join(prefix, 'lib'))
_add_directory(include_dirs, os.path.join(prefix, 'include'))
elif sys.platform.startswith("linux"):
arch_tp = (plat.processor(), plat.architecture()[0])
if arch_tp == ("x86_64", "32bit"):
# 32 bit build on 64 bit machine.
_add_directory(library_dirs, "/usr/lib/i386-linux-gnu")
else:
for platform_ in arch_tp:
if not platform_:
continue
if platform_ in ["x86_64", "64bit"]:
_add_directory(library_dirs, "/lib64")
_add_directory(library_dirs, "/usr/lib64")
_add_directory(
library_dirs, "/usr/lib/x86_64-linux-gnu")
break
elif platform_ in ["i386", "i686", "32bit"]:
_add_directory(
library_dirs, "/usr/lib/i386-linux-gnu")
break
elif platform_ in ["aarch64"]:
_add_directory(library_dirs, "/usr/lib64")
_add_directory(
library_dirs, "/usr/lib/aarch64-linux-gnu")
break
else:
raise ValueError(
"Unable to identify Linux platform: `%s`" % platform_)
self.compiler.library_dirs = library_dirs + self.compiler.library_dirs
self.compiler.include_dirs = include_dirs + self.compiler.include_dirs
pylib = "python{}".format(sys.version[:3])
if sys.version[:3] == '3.4':
pylib += 'm'
libs = [pylib]
if _find_include_file(self, "jpeglib.h"):
if _find_library_file(self, "jpeg"):
libs.append('jpeg')
else:
raise ValueError("Unable to find libjpeg")
else:
raise ValueError("Unable to find jpeglib.h")
if _find_include_file(self, "boost/thread.hpp"):
if _find_library_file(self, "boost_thread"):
libs.append("boost_thread")
elif _find_library_file(self, "boost_thread-mt"):
libs.append("boost_thread-mt")
else:
raise ValueError("Unable to find libboost_thread")
if _find_library_file(self, "boost_system"):
libs.append("boost_system")
elif _find_library_file(self, "boost_system-mt"):
libs.append("boost_system-mt")
else:
raise ValueError("Unable to find libboost_system")
else:
raise ValueError("Unable to find boost headers")
print(libs)
iwt = Extension('_ImgWorker', sources=['imgworker.cpp'],
include_dirs=self.compiler.include_dirs,
library_dirs=self.compiler.library_dirs,
libraries=libs)
iwt._needs_stub = False
exts = [iwt]
self.extensions[:] = exts
build_ext.build_extensions(self)
示例11: custom_build_ext
# run the customize_compiler
class custom_build_ext(build_ext):
def build_extensions(self):
customize_compiler_for_nvcc(self.compiler)
build_ext.build_extensions(self)
cmdclass = {}
if sys.platform.startswith('win') and os.path.exists(win_cuda_dir):
arch = int(platform.architecture()[0][0:2])
ts_module = Extension('_trottersuzuki_wrap',
sources=['trottersuzuki/trottersuzuki_wrap.cxx'],
extra_objects=['trottersuzuki/src/common.obj',
'trottersuzuki/src/cpublock.obj',
'trottersuzuki/src/model.obj',
'trottersuzuki/src/solver.obj',
'trottersuzuki/src/hybrid.cu.obj',
'trottersuzuki/src/cc2kernel.cu.obj'],
define_macros=[('CUDA', None)],
library_dirs=[win_cuda_dir+"/lib/x"+str(arch)],
libraries=['cudart', 'cublas'],
include_dirs=[numpy_include])
else:
if sys.platform.startswith('win'):
extra_compile_args = ['-openmp', '-DWIN32']
libraries = None
elif sys.platform.startswith('darwin') and 'CC' not in os.environ:
extra_compile_args = {'cc': []}
libraries = None
else:
extra_compile_args = {'cc': ['-fopenmp']}
if 'CC' in os.environ and 'clang-omp' in os.environ['CC']:
示例12: __init__
def __init__(self, name, cmd, cwd=".", output_dir=".", env=None):
Extension.__init__(self, name, sources=[])
self.cmd = cmd
self.cwd = path.normpath(cwd)
self.output_dir = path.normpath(output_dir)
self.env = env or dict(os.environ)
示例13: Extension
import warnings
try:
from Cython.Distutils import build_ext
from setuptools import setup, Extension
HAVE_CYTHON = True
except ImportError as e:
warnings.warn(e.message)
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
HAVE_CYTHON = False
import numpy
_hdbscan_tree = Extension('hdbscan._hdbscan_tree',
sources=['hdbscan/_hdbscan_tree.pyx'],
include_dirs=[numpy.get_include()])
_hdbscan_linkage = Extension('hdbscan._hdbscan_linkage',
sources=['hdbscan/_hdbscan_linkage.pyx'],
include_dirs=['hdbscan', numpy.get_include()])
_hdbscan_boruvka = Extension('hdbscan._hdbscan_boruvka',
sources=['hdbscan/_hdbscan_boruvka.pyx'],
include_dirs=['hdbscan', numpy.get_include()])
_hdbscan_reachability = Extension('hdbscan._hdbscan_reachability',
sources=['hdbscan/_hdbscan_reachability.pyx'],
include_dirs=[numpy.get_include()])
dist_metrics = Extension('hdbscan.dist_metrics',
sources=['hdbscan/dist_metrics.pyx'],
include_dirs=[numpy.get_include()])
def readme():
示例14: print
print('Readthedocs environment: %s' % (rtd,))
if 'VSC_SCRATCH' in os.environ.keys():
# we are running on the VSC cluster
zlibdir = os.environ.get('EBROOTZLIB') # SOFTROOTZLIB
libraries = ['z']
library_dirs = [zlibdir + '/lib']
include_dirs = ['.', 'src', npinclude, zlibdir + '/include']
else:
libraries = []
library_dirs = []
include_dirs = ['.', 'src', npinclude]
oalib_module = Extension('_oalib', sources=sources,
include_dirs=include_dirs, library_dirs=library_dirs, libraries=libraries, swig_opts=swig_opts
)
compile_options += ['-DNOOMP']
swig_opts += ['-DNOOMP']
oalib_module.extra_compile_args = compile_options
if checkZlib(verbose=1):
if platform.system() == 'Windows':
pass
else:
zlibflag = '-DUSEZLIB'
oalib_module.extra_compile_args += [zlibflag]
swig_opts += [zlibflag]
oalib_module.extra_link_args += ['-lz']
示例15: expand
if sys.platform == 'win32':
libraries += ['ws2_32']
define_macros += [('FD_SETSIZE', '1024'), ('_WIN32', '1')]
def expand(*lst):
result = []
for item in lst:
for name in sorted(glob(item)):
result.append(name)
return result
CORE = Extension(name='gevent.core',
sources=['gevent/gevent.corecext.c'],
include_dirs=['libev'] if LIBEV_EMBED else [],
libraries=libraries,
define_macros=define_macros,
depends=expand('gevent/callbacks.*', 'gevent/stathelper.c', 'gevent/libev*.h', 'libev/*.*'))
# QQQ libev can also use -lm, however it seems to be added implicitly
ARES = Extension(name='gevent.ares',
sources=['gevent/gevent.ares.c'],
include_dirs=['c-ares'] if CARES_EMBED else [],
libraries=libraries,
define_macros=define_macros,
depends=expand('gevent/dnshelper.c', 'gevent/cares_*.*'))
ARES.optional = True
def make_universal_header(filename, *defines):
defines = [('#define %s ' % define, define) for define in defines]