Python os.add_dll_directory() Examples
The following are 3
code examples of os.add_dll_directory().
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
os
, or try the search function
.
Example #1
Source File: _win_config.py From python-gssapi with ISC License | 5 votes |
def configure_windows(): """ Validate that KfW appears to be installed correctly and add it to the DLL directories/PATH if necessary. In the case that it can't be located, raise an error. """ if kfw_available(): return # All set, necessary DLLs should be available if os.path.exists(KFW_BIN): # In standard location try: # to use Python 3.8's DLL handling os.add_dll_directory(KFW_BIN) except AttributeError: # <3.8, use PATH os.environ['PATH'] += os.pathsep + KFW_BIN if kfw_available(): return # Check if kinit is in the PATH which should lead us to the bin folder kinit_path = shutil.which('kinit') # KfW provided binary if kinit_path: # Non-standard install location try: # Most likely >=3.8, otherwise it would have been found already os.add_dll_directory(os.path.dirname(kinit_path)) except AttributeError: # <3.8, corrupted installation? pass else: if kfw_available(): return error_not_found()
Example #2
Source File: _environment.py From cupy with MIT License | 5 votes |
def _setup_win32_dll_directory(): cuda_path = get_cuda_path() if cuda_path is None: raise RuntimeError('CUDA path could not be detected.') os.add_dll_directory(os.path.join(cuda_path, 'bin'))
Example #3
Source File: library.py From khiva-python with Mozilla Public License 2.0 | 5 votes |
def __init__(self): try: if platform.system() == 'Darwin': self.c_khiva_library = ctypes.CDLL('libkhiva_c.dylib') elif platform.system() == 'Windows': if sys.version_info.major == 3 and sys.version_info.minor == 8: import os os.add_dll_directory(os.getenv("KHIVA_DLL_DIR", default=r'C:\Program Files\Khiva\v0\lib')) self.c_khiva_library = ctypes.CDLL('khiva_c.dll') elif platform.system() == 'Linux': self.c_khiva_library = ctypes.CDLL('libkhiva_c.so') except: raise Exception("Khiva C++ library is required in order to use the Python Khiva library")