浏览代码

remove CHECKS feature, not needed

Nick Sweeting 1 年之前
父节点
当前提交
04d2316800

+ 0 - 44
archivebox/abx/archivebox/base_check.py

@@ -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)

+ 0 - 4
archivebox/abx/archivebox/hookspec.py

@@ -17,10 +17,6 @@ def get_EXTRACTORS():
 def get_REPLAYERS():
 def get_REPLAYERS():
     return {}
     return {}
 
 
-@hookspec
-def get_CHECKS():
-    return {}
-
 @hookspec
 @hookspec
 def get_ADMINDATAVIEWS():
 def get_ADMINDATAVIEWS():
     return {}
     return {}

+ 0 - 8
archivebox/abx/archivebox/use.py

@@ -13,7 +13,6 @@ if TYPE_CHECKING:
     from .base_binary import BaseBinary, BaseBinProvider
     from .base_binary import BaseBinary, BaseBinProvider
     from .base_extractor import BaseExtractor
     from .base_extractor import BaseExtractor
     from .base_replayer import BaseReplayer
     from .base_replayer import BaseReplayer
-    from .base_check import BaseCheck
     from .base_queue import BaseQueue
     from .base_queue import BaseQueue
     from .base_admindataview import BaseAdminDataView
     from .base_admindataview import BaseAdminDataView
     from .base_searchbackend import BaseSearchBackend
     from .base_searchbackend import BaseSearchBackend
