mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-24 03:36:55 -04:00

Some checks are pending
Build Debian package / build (push) Waiting to run
Build Docker image / buildx (push) Waiting to run
Build Homebrew package / build (push) Waiting to run
Run linters / lint (push) Waiting to run
Build Pip package / build (push) Waiting to run
Run tests / python_tests (ubuntu-22.04, 3.11) (push) Waiting to run
Run tests / docker_tests (push) Waiting to run
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
import sys
|
|
import importlib
|
|
from pathlib import Path
|
|
|
|
VENDOR_DIR = Path(__file__).parent
|
|
|
|
VENDORED_LIBS = [
|
|
'abx',
|
|
'pydantic-pkgr',
|
|
'pocket',
|
|
]
|
|
|
|
for subdir in reversed(sorted(VENDOR_DIR.iterdir())):
|
|
if subdir.is_dir() and subdir.name not in VENDORED_LIBS and not subdir.name.startswith('_'):
|
|
VENDORED_LIBS.append(subdir.name)
|
|
|
|
def load_vendored_libs():
|
|
if str(VENDOR_DIR) not in sys.path:
|
|
sys.path.append(str(VENDOR_DIR))
|
|
|
|
for lib_name in VENDORED_LIBS:
|
|
lib_dir = VENDOR_DIR / lib_name
|
|
assert lib_dir.is_dir(), f'Expected vendor libary {lib_name} could not be found in {lib_dir}'
|
|
|
|
try:
|
|
lib = importlib.import_module(lib_name)
|
|
# print(f"Successfully imported lib from environment {lib_name}")
|
|
except ImportError:
|
|
sys.path.append(str(lib_dir))
|
|
try:
|
|
lib = importlib.import_module(lib_name)
|
|
# print(f"Successfully imported lib from vendored fallback {lib_name}: {inspect.getfile(lib)}")
|
|
except ImportError as e:
|
|
print(f"Failed to import lib from environment or vendored fallback {lib_name}: {e}", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
|