当前位置: 首页>>代码示例>>Python>>正文


Python core.Extension类代码示例

本文整理汇总了Python中distutils.core.Extension的典型用法代码示例。如果您正苦于以下问题:Python Extension类的具体用法?Python Extension怎么用?Python Extension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Extension类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: no_cythonize

def no_cythonize(extensions, **_ignore):
    new_extensions = []
    for extension in extensions:
        curr_lang = extension.language
        if curr_lang is None:
            curr_lang = "c"
        curr_lang = "c++"
        ext_copy = \
          Extension(extension.name,
                    extension.sources,
                    language=curr_lang,
                    include_dirs=extension.include_dirs,
                    library_dirs=extension.library_dirs)
        sources = []
        for sfile in ext_copy.sources:
            path, ext = os.path.splitext(sfile)
            new_sfile = sfile
            if ext in ('.pyx', '.py'):
                if extension.language == 'c++':
                    ext = '.cpp'
                else:
                    ext = '.c'
                new_sfile = path + ext
            sources.append(new_sfile)
        ext_copy.sources[:] = sources
        print "BUILDING %s" %(ext_copy.language)
        new_extensions.append(ext_copy)
    return new_extensions
开发者ID:yarden,项目名称:learn_cython,代码行数:28,代码来源:setup.py

示例2: get_extensions

def get_extensions():

    med_sources = [str(os.path.join(UTIL_DIR, "median_utils.pyx")),
                   str(os.path.join(UTIL_DIR, "quick_select.c"))]

    include_dirs = ['numpy', UTIL_DIR]

    libraries = []

    ext_med = Extension(name=str('banzai.utils.median_utils'),
                        sources=med_sources,
                        include_dirs=include_dirs,
                        libraries=libraries,
                        language="c",
                        extra_compile_args=['-g', '-O3', '-funroll-loops', '-ffast-math'])

    has_openmp, outputs = check_openmp()
    if has_openmp:
        if setup_helpers.get_compiler_option() == 'msvc':
            ext_med.extra_compile_args.append('-openmp')
        else:
            ext_med.extra_compile_args.append('-fopenmp')
            ext_med.extra_link_args = ['-g', '-fopenmp']
    else:
        log.warn('OpenMP was not found. '
                 'banzai will be compiled without OpenMP. '
                 '(Use the "-v" option of setup.py for more details.)')
        log.debug(('(Start of OpenMP info)\n'
                   'compiler stdout:\n{0}\n'
                   'compiler stderr:\n{1}\n'
                   '(End of OpenMP info)').format(*outputs))

    return [ext_med]
开发者ID:Fingel,项目名称:banzai,代码行数:33,代码来源:setup_package.py

示例3: __init__

    def __init__(self, system_libraries):
        self.__library_manifest__ = []
        sources = []
        libraries = set()
        extra_compile_args = []
        extra_link_args = []

        if system_libraries.present("libdvd-audio"):
            if system_libraries.guaranteed_present("libdvd-audio"):
                libraries.update(set(["libdvd-audio"]))
            else:
                extra_compile_args.extend(
                    system_libraries.extra_compile_args("libdvd-audio"))
                extra_link_args.extend(
                    system_libraries.extra_link_args("libdvd-audio"))

            sources.extend(["src/dvdamodule.c",
                            "src/framelist.c",
                            "src/pcm_conv.c"])

            self.__library_manifest__.append(("libdvd-audio",
                                              "DVD-Audio data extraction",
                                              True))
        else:
            self.__library_manifest__.append(("libdvd-audio",
                                              "DVD-Audio data extraction",
                                              False))

        Extension.__init__(
            self,
            "audiotools.dvda",
            sources=sources,
            libraries=list(libraries),
            extra_compile_args=extra_compile_args,
            extra_link_args=extra_link_args)
开发者ID:KristoforMaynard,项目名称:python-audio-tools,代码行数:35,代码来源:setup.py

示例4: __init__

    def __init__(self, root = ""):
        path = join(root, 'Onboard', 'osk')
        sources = [join(path, x) for x in self.sources]
        depends = [join(path, x) for x in self.depends]
        defines = self.defines

        # dconf had an API change between 0.12 and 0.13, tell osk
        major, minor, revision = get_pkg_version("dconf")
        if major == 0 and minor <= 12:
            defines.append(("DCONF_API_0", 0))
        print("found dconf version {}.{}.{}".format(major, minor, revision))

        Extension.__init__(self,
                           MODULE_NAME_OSK,

                           sources = sources,
                           depends = depends,
                           define_macros = defines,
                           extra_compile_args = [
                               "-Wdeclaration-after-statement",
                               "-Werror=declaration-after-statement"],

                           **pkgconfig('gdk-3.0', 'x11', 'xi', 'xtst', 'xkbfile',
                                       'dconf', 'libcanberra', 'hunspell')
                           )
开发者ID:jegger,项目名称:onboard,代码行数:25,代码来源:setup.py

