Merge pull request #769 from milutter:plugin_loading
PiperOrigin-RevId: 517231543 Change-Id: Ia3f0929650da235589e9434db84500b3d9f17df1
This commit is contained in:
@@ -19,6 +19,7 @@ import ctypes.util
|
|||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import warnings
|
||||||
|
|
||||||
_SYSTEM = platform.system()
|
_SYSTEM = platform.system()
|
||||||
if _SYSTEM == 'Windows':
|
if _SYSTEM == 'Windows':
|
||||||
@@ -54,7 +55,13 @@ PLUGIN_HANDLES = []
|
|||||||
def _load_all_bundled_plugins():
|
def _load_all_bundled_plugins():
|
||||||
for directory, _, filenames in os.walk(PLUGINS_DIR):
|
for directory, _, filenames in os.walk(PLUGINS_DIR):
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
PLUGIN_HANDLES.append(ctypes.CDLL(os.path.join(directory, filename)))
|
if os.path.splitext(filename)[-1] in [".dll", ".dylib", ".so"]:
|
||||||
|
PLUGIN_HANDLES.append(ctypes.CDLL(os.path.join(directory, filename)))
|
||||||
|
elif filename == "__init__.py":
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
warnings.warn('Ignoring non-library in plugin directory: '
|
||||||
|
f'{os.path.join(directory, filename)}', ImportWarning)
|
||||||
|
|
||||||
_load_all_bundled_plugins()
|
_load_all_bundled_plugins()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user