當前位置: 首頁>>代碼示例>>Python>>正文


Python core.Extension方法代碼示例

本文整理匯總了Python中distutils.core.Extension方法的典型用法代碼示例。如果您正苦於以下問題:Python core.Extension方法的具體用法?Python core.Extension怎麽用?Python core.Extension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在distutils.core的用法示例。


在下文中一共展示了core.Extension方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_extensions

# 需要導入模塊: from distutils import core [as 別名]
# 或者: from distutils.core import Extension [as 別名]
def get_extensions():

    libraries = []

    sources = [os.path.join(C_DIR, filename) for filename in C_FILES]
    sources.append(os.path.join(HEALPIX_ROOT, 'interpolation.c'))
    sources.append(os.path.join(HEALPIX_ROOT, '_core.c'))

    extension = Extension(
        name="astropy_healpix._core",
        sources=sources,
        include_dirs=C_DIRS,
        libraries=libraries,
        language="c",
        extra_compile_args=['-O2'])

    return [extension] 
開發者ID:astropy,項目名稱:astropy-healpix,代碼行數:19,代碼來源:setup_package.py

示例2: setUp

# 需要導入模塊: from distutils import core [as 別名]
# 或者: from distutils.core import Extension [as 別名]
def setUp(self):
        self.req = Require('Distutils','1.0.3','distutils')
        self.dist = makeSetup(
            features={
                'foo': Feature("foo",standard=True,require_features=['baz',self.req]),
                'bar': Feature("bar",  standard=True, packages=['pkg.bar'],
                               py_modules=['bar_et'], remove=['bar.ext'],
                       ),
                'baz': Feature(
                        "baz", optional=False, packages=['pkg.baz'],
                        scripts = ['scripts/baz_it'],
                        libraries=[('libfoo','foo/foofoo.c')]
                       ),
                'dwim': Feature("DWIM", available=False, remove='bazish'),
            },
            script_args=['--without-bar', 'install'],
            packages = ['pkg.bar', 'pkg.foo'],
            py_modules = ['bar_et', 'bazish'],
            ext_modules = [Extension('bar.ext',['bar.c'])]
        ) 
開發者ID:MayOneUS,項目名稱:pledgeservice,代碼行數:22,代碼來源:__init__.py

示例3: _fixup_command

# 需要導入模塊: from distutils import core [as 別名]
# 或者: from distutils.core import Extension [as 別名]
def _fixup_command(self, cmd):
        # When Python was build with --enable-shared, -L. is not good enough
        # to find the libpython<blah>.so.  This is because regrtest runs it
        # under a tempdir, not in the top level where the .so lives.  By the
        # time we've gotten here, Python's already been chdir'd to the
        # tempdir.
        #
        # To further add to the fun, we can't just add library_dirs to the
        # Extension() instance because that doesn't get plumbed through to the
        # final compiler command.
        if (sysconfig.get_config_var('Py_ENABLE_SHARED') and
            not sys.platform.startswith('win')):
            runshared = sysconfig.get_config_var('RUNSHARED')
            if runshared is None:
                cmd.library_dirs = ['.']
            else:
                name, equals, value = runshared.partition('=')
                cmd.library_dirs = value.split(os.pathsep) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:20,代碼來源:test_build_ext.py

示例4: _set_py_limited_api

# 需要導入模塊: from distutils import core [as 別名]
# 或者: from distutils.core import Extension [as 別名]
def _set_py_limited_api(Extension, kwds):
    """
    Add py_limited_api to kwds if setuptools >= 26 is in use.
    Do not alter the setting if it already exists.
    Setuptools takes care of ignoring the flag on Python 2 and PyPy.

    CPython itself should ignore the flag in a debugging version
    (by not listing .abi3.so in the extensions it supports), but
    it doesn't so far, creating troubles.  That's why we check
    for "not sys.flags.debug". (http://bugs.python.org/issue28401)
    """
    if 'py_limited_api' not in kwds and not sys.flags.debug:
        import setuptools
        try:
            setuptools_major_version = int(setuptools.__version__.partition('.')[0])
            if setuptools_major_version >= 26:
                kwds['py_limited_api'] = True
        except ValueError:  # certain development versions of setuptools
            # If we don't know the version number of setuptools, we
            # try to set 'py_limited_api' anyway.  At worst, we get a
            # warning.
            kwds['py_limited_api'] = True
    return kwds 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:25,代碼來源:setuptools_ext.py