示例5: __init__

 def __init__(self, *args, **kwargs):
     # bypass the patched init if possible
     if Extension.__bases__:
         base, = Extension.__bases__
         base.__init__(self, *args, **kwargs)
     else:
         Extension.__init__(self, *args, **kwargs)
开发者ID:coldeasy,项目名称:python-driver,代码行数:7,代码来源:setup.py

示例6: __init__

 def __init__(self):
     Extension.__init__(self,
                        "audiotools.verify",
                        sources=["src/verify.c",
                                 "src/bitstream.c",
                                 "src/buffer.c",
                                 "src/func_io.c"])
开发者ID:PengYingChuan,项目名称:python-audio-tools,代码行数:7,代码来源:setup.py

示例7: __init__

    def __init__(self, source_dir, include_dirs, library_dirs):
        if winbuild:
            apr1 = 0
            for dir in library_dirs:
                if os.path.exists(os.path.join(dir, 'libapr-1.lib')):
                    apr1 = 1
            if apr1:
                libraries = ['libhttpd', 'libapr-1', 'libaprutil-1', 'ws2_32']
            else:
                libraries = ['libhttpd', 'libapr', 'libaprutil', 'ws2_32']
        else:
            libraries = ['apr-0', 'aprutil-0']

        Extension.__init__(self, "mod_python_so",
            sources = [os.path.join(source_dir, source_file) for source_file in modpy_src_files],
                           include_dirs=include_dirs,
            libraries = libraries,
            library_dirs=library_dirs
                           )
        if winbuild:
            self.define_macros.extend([('WIN32', None),('NDEBUG', None),('_WINDOWS', None)])
            self.sources.append(os.path.join(source_dir, "Version.rc"))
        else:
            # TODO: fix this to autodetect if required...
            self.include_dirs.append("/usr/include/apr-0")
        # this is a hack to prevent build_ext from trying to append "initmod_python" to the export symbols
        self.export_symbols = finallist(self.export_symbols)
开发者ID:yinsen,项目名称:apache-text,代码行数:27,代码来源:setup.py

示例8: run_distutils

 def run_distutils(self, test_directory, module, workdir, incdir):
     cwd = os.getcwd()
     os.chdir(workdir)
     try:
         build_extension = build_ext(distutils_distro)
         build_extension.include_dirs = INCLUDE_DIRS[:]
         if incdir:
             build_extension.include_dirs.append(incdir)
         build_extension.finalize_options()
         ext_include_dirs = []
         for match, get_additional_include_dirs in EXT_DEP_INCLUDES:
             if match(module):
                 ext_include_dirs += get_additional_include_dirs()
         self.copy_related_files(test_directory, workdir, module)
         extension = Extension(
             module,
             sources = self.find_source_files(workdir, module),
             include_dirs = ext_include_dirs,
             extra_compile_args = CFLAGS,
             )
         if self.language == 'cpp':
             extension.language = 'c++'
         build_extension.extensions = [extension]
         build_extension.build_temp = workdir
         build_extension.build_lib  = workdir
         build_extension.run()
     finally:
         os.chdir(cwd)
开发者ID:ekohl,项目名称:essig,代码行数:28,代码来源:runtests.py

示例9: __init__

 def __init__(self, *args, **kwargs):
     for name, default in [("extra_pyxtract_cmds", []), ("lib_type", "dynamic")]:
         setattr(self, name, kwargs.get(name, default))
         if name in kwargs:    
             del kwargs[name]
         
     Extension.__init__(self, *args, **kwargs)
开发者ID:electricFeel,项目名称:BeatKeeperHRM,代码行数:7,代码来源:setup.py

示例10: BuildExtension

def BuildExtension(sources, output_dir, extension_name):
  from distutils import log
  from distutils.core import Distribution, Extension
  import os
  import tempfile

  build_dir = tempfile.mkdtemp()
  # Source file paths must be relative to current path.
  cwd = os.getcwd()
  src_files = [os.path.relpath(filename, cwd) for filename in sources]

  ext = Extension(extension_name, src_files)

  if os.name == 'nt':
    _FixDistutilsMsvcCompiler()
    # VS 2010 does not generate manifest, see http://bugs.python.org/issue4431
    ext.extra_link_args = ['/MANIFEST']

  dist = Distribution({
    'ext_modules': [ext]
  })
  dist.script_args = ['build_ext', '--build-temp', build_dir,
                      '--build-lib', output_dir]
  dist.parse_command_line()
  log.set_threshold(log.DEBUG)
  dist.run_commands()
  dist.script_args = ['clean', '--build-temp', build_dir, '--all']
  dist.parse_command_line()
  log.set_threshold(log.DEBUG)
  dist.run_commands()
开发者ID:,项目名称:,代码行数:30,代码来源:

