Python distutils.extension() Examples
The following are 30
code examples of distutils.extension().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
distutils
, or try the search function
.
Example #1
Source File: modelutils.py From hydpy with GNU Lesser General Public License v3.0 | 6 votes |
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))
Example #2
Source File: modelutils.py From hydpy with GNU Lesser General Public License v3.0 | 6 votes |
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'
Example #3
Source File: test_build_ext.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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')
Example #4
Source File: setup.py From azure-uamqp-python with MIT License | 5 votes |
def __init__(self, name): # don't invoke the original build_ext for this special extension Extension.__init__(self, name, sources=[])
Example #5
Source File: test_build_ext.py From datafari with Apache License 2.0 | 5 votes |
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)
Example #6
Source File: test_build_ext.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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
Example #7
Source File: test_build_ext.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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)
Example #8
Source File: test_build_ext.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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')
Example #9
Source File: test_build_ext.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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)
Example #10
Source File: test_build_ext.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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
Example #11
Source File: test_build_ext.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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)
Example #12
Source File: test_build_ext.py From datafari with Apache License 2.0 | 5 votes |
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')
Example #13
Source File: test_build_ext.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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)
Example #14
Source File: test_build_ext.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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
Example #15
Source File: test_build_ext.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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)
Example #16
Source File: test_build_ext.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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')
Example #17
Source File: test_build_ext.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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)
Example #18
Source File: test_build_ext.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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
Example #19
Source File: test_build_ext.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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)
Example #20
Source File: test_build_ext.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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')
Example #21
Source File: test_build_ext.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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)
Example #22
Source File: test_build_ext.py From datafari with Apache License 2.0 | 5 votes |
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
Example #23
Source File: test_build_ext.py From datafari with Apache License 2.0 | 5 votes |
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)
Example #24
Source File: test_build_ext.py From ironpython2 with Apache License 2.0 | 5 votes |
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
Example #25
Source File: setup.py From pyroomacoustics with MIT License | 5 votes |
def __str__(self): import pybind11 return pybind11.get_include(self.user) # build C extension for image source model
Example #26
Source File: modelutils.py From hydpy with GNU Lesser General Public License v3.0 | 5 votes |
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
Example #27
Source File: test_build_ext.py From oss-ftp with MIT License | 5 votes |
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)
Example #28
Source File: test_build_ext.py From ironpython2 with Apache License 2.0 | 5 votes |
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)
Example #29
Source File: test_build_ext.py From oss-ftp with MIT License | 5 votes |
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')
Example #30
Source File: test_build_ext.py From oss-ftp with MIT License | 5 votes |
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)