示例5: make_extension

# 需要導入模塊: from distutils import core [as 別名]
# 或者: from distutils.core import Extension [as 別名]
def make_extension(name, files, *args, **kwargs):
    """
    Make a new extension.  Automatically sets include_dirs and
    library_dirs to the base directories appropriate for this
    platform.

    `name` is the name of the extension.

    `files` is a list of source files.

    Any additional arguments are passed to the
    `distutils.core.Extension` constructor.
    """
    ext = DelayedExtension(name, files, *args, **kwargs)
    for dir in get_base_dirs():
        include_dir = os.path.join(dir, 'include')
        if os.path.exists(include_dir):
            ext.include_dirs.append(include_dir)
        for lib in ('lib', 'lib64'):
            lib_dir = os.path.join(dir, lib)
            if os.path.exists(lib_dir):
                ext.library_dirs.append(lib_dir)
    ext.include_dirs.append('.')

    return ext 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:27,代碼來源:setupext.py

示例6: include_dirs_hook

# 需要導入模塊: from distutils import core [as 別名]
# 或者: from distutils.core import Extension [as 別名]
def include_dirs_hook():
        if hasattr(builtins, '__NUMPY_SETUP__'):
            del builtins.__NUMPY_SETUP__
        import numpy
        importlib.reload(numpy)

        ext = Extension('test', [])
        # ext.include_dirs.append(numpy.get_include())
        #iOS: 
        ext.include_dirs.append('../../onIpad/lib/python3.7/site-packages/numpy-1.16.0-py3.7-macosx-10.9-x86_64.egg/numpy/core/include/')
        print("Include dirs found: ", numpy.get_include())
        if not has_include_file(
                ext.include_dirs, os.path.join("numpy", "arrayobject.h")):
            warnings.warn(
                "The C headers for numpy could not be found. "
                "You may need to install the development package")
        #iOS: 
        return ['../../onIpad/lib/python3.7/site-packages/numpy-1.16.0-py3.7-macosx-10.9-x86_64.egg/numpy/core/include/']
        # return [numpy.get_include()] 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:21,代碼來源:setupext.py

示例7: generate

# 需要導入模塊: from distutils import core [as 別名]
# 或者: from distutils.core import Extension [as 別名]
def generate(self, run_cc=True, build_python=False, generate_c=True):
        filename = ('py'+self.name if build_python else self.name) + '.c'
        if generate_c:
            with open(filename, 'w') as f:
                print('Generating C code to %s...' % f.name, file=sys.stderr)
                self.c_emit(f, build_python)
                f.flush()
        if run_cc and not build_python:
            command = [self.cc] + self.cflags + [
                    '-I', os.path.realpath(os.path.dirname(sys.argv[0])),
                    '-o', self.name, filename]
            print(' '.join(command), file=sys.stderr)
            subprocess.call(command)
        elif run_cc and build_python:
            from distutils.core import setup, Extension
            tagger = Extension(
                    self.name,
                    sources = [filename],
                    libraries = [],
                    extra_compile_args = self.cflags,
                    extra_link_args = [])
            setup(name = self.name, ext_modules = [tagger],
                  script_args = ['build_ext', '--inplace']) 
開發者ID:robertostling,項目名稱:efselab,代碼行數:25,代碼來源:configuration.py

示例8: _set_py_limited_api

