def test_EXT_SUFFIX_in_vars(self): import _imp if not _imp.extension_suffixes(): self.skipTest("stub loader has no suffixes") vars = sysconfig.get_config_vars() self.assertIsNotNone(vars['SO']) self.assertEqual(vars['SO'], vars['EXT_SUFFIX']) self.assertEqual(vars['EXT_SUFFIX'], _imp.extension_suffixes()[0])
def _init_os2(vars): """Initialize the module as appropriate for OS/2""" import _imp _init_posix(vars) # set the python module extension to .pyd instead of .dll - # for compatibility with previous releases vars['EXT_SUFFIX'] = _imp.extension_suffixes()[0]
def __init__(self, path, rights): super().__init__(path, rights) loaders = [(OpenatExtensionFileLoader, _imp.extension_suffixes()), (OpenatSourceFileLoader, SOURCE_SUFFIXES), (OpenatSourcelessFileLoader, BYTECODE_SUFFIXES)] self._loaders = [(suffix, loader) for loader, suffixes in loaders for suffix in suffixes]
def get_suffixes(): warnings.warn('imp.get_suffixes() is deprecated; use the constants ' 'defined on importlib.machinery instead', DeprecationWarning, 2) extensions = [(s, 'rb', C_EXTENSION) for s in extension_suffixes()] source = [(s, 'U', PY_SOURCE) for s in machinery.SOURCE_SUFFIXES] bytecode = [(s, 'rb', PY_COMPILED) for s in machinery.BYTECODE_SUFFIXES] return extensions + source + bytecode
def _install_source_loader_helper(source_loader_type): extensions = ExtensionFileLoader, _imp.extension_suffixes() source = source_loader_type, SOURCE_SUFFIXES bytecode = SourcelessFileLoader, BYTECODE_SUFFIXES supported_loaders = [extensions, source, bytecode] sys.path_hooks[:] = [ zipimport.zipimporter, FileFinder.path_hook(*supported_loaders), ] sys.path_importer_cache.clear()
def _init_nt(): """Initialize the module as appropriate for NT""" g = {} g['EXT_SUFFIX'] = _imp.extension_suffixes()[0] g['EXE'] = ".exe" g['SO'] = ".pyd" g['SOABI'] = g['SO'].rsplit('.')[0] # xxx? global _config_vars _config_vars = g
def _get_posix_vars(): """Initialize the config vars as appropriate for POSIX systems.""" import _imp import sys import os darwin_native = sys.platform == "darwin" and __graalpython__.platform_id == "native" # note: this must be kept in sync with _imp.extension_suffixes so_abi = sys.implementation.cache_tag + "-" + __graalpython__.platform_id + "-" + sys.implementation._multiarch so_ext = ".so" if not darwin_native else ".dylib" assert _imp.extension_suffixes( )[0] == "." + so_abi + so_ext, "mismatch between extension suffix to _imp.extension_suffixes" toolchain_cxx = __graalpython__.get_toolchain_tool_path('CXX') have_cxx = toolchain_cxx is not None g = {} g['CC'] = __graalpython__.get_toolchain_tool_path('CC') g['CXX'] = toolchain_cxx if have_cxx else g['CC'] + ' --driver-mode=g++' g['OPT'] = "-stdlib=libc++ -DNDEBUG" g['CONFINCLUDEPY'] = get_python_inc() g['CPPFLAGS'] = '-I. -I' + get_python_inc() gnu_source = "-D_GNU_SOURCE=1" g['USE_GNU_SOURCE'] = gnu_source cflags_default = "-Wno-unused-command-line-argument -stdlib=libc++ -DNDEBUG -DGRAALVM_PYTHON_LLVM" g['CFLAGS_DEFAULT'] = cflags_default g['CFLAGS'] = cflags_default + " " + gnu_source g['LDFLAGS'] = "" g['CCSHARED'] = "-fPIC" g['LDSHARED_LINUX'] = "%s -shared -fPIC" % __graalpython__.get_toolchain_tool_path( 'CC') if darwin_native: g['LDSHARED'] = __graalpython__.get_toolchain_tool_path( 'CC') + " -bundle -undefined dynamic_lookup" g['LDFLAGS'] = "-bundle -undefined dynamic_lookup" else: g['LDSHARED'] = g['LDSHARED_LINUX'] g['SOABI'] = so_abi g['EXT_SUFFIX'] = "." + so_abi + so_ext g['SHLIB_SUFFIX'] = so_ext g['SO'] = "." + so_abi + so_ext # deprecated in Python 3, for backward compatibility g['AR'] = __graalpython__.get_toolchain_tool_path('AR') g['RANLIB'] = __graalpython__.get_toolchain_tool_path('RANLIB') g['ARFLAGS'] = "rc" g['LD'] = __graalpython__.get_toolchain_tool_path('LD') g['EXE'] = "" g['LIBDIR'] = os.path.join(sys.prefix, 'lib') g['VERSION'] = get_python_version() g['Py_HASH_ALGORITHM'] = 0 # does not give any specific info about the hashing algorithm g['NM'] = __graalpython__.get_toolchain_tool_path('NM') g['MULTIARCH'] = sys.implementation._multiarch g['ABIFLAGS'] = "" g['Py_DEBUG'] = 0 g['Py_ENABLE_SHARED'] = 0 return g
def _init_non_posix(vars): """Initialize the module as appropriate for NT""" # set basic install directories import _imp vars['LIBDEST'] = get_path('stdlib') vars['BINLIBDEST'] = get_path('platstdlib') vars['INCLUDEPY'] = get_path('include') vars['EXT_SUFFIX'] = _imp.extension_suffixes()[0] vars['EXE'] = '.exe' vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable))
def _init_nt(): """Initialize the module as appropriate for NT""" g = {} g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1) g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1) g['INCLUDEPY'] = get_python_inc(plat_specific=0) g['EXT_SUFFIX'] = _imp.extension_suffixes()[0] g['EXE'] = '.exe' g['VERSION'] = get_python_version().replace('.', '') g['BINDIR'] = os.path.dirname(os.path.abspath(sys.executable)) global _config_vars _config_vars = g
def add_ext_suffix_39(vars): """ Ensure vars contains 'EXT_SUFFIX'. pypa/distutils#130 """ import _imp ext_suffix = _imp.extension_suffixes()[0] vars.update( EXT_SUFFIX=ext_suffix, # sysconfig sets SO to match EXT_SUFFIX, so maintain # that expectation. # https://github.com/python/cpython/blob/785cc6770588de087d09e89a69110af2542be208/Lib/sysconfig.py#L671-L673 SO=ext_suffix, )
def _init_non_posix(vars): """Initialize the module as appropriate for NT""" # set basic install directories vars['LIBDEST'] = get_path('stdlib') vars['BINLIBDEST'] = get_path('platstdlib') vars['INCLUDEPY'] = get_path('include') vars['EXT_SUFFIX'] = '.pyd' vars['EXE'] = '.exe' vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable)) # pypy: give us control over the ABI tag in a wheel name import _imp so_ext = _imp.extension_suffixes()[0] vars['SOABI'] = '-'.join(so_ext.split('.')[1].split('-')[:2])
def _init_nt(): """Initialize the module as appropriate for NT""" g = {} # set basic install directories g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1) g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1) # XXX hmmm.. a normal install puts include files here g['INCLUDEPY'] = get_python_inc(plat_specific=0) g['EXT_SUFFIX'] = _imp.extension_suffixes()[0] g['EXE'] = ".exe" g['VERSION'] = get_python_version().replace(".", "") g['BINDIR'] = os.path.dirname(os.path.abspath(sys.executable)) global _config_vars _config_vars = g
def _init_posix(): """Initialize the module as appropriate for POSIX systems.""" darwin_native = sys.platform == "darwin" and __graalpython__.platform_id == "native" # note: this must be kept in sync with _imp.extension_suffixes so_abi = sys.implementation.cache_tag + "-" + __graalpython__.platform_id + "-" + sys.implementation._multiarch so_ext = ".so" if not darwin_native else ".dylib" assert _imp.extension_suffixes( )[0] == "." + so_abi + so_ext, "mismatch between extension suffix to _imp.extension_suffixes" toolchain_cxx = __graalpython__.get_toolchain_path('CXX') have_cxx = toolchain_cxx is not None g = {} g['CC'] = __graalpython__.get_toolchain_path('CC') g['CXX'] = toolchain_cxx if have_cxx else g['CC'] + ' --driver-mode=g++' g['OPT'] = "-stdlib=libc++ -DNDEBUG -O1" g['CONFINCLUDEPY'] = get_python_inc() g['CPPFLAGS'] = '-I. -I' + get_python_inc() g['CFLAGS'] = "-Wno-unused-command-line-argument -stdlib=libc++ -DNDEBUG -O1" g['CCSHARED'] = "-fPIC" g['LDSHARED_LINUX'] = "%s -shared -fPIC" % __graalpython__.get_toolchain_path( 'CC') if darwin_native: g['LDSHARED'] = g['LDSHARED_LINUX'] + " -Wl,-undefined,dynamic_lookup" else: g['LDSHARED'] = g['LDSHARED_LINUX'] g['SOABI'] = so_abi g['EXT_SUFFIX'] = "." + so_abi + so_ext g['SHLIB_SUFFIX'] = so_ext g['SO'] = "." + so_abi + so_ext # deprecated in Python 3, for backward compatibility g['AR'] = __graalpython__.get_toolchain_path('AR') g['RANLIB'] = __graalpython__.get_toolchain_path('RANLIB') g['ARFLAGS'] = "rc" g['EXE'] = "" g['LIBDIR'] = os.path.join(sys.prefix, 'lib') g['VERSION'] = get_python_version() global _config_vars _config_vars = g
def _init_posix(): """Initialize the module as appropriate for POSIX systems.""" so_ext = _imp.extension_suffixes()[0] g = {} g['CC'] = "%s -CC" % sys.executable g['CXX'] = "%s -CC" % sys.executable g['OPT'] = "-DNDEBUG -O1" g['CFLAGS'] = "-DNDEBUG -O1" g['CCSHARED'] = "-fPIC" g['LDSHARED'] = "%s -LD" % sys.executable g['EXT_SUFFIX'] = so_ext g['SHLIB_SUFFIX'] = so_ext g['SO'] = so_ext # deprecated in Python 3, for backward compatibility g['AR'] = "ar" g['ARFLAGS'] = "rc" g['EXE'] = "" g['LIBDIR'] = os.path.join(sys.prefix, 'lib') g['VERSION'] = get_python_version() global _config_vars _config_vars = g
print(comment("Panda3D modules that are implemented in C++."), file=handle) print("namespace panda3d {", file=handle) # Determine the path to the interrogatedb files pandac = os.path.dirname(pandac.__file__) interrogate_add_search_directory(os.path.join(pandac, "..", "..", "etc")) interrogate_add_search_directory(os.path.join(pandac, "input")) import panda3d.core processModule(handle, "core") # Determine the suffix for the extension modules. if sys.version_info >= (3, 0): import _imp ext_suffix = _imp.extension_suffixes()[0] elif sys.platform == "win32": ext_suffix = ".pyd" else: ext_suffix = ".so" for lib in os.listdir(os.path.dirname(panda3d.__file__)): if lib.endswith(ext_suffix) and not lib.startswith('core.'): module_name = lib[:-len(ext_suffix)] __import__("panda3d." + module_name) processModule(handle, module_name) print("}", file=handle) handle.close() print("Wrote output to pandadoc.hpp. You can now run:")
"""The machinery of importlib: finders, loaders, hooks, etc.""" import _imp from ._bootstrap import (SOURCE_SUFFIXES, DEBUG_BYTECODE_SUFFIXES, OPTIMIZED_BYTECODE_SUFFIXES, BYTECODE_SUFFIXES) from ._bootstrap import BuiltinImporter from ._bootstrap import FrozenImporter from ._bootstrap import PathFinder from ._bootstrap import FileFinder from ._bootstrap import SourceFileLoader from ._bootstrap import SourcelessFileLoader from ._bootstrap import ExtensionFileLoader EXTENSION_SUFFIXES = _imp.extension_suffixes()
import _imp so_ext = _imp.extension_suffixes()[0] build_time_vars = { "EXT_SUFFIX": so_ext, "SHLIB_SUFFIX": so_ext, "SOABI": '-'.join(so_ext.split('.')[1].split('-')[:2]), "SO": so_ext # deprecated in Python 3, for backward compatibility }
def test_EXT_SUFFIX_in_vars(self): import _imp vars = sysconfig.get_config_vars() self.assertIsNotNone(vars['SO']) self.assertEqual(vars['SO'], vars['EXT_SUFFIX']) self.assertEqual(vars['EXT_SUFFIX'], _imp.extension_suffixes()[0])
def get_suffixes(): extensions = [(s, 'rb', C_EXTENSION) for s in extension_suffixes()] source = [(s, 'U', PY_SOURCE) for s in _bootstrap._SOURCE_SUFFIXES] bytecode = [(_bootstrap._BYTECODE_SUFFIX, 'rb', PY_COMPILED)] return extensions + source + bytecode
def test_ext_suffixes(self): import _imp for suffix in _imp.extension_suffixes(): assert suffix.endswith(('.pyd', '.so'))