mirror of
https://github.com/ArchiveBox/ArchiveBox
synced 2024-11-25 13:40:20 +00:00
Update __init__.py
This commit is contained in:
parent
5872375a50
commit
1148cadd7a
1 changed files with 5 additions and 4 deletions
|
@ -7,16 +7,17 @@ PKGS_DIR = Path(__file__).parent
|
||||||
VENDORED_PKGS = [
|
VENDORED_PKGS = [
|
||||||
'abx',
|
'abx',
|
||||||
# 'pydantic-pkgr',
|
# 'pydantic-pkgr',
|
||||||
|
# ... everything else in archivebox/pkgs/* comes after ...
|
||||||
]
|
]
|
||||||
|
|
||||||
# scan ./pkgs and add all dirs present to list of available VENDORED_PKGS
|
# VENDORED_PKGS += [ ... ./pkgs/* ... ]
|
||||||
for subdir in reversed(sorted(PKGS_DIR.iterdir())):
|
for subdir in reversed(sorted(PKGS_DIR.iterdir())):
|
||||||
if subdir.is_dir() and subdir.name not in VENDORED_PKGS and not subdir.name.startswith('_'):
|
if subdir.is_dir() and subdir.name not in VENDORED_PKGS and not subdir.name.startswith('_'):
|
||||||
VENDORED_PKGS.append(subdir.name)
|
VENDORED_PKGS.append(subdir.name)
|
||||||
|
|
||||||
|
|
||||||
def load_vendored_pkgs():
|
def load_vendored_pkgs():
|
||||||
"""Add archivebox/vendor to sys.path and import all vendored libraries present within"""
|
"""Add archivebox/pkgs to sys.path and import all vendored python packages present within"""
|
||||||
if str(PKGS_DIR) not in sys.path:
|
if str(PKGS_DIR) not in sys.path:
|
||||||
sys.path.append(str(PKGS_DIR))
|
sys.path.append(str(PKGS_DIR))
|
||||||
|
|
||||||
|
@ -28,12 +29,12 @@ def load_vendored_pkgs():
|
||||||
lib = importlib.import_module(pkg_name)
|
lib = importlib.import_module(pkg_name)
|
||||||
# print(f"Successfully imported lib from environment {pkg_name}")
|
# print(f"Successfully imported lib from environment {pkg_name}")
|
||||||
except ImportError:
|
except ImportError:
|
||||||
sys.path.append(str(pkg_dir))
|
sys.path.append(str(pkg_dir)) # perhaps the pkg is in a subdirectory of the directory
|
||||||
try:
|
try:
|
||||||
lib = importlib.import_module(pkg_name)
|
lib = importlib.import_module(pkg_name)
|
||||||
# print(f"Successfully imported lib from vendored fallback {pkg_name}: {inspect.getfile(lib)}")
|
# print(f"Successfully imported lib from vendored fallback {pkg_name}: {inspect.getfile(lib)}")
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
print(f"Failed to import lib from environment or vendored fallback {pkg_name}: {e}", file=sys.stderr)
|
print(f"Failed to import required pkg from sys.path or archivebox/pkgs dir {pkg_name}: {e}", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue