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


Python distutils.extension方法代码示例

本文整理汇总了Python中distutils.extension方法的典型用法代码示例。如果您正苦于以下问题:Python distutils.extension方法的具体用法?Python distutils.extension怎么用?Python distutils.extension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在distutils的用法示例。


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

示例1: get_dllextension

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import extension [as 别名]
def get_dllextension() -> str:
    """Return the DLL file extension for the current operating system.

    The returned value depends on the response of function |platform.system|
    of module |platform|.  |get_dllextension| returns `.pyd` if
    |platform.system| returns the string "windows" and `.so` for
    all other strings:

    >>> from hydpy.cythons.modelutils import get_dllextension
    >>> import platform
    >>> from unittest import mock
    >>> with mock.patch.object(
    ...     platform, 'system', side_effect=lambda: 'Windows') as mocked:
    ...     get_dllextension()
    '.pyd'
    >>> with mock.patch.object(
    ...     platform, 'system', side_effect=lambda: 'Linux') as mocked:
    ...     get_dllextension()
    '.so'
    """
    if platform.system().lower() == 'windows':
        return '.pyd'
    return '.so' 
开发者ID:hydpy-dev,项目名称:hydpy,代码行数:25,代码来源:modelutils.py

示例2: write

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import extension [as 别名]
def write(self) -> None:
        """Collect the source code and write it into a Cython extension
        file ("pyx")."""
        with open(self.pyxpath, 'w') as pxf:
            print('    * cython options')
            pxf.write(repr(self.cythonoptions))
            print('    * C imports')
            pxf.write(repr(self.cimports))
            print('    * constants (if defined)')
            pxf.write(repr(self.constants))
            print('    * parameter classes')
            pxf.write(repr(self.parameters))
            print('    * sequence classes')
            pxf.write(repr(self.sequences))
            print('    * numerical parameters')
            pxf.write(repr(self.numericalparameters))
            print('    * model class')
            print('        - model attributes')
            pxf.write(repr(self.modeldeclarations))
            print('        - standard functions')
            pxf.write(repr(self.modelstandardfunctions))
            print('        - numeric functions')
            pxf.write(repr(self.modelnumericfunctions))
            print('        - additional functions')
            pxf.write(repr(self.modeluserfunctions)) 
开发者ID:hydpy-dev,项目名称:hydpy,代码行数:27,代码来源:modelutils.py

示例3: __init__

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import extension [as 别名]
def __init__(self, name):
        # don't invoke the original build_ext for this special extension
        Extension.__init__(self, name, sources=[]) 
开发者ID:Azure,项目名称:azure-uamqp-python,代码行数:5,代码来源:setup.py

示例4: test_setuptools_compat

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils 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

示例5: test_deployment_target_default

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import extension [as 别名]
def test_deployment_target_default(self):
        # Issue 9516: Test that, in the absence of the environment variable,
        # an extension module is compiled with the same deployment target as
        #  the interpreter.
        self._try_compile_deployment_target('==', None) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_build_ext.py

示例6: test_deployment_target_too_low

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import extension [as 别名]
def test_deployment_target_too_low(self):
        # Issue 9516: Test that an extension module is not allowed to be
        # compiled with a deployment target less than that of the interpreter.
        self.assertRaises(DistutilsPlatformError,
            self._try_compile_deployment_target, '>', '10.1') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_build_ext.py

示例7: test_deployment_target_higher_ok

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import extension [as 别名]
def test_deployment_target_higher_ok(self):
        # Issue 9516: Test that an extension module can be compiled with a
        # deployment target higher than that of the interpreter: the ext
        # module may depend on some newer OS feature.
        deptarget = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
        if deptarget:
            # increment the minor version number (i.e. 10.6 -> 10.7)
            deptarget = [int(x) for x in deptarget.split('.')]
            deptarget[-1] += 1
            deptarget = '.'.join(str(i) for i in deptarget)
            self._try_compile_deployment_target('<', deptarget) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_build_ext.py

示例8: _get_unpatched

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import extension [as 别名]
def _get_unpatched(cls):
    """Protect against re-patching the distutils if reloaded

    Also ensures that no other distutils extension monkeypatched the distutils
    first.
    """
    while cls.__module__.startswith('setuptools'):
        cls, = cls.__bases__
    if not cls.__module__.startswith('distutils'):
        raise AssertionError(
            "distutils has already been patched by %r" % cls
        )
    return cls 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:15,代码来源:setuptools_extension.py

示例9: compile_

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import extension [as 别名]
def compile_(self) -> None:
        """Translate Cython code to C code and compile it."""
        argv = copy.deepcopy(sys.argv)
        sys.argv = [sys.argv[0], 'build_ext', '--build-lib='+self.buildpath]
        exc_modules = [distutils.extension.Extension(
            'hydpy.cythons.autogen.'+self.cyname,
            [self.pyxfilepath], extra_compile_args=['-O2'])]
        distutils.core.setup(ext_modules=build.cythonize(exc_modules),
                             include_dirs=[numpy.get_include()])
        sys.argv = argv 
开发者ID:hydpy-dev,项目名称:hydpy,代码行数:12,代码来源:modelutils.py

示例10: __str__

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import extension [as 别名]
def __str__(self):
        import pybind11

        return pybind11.get_include(self.user)


# build C extension for image source model 
开发者ID:LCAV,项目名称:pyroomacoustics,代码行数:9,代码来源:setup.py


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