@@ -79,13 +78,6 @@ def get_REPLAYERS() -> Dict[str, 'BaseReplayer']:
             for replayer in plugin_replayers
             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']:
 def get_ADMINDATAVIEWS() -> Dict[str, 'BaseAdminDataView']:
     return benedict({
     return benedict({
         admin_dataview.id: admin_dataview
         admin_dataview.id: admin_dataview

+ 0 - 1
archivebox/core/settings.py

@@ -62,7 +62,6 @@ BINPROVIDERS = abx.archivebox.use.get_BINPROVIDERS()
 BINARIES = abx.archivebox.use.get_BINARIES()
 BINARIES = abx.archivebox.use.get_BINARIES()
 EXTRACTORS = abx.archivebox.use.get_EXTRACTORS()
 EXTRACTORS = abx.archivebox.use.get_EXTRACTORS()
 REPLAYERS = abx.archivebox.use.get_REPLAYERS()
 REPLAYERS = abx.archivebox.use.get_REPLAYERS()
-CHECKS = abx.archivebox.use.get_CHECKS()
 ADMINDATAVIEWS = abx.archivebox.use.get_ADMINDATAVIEWS()
 ADMINDATAVIEWS = abx.archivebox.use.get_ADMINDATAVIEWS()
 QUEUES = abx.archivebox.use.get_QUEUES()
 QUEUES = abx.archivebox.use.get_QUEUES()
 SEARCHBACKENDS = abx.archivebox.use.get_SEARCHBACKENDS()
 SEARCHBACKENDS = abx.archivebox.use.get_SEARCHBACKENDS()

+ 1 - 49
archivebox/plugins_pkg/pip/apps.py

@@ -12,13 +12,12 @@ import django
 import django.db.backends.sqlite3.base
 import django.db.backends.sqlite3.base
 from django.db.backends.sqlite3.base import Database as django_sqlite3     # type: ignore[import-type]
 from django.db.backends.sqlite3.base import Database as django_sqlite3     # type: ignore[import-type]
 from django.core.checks import Error, Tags
 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 archivebox.config import CONSTANTS, VERSION
 
 
 from abx.archivebox.base_plugin import BasePlugin
 from abx.archivebox.base_plugin import BasePlugin
 from abx.archivebox.base_configset import BaseConfigSet
 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_binary import BaseBinary, BaseBinProvider, env, apt, brew
 from abx.archivebox.base_hook import BaseHook
 from abx.archivebox.base_hook import BaseHook
 
 
@@ -241,51 +240,6 @@ class PipxBinary(BaseBinary):
 PIPX_BINARY = PipxBinary()
 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):
 class PipPlugin(BasePlugin):
     app_label: str = 'pip'
     app_label: str = 'pip'
     verbose_name: str = 'PIP'
     verbose_name: str = 'PIP'
@@ -302,8 +256,6 @@ class PipPlugin(BasePlugin):
         PYTHON_BINARY,
         PYTHON_BINARY,
         SQLITE_BINARY,
         SQLITE_BINARY,
         DJANGO_BINARY,
         DJANGO_BINARY,
-        USER_IS_NOT_ROOT_CHECK,
-        PIP_ENVIRONMENT_CHECK,
     ]
     ]
 
 
 
 

+ 1 - 1
archivebox/vendor/pydantic-pkgr

@@ -1 +1 @@
-Subproject commit e2f6b10550f41e64817908eef3feb0aa33071969
+Subproject commit 8177447eb0d1bc93a886db1386cdfbee25343162

+ 2 - 2
pyproject.toml

@@ -1,6 +1,6 @@
 [project]
 [project]
 name = "archivebox"
 name = "archivebox"
-version = "0.8.5rc32"
+version = "0.8.5rc33"
 requires-python = ">=3.10"
 requires-python = ">=3.10"
 description = "Self-hosted internet archiving solution."
 description = "Self-hosted internet archiving solution."
 authors = [{name = "Nick Sweeting", email = "[email protected]"}]
 authors = [{name = "Nick Sweeting", email = "[email protected]"}]
@@ -78,7 +78,7 @@ dependencies = [
     "django-taggit==1.3.0",
     "django-taggit==1.3.0",
     "base32-crockford==0.3.0",
     "base32-crockford==0.3.0",
     # "pocket@git+https://github.com/tapanpandita/[email protected]",
     # "pocket@git+https://github.com/tapanpandita/[email protected]",
-    "pydantic-pkgr>=0.4.21",
+    "pydantic-pkgr>=0.4.23",
     ############# Plugin Dependencies ################
     ############# Plugin Dependencies ################
     "sonic-client>=1.0.0",
     "sonic-client>=1.0.0",
     "yt-dlp>=2024.8.6",               # for: media"
     "yt-dlp>=2024.8.6",               # for: media"

+ 5 - 5
uv.lock

@@ -41,7 +41,7 @@ wheels = [
 
 
 [[package]]
 [[package]]
 name = "archivebox"
 name = "archivebox"
-version = "0.8.5rc32"
+version = "0.8.5rc33"
 source = { editable = "." }
 source = { editable = "." }
 dependencies = [
 dependencies = [
     { name = "atomicwrites" },
     { name = "atomicwrites" },
@@ -148,7 +148,7 @@ requires-dist = [
     { name = "pluggy", specifier = ">=1.5.0" },
     { name = "pluggy", specifier = ">=1.5.0" },
     { name = "psutil", specifier = ">=6.0.0" },
     { name = "psutil", specifier = ">=6.0.0" },
     { name = "py-machineid", specifier = ">=0.6.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 = "pydantic-settings", specifier = ">=2.5.2" },
     { name = "python-benedict", extras = ["io", "parse"], specifier = ">=0.33.2" },
     { name = "python-benedict", extras = ["io", "parse"], specifier = ">=0.33.2" },
     { name = "python-crontab", specifier = ">=3.2.0" },
     { name = "python-crontab", specifier = ">=3.2.0" },
@@ -1834,16 +1834,16 @@ wheels = [
 
 
 [[package]]
 [[package]]
 name = "pydantic-pkgr"
 name = "pydantic-pkgr"
-version = "0.4.22"
+version = "0.4.23"
 source = { registry = "https://pypi.org/simple" }
 source = { registry = "https://pypi.org/simple" }
 dependencies = [
 dependencies = [
     { name = "pydantic" },
     { name = "pydantic" },
     { name = "pydantic-core" },
     { name = "pydantic-core" },
     { name = "typing-extensions" },
     { 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 = [
 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]]
 [[package]]