示例11: __init__

    def __init__(self, name, sources, **kwargs):
        # the goal is to rely on original Extension
        # to do so we convert the .py to .cpp with pythran
        # and register the .cpp in place of the .py
        # That's stage 0, and it's enough if you get the source
        # from github and `python setup.py install it`
        #
        # *But* if you want to distribute the source through
        # `python setup.py sdist` then the .py no longer exists
        # and only the .cpp is distributed. That's stage 1

        cxx_sources = []
        for source in sources:
            base, ext = os.path.splitext(source)
            output_file = base + '.cpp'  # target name

            # stage 0 when we have the .py
            if os.path.exists(source):
                stage = 0
            # stage 1 otherwise. `.cpp' should already be there
            # as generated upon stage 0
            else:
                assert os.path.exists(output_file)
                stage = 1
                ext = '.cpp'
                source = output_file

            # stage-dependant processing
            if stage == 0:
                tc.compile_pythranfile(source, output_file,
                                       module_name=name, cpponly=True)
            cxx_sources.append(output_file)

        extension_args = cfg.make_extension()
        Extension.__init__(self, name, cxx_sources, **extension_args)
开发者ID:artas360,项目名称:pythran,代码行数:35,代码来源:dist.py

示例12: get_extensions

def get_extensions():

    sources = ["lacosmicx/_lacosmicx.pyx", "lacosmicx/laxutils.c"]

    include_dirs = [numpy.get_include(), '.']

    libraries = []

    ext = Extension(name="_lacosmicx",
                    sources=sources,
                    include_dirs=include_dirs,
                    libraries=libraries,
                    language="c",
                    extra_compile_args=['-g', '-O3',
                                        '-funroll-loops', '-ffast-math'])

    has_openmp, outputs = check_openmp()
    if has_openmp:
        ext.extra_compile_args.append('-fopenmp')
        ext.extra_link_args = ['-g', '-fopenmp']
    else:
        log.warn('OpenMP was not found. '
                 'lacosmicx will be compiled without OpenMP. '
                 '(Use the "-v" option of setup.py for more details.)')
        log.debug(('(Start of OpenMP info)\n'
                   'compiler stdout:\n{0}\n'
                   'compiler stderr:\n{1}\n'
                   '(End of OpenMP info)').format(*outputs))

    return [ext]
开发者ID:cmccully,项目名称:lacosmicx,代码行数:30,代码来源:setup.py

示例13: __init__

    def __init__(self, system_libraries):
        """extra_link_args is a list of argument strings
        from pkg-config, or None if we're to use the standard
        libcdio libraries"""

        self.__library_manifest__ = []
        sources = []
        libraries = set()
        extra_compile_args = []
        extra_link_args = []

        if system_libraries.present("libcdio_paranoia"):
            if system_libraries.guaranteed_present("libcdio_paranoia"):
                libraries.update(set(["libcdio",
                                      "libcdio_cdda",
                                      "libcdio_paranoia"]))
                try:
                    if tuple(int(s) for s in
                             system_libraries.configfile.get(
                                 "Libraries",
                                 "libcdio_paranoia_version")) < (0, 90):
                        paranoia_version = [("OLD_PARANOIA", None)]
                    else:
                        paranoia_version = []
                except (KeyError, ValueError):
                    paranoia_version = []
            else:
                extra_compile_args.extend(
                    system_libraries.extra_compile_args("libcdio_paranoia"))
                extra_link_args.extend(
                    system_libraries.extra_link_args("libcdio_paranoia"))

                if system_libraries.lib_version("libcdio_paranoia") < (0, 90):
                    paranoia_version = [("OLD_PARANOIA", None)]
                else:
                    paranoia_version = []

            sources.extend(["src/cdiomodule.c",
                            "src/framelist.c",
                            "src/pcm_conv.c"])

            self.__library_manifest__.append(("libcdio",
                                              "CDDA data extraction",
                                              True))
        else:
            self.__library_manifest__.append(("libcdio",
                                              "CDDA data extraction",
                                              False))
            paranoia_version = []

        Extension.__init__(
            self,
            "audiotools.cdio",
            sources=sources,
            libraries=list(libraries),
            extra_compile_args=extra_compile_args,
            extra_link_args=extra_link_args,
            define_macros=paranoia_version)
开发者ID:brigittebigi,项目名称:sppas,代码行数:58,代码来源:setup.py

示例14: __init__

 def __init__(self,*args,**kw):
     _Extension.__init__(self,*args,**kw)
     sources = []
     for s in self.sources:
         if s.endswith('.pyx'):
             sources.append(s[:-3]+'c')
         else:
             sources.append(s)
     self.sources = sources
开发者ID:pombredanne,项目名称:ensetuptools,代码行数:9,代码来源:extension.py

示例15: __init__

 def __init__(self, *args, **kw):
     # Add a custom 'target_desc' option, which matches CCompiler
     # (is there a better way?
     if "target_desc" in kw:
         self.target_desc = kw['target_desc']
         del kw['target_desc']
     else:
         self.target_desc = "executable"
     Extension.__init__(self, *args, **kw)
开发者ID:tstapler,项目名称:ras_automated_testing,代码行数:9,代码来源:py2exe_distutils.py


注:本文中的distutils.core.Extension类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。