Here are the examples of the python api sys.extensions_location taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
3
Example 1
def load_plugin(self, name):
if name in self._plugins:
return
sys.path.insert(0, sys.extensions_location)
try:
del sys.modules[name]
except KeyError:
pass
try:
p, err = importlib.import_module(name), ''
except Exception as err:
p = None
err = str(err)
self._plugins[name] = (p, err)
sys.path.remove(sys.extensions_location)
3
Example 2
Project: calibre Source File: sqlite.py
def load_c_extensions(conn, debug=DEBUG):
try:
conn.enable_load_extension(True)
ext_path = os.path.join(sys.extensions_location, 'sqlite_custom.'+
('pyd' if iswindows else 'so'))
conn.load_extension(ext_path)
conn.enable_load_extension(False)
return True
except Exception as e:
if debug:
print 'Failed to load high performance sqlite C extension'
print e
return False
0
Example 3
Project: calibre Source File: device.py
def eject_exe():
base = sys.extensions_location if hasattr(sys, 'new_app_layout') else os.path.dirname(sys.executable)
return os.path.join(base, 'calibre-eject.exe')
0
Example 4
def test_plugins(self):
exclusions = set()
if is_ci:
if isosx:
# The compiler version on OS X is different between the
# machine on which the dependencies are built and the
# machine on which the calibre modules are built, which causes
# C++ name mangling incompatibilities preventing some modules
# from loading
exclusions.update(set('podofo'.split()))
if islinux and (not os.path.exists('/dev/bus/usb') and not os.path.exists('/proc/bus/usb')):
# libusb fails to initialize in containers without USB subsystems
exclusions.update(set('libusb libmtp'.split()))
for name in plugins:
if name in exclusions:
if name in ('libusb', 'libmtp'):
# Just check that the DLL can be loaded
ctypes.CDLL(os.path.join(sys.extensions_location, name + ('.dylib' if isosx else '.so')))
continue
mod, err = plugins[name]
self.assertFalse(err or not mod, 'Failed to load plugin: ' + name + ' with error:\n' + err)