scope LIB_DIR by os, arch, and docker status

This commit is contained in:
Nick Sweeting 2024-10-04 00:08:44 -07:00
parent 2e3a2f459c
commit 152b530249
No known key found for this signature in database
3 changed files with 25 additions and 16 deletions

View file

@ -14,6 +14,7 @@
# #
# Read more about [developing Archivebox](https://github.com/ArchiveBox/ArchiveBox#archivebox-development). # Read more about [developing Archivebox](https://github.com/ArchiveBox/ArchiveBox#archivebox-development).
#########################################################################################
# Use Debian 12 w/ faster package updates: https://packages.debian.org/bookworm-backports/ # Use Debian 12 w/ faster package updates: https://packages.debian.org/bookworm-backports/
FROM python:3.11-slim-bookworm FROM python:3.11-slim-bookworm

View file

@ -3,6 +3,8 @@ __package__ = 'archivebox.config'
import os import os
import re import re
import platform
from typing import Dict from typing import Dict
from pathlib import Path from pathlib import Path
import importlib.metadata import importlib.metadata
@ -18,8 +20,6 @@ PACKAGE_DIR: Path = Path(__file__).resolve().parent.parent # archivebox sourc
DATA_DIR: Path = Path(os.curdir).resolve() # archivebox user data dir DATA_DIR: Path = Path(os.curdir).resolve() # archivebox user data dir
ARCHIVE_DIR: Path = DATA_DIR / 'archive' # archivebox snapshot data dir ARCHIVE_DIR: Path = DATA_DIR / 'archive' # archivebox snapshot data dir
IN_DOCKER = os.environ.get('IN_DOCKER', False) in ('1', 'true', 'True', 'yes')
def _detect_installed_version(PACKAGE_DIR: Path): def _detect_installed_version(PACKAGE_DIR: Path):
"""Autodetect the installed archivebox version by using pip package metadata, pyproject.toml file, or package.json file""" """Autodetect the installed archivebox version by using pip package metadata, pyproject.toml file, or package.json file"""
try: try:
@ -54,6 +54,12 @@ VERSION: str = _detect_installed_version(PACKAGE_DIR)
class ConstantsDict(Mapping): class ConstantsDict(Mapping):
IN_DOCKER = os.environ.get('IN_DOCKER', False) in ('1', 'true', 'True', 'yes')
OS = platform.system().lower() # darwin, linux, etc.
ARCH = platform.machine().lower() # arm64, x86_64, etc.
LIB_DIR_SCOPE = f'{ARCH}-{OS}' + ('-docker' if IN_DOCKER else '')
PACKAGE_DIR: Path = PACKAGE_DIR # archivebox source code dir PACKAGE_DIR: Path = PACKAGE_DIR # archivebox source code dir
DATA_DIR: Path = DATA_DIR # archivebox user data dir DATA_DIR: Path = DATA_DIR # archivebox user data dir
ARCHIVE_DIR: Path = ARCHIVE_DIR # archivebox snapshot data dir ARCHIVE_DIR: Path = ARCHIVE_DIR # archivebox snapshot data dir
@ -80,7 +86,7 @@ class ConstantsDict(Mapping):
PERSONAS_DIR: Path = DATA_DIR / PERSONAS_DIR_NAME PERSONAS_DIR: Path = DATA_DIR / PERSONAS_DIR_NAME
CACHE_DIR: Path = DATA_DIR / CACHE_DIR_NAME CACHE_DIR: Path = DATA_DIR / CACHE_DIR_NAME
LOGS_DIR: Path = DATA_DIR / LOGS_DIR_NAME LOGS_DIR: Path = DATA_DIR / LOGS_DIR_NAME
LIB_DIR: Path = (Path('/tmp') if IN_DOCKER else DATA_DIR) / LIB_DIR_NAME LIB_DIR: Path = DATA_DIR / LIB_DIR_NAME / LIB_DIR_SCOPE # e.g. data/lib/arm64-darwin-docker
TMP_DIR: Path = (Path('/tmp') if IN_DOCKER else DATA_DIR) / TMP_DIR_NAME TMP_DIR: Path = (Path('/tmp') if IN_DOCKER else DATA_DIR) / TMP_DIR_NAME
CUSTOM_TEMPLATES_DIR: Path = DATA_DIR / CUSTOM_TEMPLATES_DIR_NAME CUSTOM_TEMPLATES_DIR: Path = DATA_DIR / CUSTOM_TEMPLATES_DIR_NAME
USER_PLUGINS_DIR: Path = DATA_DIR / USER_PLUGINS_DIR_NAME USER_PLUGINS_DIR: Path = DATA_DIR / USER_PLUGINS_DIR_NAME

28
pdm.lock generated
View file

@ -5,7 +5,7 @@
groups = ["default", "all", "ldap", "sonic"] groups = ["default", "all", "ldap", "sonic"]
strategy = ["inherit_metadata"] strategy = ["inherit_metadata"]
lock_version = "4.5.0" lock_version = "4.5.0"
content_hash = "sha256:a03237d9196e1d9b2f82130d026c5fa9eaf165a7d2079393baa2205bedd92674" content_hash = "sha256:be2740879f6045b108b48e90997be10a6a670805e7682a0c86fc3cd1e98811c4"
[[metadata.targets]] [[metadata.targets]]
requires_python = "==3.11.*" requires_python = "==3.11.*"
@ -13,7 +13,7 @@ platform = "manylinux_2_17_x86_64"
[[metadata.targets]] [[metadata.targets]]
requires_python = "==3.11.*" requires_python = "==3.11.*"
platform = "macos_14_0_arm64" platform = "macos_12_0_arm64"
[[package]] [[package]]
name = "annotated-types" name = "annotated-types"
@ -642,17 +642,6 @@ files = [
{file = "django_taggit-1.3.0-py3-none-any.whl", hash = "sha256:609b0223d8a652f3fae088b7fd29f294fdadaca2d7931d45c27d6c59b02fdf31"}, {file = "django_taggit-1.3.0-py3-none-any.whl", hash = "sha256:609b0223d8a652f3fae088b7fd29f294fdadaca2d7931d45c27d6c59b02fdf31"},
] ]
[[package]]
name = "django-url-tools"
version = "0.0.8"
summary = "Django helpers for dealing with URLs in templates"
groups = ["default"]
marker = "python_version == \"3.11\""
files = [
{file = "django-url-tools-0.0.8.tar.gz", hash = "sha256:012cf28796265cd805b502f360c9a86f750b02dd7d5c770fc878bf1dead5aada"},
{file = "django-url-tools-0.0.8.zip", hash = "sha256:9d9cb034d3e1768ef4b98ab3e3ebb75eae51530d04c11ad19ecbefa30831d762"},
]
[[package]] [[package]]
name = "et-xmlfile" name = "et-xmlfile"
version = "1.1.0" version = "1.1.0"
@ -1004,6 +993,19 @@ dependencies = [
"requests", "requests",
] ]
[[package]]
name = "pocket"
version = "0.3.7"
git = "https://github.com/tapanpandita/pocket.git"
ref = "v0.3.7"
revision = "5a144438cc89bfc0ec94db960718ccf1f76468c1"
summary = "api wrapper for getpocket.com"
groups = ["default"]
marker = "python_version == \"3.11\""
dependencies = [
"requests",
]
[[package]] [[package]]
name = "prompt-toolkit" name = "prompt-toolkit"
version = "3.0.48" version = "3.0.48"