From 04d2316800bd19bf99d0e079fe3982735d7978ba Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Wed, 9 Oct 2024 18:06:00 -0700 Subject: [PATCH] remove CHECKS feature, not needed --- archivebox/abx/archivebox/base_check.py | 44 ---------------------- archivebox/abx/archivebox/hookspec.py | 4 -- archivebox/abx/archivebox/use.py | 8 ---- archivebox/core/settings.py | 1 - archivebox/plugins_pkg/pip/apps.py | 50 +------------------------ archivebox/vendor/pydantic-pkgr | 2 +- pyproject.toml | 4 +- uv.lock | 10 ++--- 8 files changed, 9 insertions(+), 114 deletions(-) delete mode 100644 archivebox/abx/archivebox/base_check.py diff --git a/archivebox/abx/archivebox/base_check.py b/archivebox/abx/archivebox/base_check.py deleted file mode 100644 index c0d46f1c..00000000 --- a/archivebox/abx/archivebox/base_check.py +++ /dev/null @@ -1,44 +0,0 @@ -__package__ = "abx.archivebox" - -from typing import List - -from django.core.checks import Warning, Tags, register - -import abx - -from .base_hook import BaseHook, HookType - - -class BaseCheck(BaseHook): - hook_type: HookType = "CHECK" - - tag: str = Tags.database - - @staticmethod - def check(settings, logger) -> List[Warning]: - """Override this method to implement your custom runtime check.""" - errors = [] - # if not hasattr(settings, 'SOME_KEY'): - # errors.extend(Error( - # 'Missing settings.SOME_KEY after django_setup(), did SOME_KEY get loaded?', - # id='core.C001', - # hint='Make sure to run django_setup() is able to load settings.SOME_KEY.', - # )) - # logger.debug('[√] Loaded settings.PLUGINS succesfully.') - return errors - - @abx.hookimpl - def get_CHECKS(self): - return [self] - - @abx.hookimpl - def register_checks(self): - """Tell django that this check exists so it can be run automatically by django.""" - def run_check(**kwargs): - from django.conf import settings - import logging - return self.check(settings, logging.getLogger("checks")) - - run_check.__name__ = self.id - run_check.tags = [self.tag] - register(self.tag)(run_check) diff --git a/archivebox/abx/archivebox/hookspec.py b/archivebox/abx/archivebox/hookspec.py index 661d0580..1d08aa56 100644 --- a/archivebox/abx/archivebox/hookspec.py +++ b/archivebox/abx/archivebox/hookspec.py @@ -17,10 +17,6 @@ def get_EXTRACTORS(): def get_REPLAYERS(): return {} -@hookspec -def get_CHECKS(): - return {} - @hookspec def get_ADMINDATAVIEWS(): return {} diff --git a/archivebox/abx/archivebox/use.py b/archivebox/abx/archivebox/use.py index ddb70303..e958b62f 100644 --- a/archivebox/abx/archivebox/use.py +++ b/archivebox/abx/archivebox/use.py @@ -13,7 +13,6 @@ if TYPE_CHECKING: from .base_binary import BaseBinary, BaseBinProvider from .base_extractor import BaseExtractor from .base_replayer import BaseReplayer - from .base_check import BaseCheck from .base_queue import BaseQueue from .base_admindataview import BaseAdminDataView from .base_searchbackend import BaseSearchBackend @@ -79,13 +78,6 @@ def get_REPLAYERS() -> Dict[str, 'BaseReplayer']: for replayer in plugin_replayers }) -def get_CHECKS() -> Dict[str, 'BaseCheck']: - return benedict({ - check.id: check - for plugin_checks in pm.hook.get_CHECKS() - for check in plugin_checks - }) - def get_ADMINDATAVIEWS() -> Dict[str, 'BaseAdminDataView']: return benedict({ admin_dataview.id: admin_dataview diff --git a/archivebox/core/settings.py b/archivebox/core/settings.py index 82e27e35..3c2c40f0 100644 --- a/archivebox/core/settings.py +++ b/archivebox/core/settings.py @@ -62,7 +62,6 @@ BINPROVIDERS = abx.archivebox.use.get_BINPROVIDERS() BINARIES = abx.archivebox.use.get_BINARIES() EXTRACTORS = abx.archivebox.use.get_EXTRACTORS() REPLAYERS = abx.archivebox.use.get_REPLAYERS() -CHECKS = abx.archivebox.use.get_CHECKS() ADMINDATAVIEWS = abx.archivebox.use.get_ADMINDATAVIEWS() QUEUES = abx.archivebox.use.get_QUEUES() SEARCHBACKENDS = abx.archivebox.use.get_SEARCHBACKENDS() diff --git a/archivebox/plugins_pkg/pip/apps.py b/archivebox/plugins_pkg/pip/apps.py index a4c27f82..372aba89 100644 --- a/archivebox/plugins_pkg/pip/apps.py +++ b/archivebox/plugins_pkg/pip/apps.py @@ -12,13 +12,12 @@ import django import django.db.backends.sqlite3.base from django.db.backends.sqlite3.base import Database as django_sqlite3 # type: ignore[import-type] from django.core.checks import Error, Tags -from pydantic_pkgr import BinProvider, PipProvider, BinName, BinProviderName, ProviderLookupDict, SemVer, bin_abspath +from pydantic_pkgr import BinProvider, PipProvider, BinName, BinProviderName, ProviderLookupDict, SemVer from archivebox.config import CONSTANTS, VERSION from abx.archivebox.base_plugin import BasePlugin from abx.archivebox.base_configset import BaseConfigSet -from abx.archivebox.base_check import BaseCheck from abx.archivebox.base_binary import BaseBinary, BaseBinProvider, env, apt, brew from abx.archivebox.base_hook import BaseHook @@ -241,51 +240,6 @@ class PipxBinary(BaseBinary): PIPX_BINARY = PipxBinary() -class CheckUserIsNotRoot(BaseCheck): - label: str = 'CheckUserIsNotRoot' - tag: str = Tags.database - - @staticmethod - def check(settings, logger) -> List[Warning]: - errors = [] - if getattr(settings, "USER", None) == 'root' or getattr(settings, "PUID", None) == 0: - errors.append( - Error( - "Cannot run as root!", - id="core.S001", - hint=f'Run ArchiveBox as a non-root user with a UID greater than 500. (currently running as UID {os.getuid()}).', - ) - ) - # logger.debug('[√] UID is not root') - return errors - - -class CheckPipEnvironment(BaseCheck): - label: str = "CheckPipEnvironment" - tag: str = Tags.database - - @staticmethod - def check(settings, logger) -> List[Warning]: - # soft errors: check that lib/pip virtualenv is setup properly - errors = [] - - LIB_PIP_BINPROVIDER.setup() - if not LIB_PIP_BINPROVIDER.is_valid: - errors.append( - Error( - f"Failed to setup {LIB_PIP_BINPROVIDER.pip_venv} virtualenv for runtime dependencies!", - id="pip.P001", - hint="Make sure the data dir is writable and make sure python3-pip and python3-venv are installed & available on the host.", - ) - ) - # logger.debug("[√] CheckPipEnvironment: data/lib/pip virtualenv is setup properly") - return errors - - -USER_IS_NOT_ROOT_CHECK = CheckUserIsNotRoot() -PIP_ENVIRONMENT_CHECK = CheckPipEnvironment() - - class PipPlugin(BasePlugin): app_label: str = 'pip' verbose_name: str = 'PIP' @@ -302,8 +256,6 @@ class PipPlugin(BasePlugin): PYTHON_BINARY, SQLITE_BINARY, DJANGO_BINARY, - USER_IS_NOT_ROOT_CHECK, - PIP_ENVIRONMENT_CHECK, ] diff --git a/archivebox/vendor/pydantic-pkgr b/archivebox/vendor/pydantic-pkgr index e2f6b105..8177447e 160000 --- a/archivebox/vendor/pydantic-pkgr +++ b/archivebox/vendor/pydantic-pkgr @@ -1 +1 @@ -Subproject commit e2f6b10550f41e64817908eef3feb0aa33071969 +Subproject commit 8177447eb0d1bc93a886db1386cdfbee25343162 diff --git a/pyproject.toml b/pyproject.toml index 0a61298a..e0e944f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "archivebox" -version = "0.8.5rc32" +version = "0.8.5rc33" requires-python = ">=3.10" description = "Self-hosted internet archiving solution." authors = [{name = "Nick Sweeting", email = "pyproject.toml@archivebox.io"}] @@ -78,7 +78,7 @@ dependencies = [ "django-taggit==1.3.0", "base32-crockford==0.3.0", # "pocket@git+https://github.com/tapanpandita/pocket.git@v0.3.7", - "pydantic-pkgr>=0.4.21", + "pydantic-pkgr>=0.4.23", ############# Plugin Dependencies ################ "sonic-client>=1.0.0", "yt-dlp>=2024.8.6", # for: media" diff --git a/uv.lock b/uv.lock index 33132b53..7b9c5c59 100644 --- a/uv.lock +++ b/uv.lock @@ -41,7 +41,7 @@ wheels = [ [[package]] name = "archivebox" -version = "0.8.5rc32" +version = "0.8.5rc33" source = { editable = "." } dependencies = [ { name = "atomicwrites" }, @@ -148,7 +148,7 @@ requires-dist = [ { name = "pluggy", specifier = ">=1.5.0" }, { name = "psutil", specifier = ">=6.0.0" }, { name = "py-machineid", specifier = ">=0.6.0" }, - { name = "pydantic-pkgr", specifier = ">=0.4.21" }, + { name = "pydantic-pkgr", specifier = ">=0.4.23" }, { name = "pydantic-settings", specifier = ">=2.5.2" }, { name = "python-benedict", extras = ["io", "parse"], specifier = ">=0.33.2" }, { name = "python-crontab", specifier = ">=3.2.0" }, @@ -1834,16 +1834,16 @@ wheels = [ [[package]] name = "pydantic-pkgr" -version = "0.4.22" +version = "0.4.23" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "pydantic" }, { name = "pydantic-core" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/33/27/7f53f0b7e7359b20ddef4483256f535190e8b0bf291f0d0e63209e882a0b/pydantic_pkgr-0.4.22.tar.gz", hash = "sha256:5b6f7b19938b82483f5ba664ddf9ba249b9e9900a1088b0162dd378fd9291ea9", size = 38723 } +sdist = { url = "https://files.pythonhosted.org/packages/09/fe/92649747968cfc93508fe54d182605b555bba6dc9762f99cf80fbc914d67/pydantic_pkgr-0.4.23.tar.gz", hash = "sha256:f4508fc395ba36648d86d5ff9792603eb9f166e5ec2d3ca88616c725d423635e", size = 38721 } wheels = [ - { url = "https://files.pythonhosted.org/packages/c1/48/783c3d7aa78fcd2bda2e0da83c163fb828647d12b9b82a71ca59eb82629b/pydantic_pkgr-0.4.22-py3-none-any.whl", hash = "sha256:f359e8676d92f9e8cc2bff44720407b04ff87c1df2da49077e72a2f9cb65aa2a", size = 41699 }, + { url = "https://files.pythonhosted.org/packages/31/e0/a953dc79dccf8f77afe967d48d27bd911666598d1ac1b905101d291d32ad/pydantic_pkgr-0.4.23-py3-none-any.whl", hash = "sha256:f7f04683db6b669fb74dd6c94f08e4918d16d1a38910b4025b0dcb7a28f2bf25", size = 41703 }, ] [[package]]