2019-04-17 03:18:42 +00:00
|
|
|
__package__ = 'archivebox'
|
2024-05-06 14:13:25 +00:00
|
|
|
|
2024-09-25 12:10:09 +00:00
|
|
|
|
2024-09-25 02:04:38 +00:00
|
|
|
# print('INSTALLING MONKEY PATCHES')
|
2024-09-25 12:10:09 +00:00
|
|
|
from .monkey_patches import * # noqa
|
|
|
|
# print('DONE INSTALLING MONKEY PATCHES')
|
2024-09-25 02:04:38 +00:00
|
|
|
|
2024-09-24 22:13:54 +00:00
|
|
|
|
|
|
|
import os
|
2024-09-26 09:36:34 +00:00
|
|
|
import sys
|
2024-09-25 12:10:09 +00:00
|
|
|
import importlib.metadata
|
2024-09-24 22:13:54 +00:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
PACKAGE_DIR = Path(__file__).resolve().parent # archivebox source code dir
|
|
|
|
DATA_DIR = Path(os.curdir).resolve() # archivebox user data dir
|
2024-09-26 09:36:34 +00:00
|
|
|
ARCHIVE_DIR = DATA_DIR / 'archive'
|
2024-09-24 22:13:54 +00:00
|
|
|
|
2024-09-26 09:36:34 +00:00
|
|
|
# make sure PACKAGE_DIR is in sys.path so we can import all subfolders
|
|
|
|
# without necessarily waiting for django to load them thorugh INSTALLED_APPS
|
|
|
|
if str(PACKAGE_DIR) not in sys.path:
|
|
|
|
sys.path.append(str(PACKAGE_DIR))
|
2024-09-24 22:13:54 +00:00
|
|
|
|
2024-09-27 07:37:44 +00:00
|
|
|
# load fallback libraries from vendor dir
|
|
|
|
from .vendor import load_vendored_libs
|
|
|
|
load_vendored_libs()
|
|
|
|
|
|
|
|
|
|
|
|
os.environ['OUTPUT_DIR'] = str(DATA_DIR)
|
|
|
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'core.settings'
|
|
|
|
|
|
|
|
|
2024-09-24 22:13:54 +00:00
|
|
|
def _detect_installed_version():
|
|
|
|
try:
|
|
|
|
return importlib.metadata.version(__package__ or 'archivebox')
|
|
|
|
except importlib.metadata.PackageNotFoundError:
|
|
|
|
try:
|
|
|
|
pyproject_config = (PACKAGE_DIR / 'pyproject.toml').read_text()
|
|
|
|
for line in pyproject_config:
|
|
|
|
if line.startswith('version = '):
|
|
|
|
return line.split(' = ', 1)[-1].strip('"')
|
|
|
|
except FileNotFoundError:
|
|
|
|
# building docs, pyproject.toml is not available
|
|
|
|
return 'dev'
|
|
|
|
|
|
|
|
raise Exception('Failed to detect installed archivebox version!')
|
|
|
|
|
2024-09-25 12:10:09 +00:00
|
|
|
VERSION = _detect_installed_version()
|
2024-09-24 22:13:54 +00:00
|
|
|
|
2024-09-25 12:10:09 +00:00
|
|
|
__version__ = VERSION
|
2024-09-25 02:04:38 +00:00
|
|
|
|
2024-09-25 12:10:09 +00:00
|
|
|
|
|
|
|
from .constants import CONSTANTS
|