# 需要導入模塊: from distutils import core [as 別名]
# 或者: from distutils.core import Extension [as 別名]
def _set_py_limited_api(Extension, kwds):
    """
    Add py_limited_api to kwds if setuptools >= 26 is in use.
    Do not alter the setting if it already exists.
    Setuptools takes care of ignoring the flag on Python 2 and PyPy.

    CPython itself should ignore the flag in a debugging version
    (by not listing .abi3.so in the extensions it supports), but
    it doesn't so far, creating troubles.  That's why we check
    for "not hasattr(sys, 'gettotalrefcount')" (the 2.7 compatible equivalent
    of 'd' not in sys.abiflags). (http://bugs.python.org/issue28401)
    """
    if 'py_limited_api' not in kwds and not hasattr(sys, 'gettotalrefcount'):
        import setuptools
        try:
            setuptools_major_version = int(setuptools.__version__.partition('.')[0])
            if setuptools_major_version >= 26:
                kwds['py_limited_api'] = True
        except ValueError:  # certain development versions of setuptools
            # If we don't know the version number of setuptools, we
            # try to set 'py_limited_api' anyway.  At worst, we get a
            # warning.
            kwds['py_limited_api'] = True
    return kwds 
開發者ID:aws-quickstart,項目名稱:quickstart-git2s3,代碼行數:26,代碼來源:setuptools_ext.py

示例9: test_build_ext

# 需要導入模塊: from distutils import core [as 別名]
# 或者: from distutils.core import Extension [as 別名]
def test_build_ext(self):
        global ALREADY_TESTED
        support.copy_xxmodule_c(self.tmp_dir)
        self.xx_created = True
        xx_c = os.path.join(self.tmp_dir, 'xxmodule.c')
        xx_ext = Extension('xx', [xx_c])
        dist = Distribution({'name': 'xx', 'ext_modules': [xx_ext]})
        dist.package_dir = self.tmp_dir
        cmd = build_ext(dist)
        support.fixup_build_ext(cmd)
        cmd.build_lib = self.tmp_dir
        cmd.build_temp = self.tmp_dir

        old_stdout = sys.stdout
        if not test_support.verbose:
            # silence compiler output
            sys.stdout = StringIO()
        try:
            cmd.ensure_finalized()
            cmd.run()
        finally:
            sys.stdout = old_stdout

        if ALREADY_TESTED:
            self.skipTest('Already tested in %s' % ALREADY_TESTED)
        else:
            ALREADY_TESTED = type(self).__name__

        import xx

        for attr in ('error', 'foo', 'new', 'roj'):
            self.assertTrue(hasattr(xx, attr))

        self.assertEqual(xx.foo(2, 5), 7)
        self.assertEqual(xx.foo(13,15), 28)
        self.assertEqual(xx.new().demo(), None)
        if test_support.HAVE_DOCSTRINGS:
            doc = 'This is a template module just for instruction.'
            self.assertEqual(xx.__doc__, doc)
        self.assertIsInstance(xx.Null(), xx.Null)
        self.assertIsInstance(xx.Str(), xx.Str) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:43,代碼來源:test_build_ext.py

示例10: test_get_source_files

# 需要導入模塊: from distutils import core [as 別名]
# 或者: from distutils.core import Extension [as 別名]
def test_get_source_files(self):
        modules = [Extension('foo', ['xxx'])]
        dist = Distribution({'name': 'xx', 'ext_modules': modules})
        cmd = build_ext(dist)
        cmd.ensure_finalized()
        self.assertEqual(cmd.get_source_files(), ['xxx']) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:8,代碼來源:test_build_ext.py

示例11: test_build_ext_inplace

# 需要導入模塊: from distutils import core [as 別名]
# 或者: from distutils.core import Extension [as 別名]
def test_build_ext_inplace(self):
        etree_c = os.path.join(self.tmp_dir, 'lxml.etree.c')
        etree_ext = Extension('lxml.etree', [etree_c])
        dist = Distribution({'name': 'lxml', 'ext_modules': [etree_ext]})
        cmd = build_ext(dist)
        cmd.ensure_finalized()
        cmd.inplace = 1
        cmd.distribution.package_dir = {'': 'src'}
        cmd.distribution.packages = ['lxml', 'lxml.html']
        curdir = os.getcwd()
        ext = sysconfig.get_config_var("SO")
        wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + ext)
        path = cmd.get_ext_fullpath('lxml.etree')
        self.assertEqual(wanted, path) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:16,代碼來源:test_build_ext.py

示例12: test_setuptools_compat

# 需要導入模塊: from distutils import core [as 別名]
# 或者: from distutils.core import Extension [as 別名]
def test_setuptools_compat(self):
        import distutils.core, distutils.extension, distutils.command.build_ext
        saved_ext = distutils.extension.Extension
        try:
            # on some platforms, it loads the deprecated "dl" module
            test_support.import_module('setuptools_build_ext', deprecated=True)

            # theses import patch Distutils' Extension class
            from setuptools_build_ext import build_ext as setuptools_build_ext
            from setuptools_extension import Extension

            etree_c = os.path.join(self.tmp_dir, 'lxml.etree.c')
            etree_ext = Extension('lxml.etree', [etree_c])
            dist = Distribution({'name': 'lxml', 'ext_modules': [etree_ext]})
            cmd = setuptools_build_ext(dist)
            cmd.ensure_finalized()
            cmd.inplace = 1
            cmd.distribution.package_dir = {'': 'src'}
            cmd.distribution.packages = ['lxml', 'lxml.html']
            curdir = os.getcwd()
            ext = sysconfig.get_config_var("SO")
            wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + ext)
            path = cmd.get_ext_fullpath('lxml.etree')
            self.assertEqual(wanted, path)
        finally:
            # restoring Distutils' Extension class otherwise its broken
            distutils.extension.Extension = saved_ext
            distutils.core.Extension = saved_ext
            distutils.command.build_ext.Extension = saved_ext 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:31,代碼來源:test_build_ext.py

示例13: _set_py_limited_api

# 需要導入模塊: from distutils import core [as 別名]
# 或者: from distutils.core import Extension [as 別名]
def _set_py_limited_api(Extension, kwds):
    """
    Add py_limited_api to kwds if setuptools >= 26 is in use.
    Do not alter the setting if it already exists.
    Setuptools takes care of ignoring the flag on Python 2 and PyPy.

    CPython itself should ignore the flag in a debugging version
    (by not listing .abi3.so in the extensions it supports), but
    it doesn't so far, creating troubles.  That's why we check
    for "not hasattr(sys, 'gettotalrefcount')" (the 2.7 compatible equivalent
    of 'd' not in sys.abiflags). (http://bugs.python.org/issue28401)

    On Windows, it's better not to use py_limited_api until issue #355
    can be resolved (by having virtualenv copy PYTHON3.DLL).  See also
    the start of _cffi_include.h.
    """
    if ('py_limited_api' not in kwds and not hasattr(sys, 'gettotalrefcount')
            and sys.platform != 'win32'):
        import setuptools
        try:
            setuptools_major_version = int(setuptools.__version__.partition('.')[0])
            if setuptools_major_version >= 26:
                kwds['py_limited_api'] = True
        except ValueError:  # certain development versions of setuptools
            # If we don't know the version number of setuptools, we
            # try to set 'py_limited_api' anyway.  At worst, we get a
            # warning.
            kwds['py_limited_api'] = True
    return kwds 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:31,代碼來源:setuptools_ext.py

示例14: get_extension

# 需要導入模塊: from distutils import core [as 別名]
# 或者: from distutils.core import Extension [as 別名]
def get_extension(srcfilename, modname, sources=(), **kwds):
    _hack_at_distutils()
    from distutils.core import Extension
    allsources = [srcfilename]
    for src in sources:
        allsources.append(os.path.normpath(src))
    return Extension(name=modname, sources=allsources, **kwds) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:9,代碼來源:ffiplatform.py

示例15: get_extension

# 需要導入模塊: from distutils import core [as 別名]
# 或者: from distutils.core import Extension [as 別名]
def get_extension(srcfilename, modname, sources=(), **kwds):
    from distutils.core import Extension
    allsources = [srcfilename]
    for src in sources:
        allsources.append(os.path.normpath(src))
    return Extension(name=modname, sources=allsources, **kwds) 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:8,代碼來源:ffiplatform.py


注:本文中的distutils.core.Extension方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。