mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-13 14:44:29 -04:00
new vastly simplified plugin spec without pydantic
Some checks are pending
Build Debian package / build (push) Waiting to run
Build Docker image / buildx (push) Waiting to run
Build Homebrew package / build (push) Waiting to run
Run linters / lint (push) Waiting to run
Build Pip package / build (push) Waiting to run
Run tests / python_tests (ubuntu-22.04, 3.11) (push) Waiting to run
Run tests / docker_tests (push) Waiting to run
Some checks are pending
Build Debian package / build (push) Waiting to run
Build Docker image / buildx (push) Waiting to run
Build Homebrew package / build (push) Waiting to run
Run linters / lint (push) Waiting to run
Build Pip package / build (push) Waiting to run
Run tests / python_tests (ubuntu-22.04, 3.11) (push) Waiting to run
Run tests / docker_tests (push) Waiting to run
This commit is contained in:
parent
abf75f49f4
commit
01ba6d49d3
115 changed files with 2466 additions and 2301 deletions
|
@ -0,0 +1,44 @@
|
|||
__package__ = 'plugins_pkg.playwright'
|
||||
__label__ = 'playwright'
|
||||
__version__ = '2024.10.14'
|
||||
__author__ = 'Nick Sweeting'
|
||||
__homepage__ = 'https://github.com/microsoft/playwright-python'
|
||||
|
||||
import abx
|
||||
|
||||
|
||||
@abx.hookimpl
|
||||
def get_PLUGIN():
|
||||
return {
|
||||
'playwright': {
|
||||
'PACKAGE': __package__,
|
||||
'LABEL': __label__,
|
||||
'VERSION': __version__,
|
||||
'AUTHOR': __author__,
|
||||
'HOMEPAGE': __homepage__,
|
||||
}
|
||||
}
|
||||
|
||||
@abx.hookimpl
|
||||
def get_CONFIG():
|
||||
from .config import PLAYWRIGHT_CONFIG
|
||||
|
||||
return {
|
||||
'playwright': PLAYWRIGHT_CONFIG
|
||||
}
|
||||
|
||||
@abx.hookimpl
|
||||
def get_BINARIES():
|
||||
from .binaries import PLAYWRIGHT_BINARY
|
||||
|
||||
return {
|
||||
'playwright': PLAYWRIGHT_BINARY,
|
||||
}
|
||||
|
||||
@abx.hookimpl
|
||||
def get_BINPROVIDERS():
|
||||
from .binproviders import PLAYWRIGHT_BINPROVIDER
|
||||
|
||||
return {
|
||||
'playwright': PLAYWRIGHT_BINPROVIDER,
|
||||
}
|
23
archivebox/plugins_pkg/playwright/binaries.py
Normal file
23
archivebox/plugins_pkg/playwright/binaries.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
__package__ = 'plugins_pkg.playwright'
|
||||
|
||||
from typing import List
|
||||
|
||||
from pydantic import InstanceOf
|
||||
from pydantic_pkgr import BinName, BinProvider
|
||||
|
||||
from abx.archivebox.base_binary import BaseBinary, env
|
||||
|
||||
from plugins_pkg.pip.binproviders import SYS_PIP_BINPROVIDER, VENV_PIP_BINPROVIDER, LIB_PIP_BINPROVIDER
|
||||
|
||||
from .config import PLAYWRIGHT_CONFIG
|
||||
|
||||
|
||||
|
||||
|
||||
class PlaywrightBinary(BaseBinary):
|
||||
name: BinName = PLAYWRIGHT_CONFIG.PLAYWRIGHT_BINARY
|
||||
|
||||
binproviders_supported: List[InstanceOf[BinProvider]] = [LIB_PIP_BINPROVIDER, VENV_PIP_BINPROVIDER, SYS_PIP_BINPROVIDER, env]
|
||||
|
||||
|
||||
PLAYWRIGHT_BINARY = PlaywrightBinary()
|
|
@ -1,15 +1,13 @@
|
|||
__package__ = 'archivebox.plugins_pkg.playwright'
|
||||
__package__ = 'plugins_pkg.playwright'
|
||||
|
||||
import os
|
||||
import platform
|
||||
from pathlib import Path
|
||||
from typing import List, Optional, Dict, ClassVar
|
||||
|
||||
# Depends on other PyPI/vendor packages:
|
||||
from pydantic import InstanceOf, computed_field, Field
|
||||
from pydantic import computed_field, Field
|
||||
from pydantic_pkgr import (
|
||||
BinName,
|
||||
BinProvider,
|
||||
BinProviderName,
|
||||
BinProviderOverrides,
|
||||
InstallArgs,
|
||||
|
@ -22,42 +20,15 @@ from pydantic_pkgr import (
|
|||
|
||||
from archivebox.config import CONSTANTS
|
||||
|
||||
# Depends on other Django apps:
|
||||
from abx.archivebox.base_plugin import BasePlugin
|
||||
from abx.archivebox.base_configset import BaseConfigSet
|
||||
from abx.archivebox.base_binary import BaseBinary, BaseBinProvider, env
|
||||
# from abx.archivebox.base_extractor import BaseExtractor
|
||||
# from abx.archivebox.base_queue import BaseQueue
|
||||
from abx.archivebox.base_hook import BaseHook
|
||||
from abx.archivebox.base_binary import BaseBinProvider, env
|
||||
|
||||
from plugins_pkg.pip.apps import SYS_PIP_BINPROVIDER, VENV_PIP_BINPROVIDER, LIB_PIP_BINPROVIDER
|
||||
from plugins_pkg.pip.binproviders import SYS_PIP_BINPROVIDER
|
||||
|
||||
from .binaries import PLAYWRIGHT_BINARY
|
||||
|
||||
|
||||
###################### Config ##########################
|
||||
|
||||
|
||||
class PlaywrightConfigs(BaseConfigSet):
|
||||
# PLAYWRIGHT_BINARY: str = Field(default='wget')
|
||||
# PLAYWRIGHT_ARGS: Optional[List[str]] = Field(default=None)
|
||||
# PLAYWRIGHT_EXTRA_ARGS: List[str] = []
|
||||
# PLAYWRIGHT_DEFAULT_ARGS: List[str] = ['--timeout={TIMEOUT-10}']
|
||||
pass
|
||||
|
||||
|
||||
PLAYWRIGHT_CONFIG = PlaywrightConfigs()
|
||||
|
||||
LIB_DIR_BROWSERS = CONSTANTS.LIB_BROWSERS_DIR
|
||||
|
||||
|
||||
|
||||
class PlaywrightBinary(BaseBinary):
|
||||
name: BinName = "playwright"
|
||||
|
||||
binproviders_supported: List[InstanceOf[BinProvider]] = [LIB_PIP_BINPROVIDER, VENV_PIP_BINPROVIDER, SYS_PIP_BINPROVIDER, env]
|
||||
|
||||
|
||||
|
||||
PLAYWRIGHT_BINARY = PlaywrightBinary()
|
||||
MACOS_PLAYWRIGHT_CACHE_DIR: Path = Path("~/Library/Caches/ms-playwright")
|
||||
LINUX_PLAYWRIGHT_CACHE_DIR: Path = Path("~/.cache/ms-playwright")
|
||||
|
||||
|
||||
class PlaywrightBinProvider(BaseBinProvider):
|
||||
|
@ -67,11 +38,11 @@ class PlaywrightBinProvider(BaseBinProvider):
|
|||
PATH: PATHStr = f"{CONSTANTS.LIB_BIN_DIR}:{DEFAULT_ENV_PATH}"
|
||||
|
||||
playwright_browsers_dir: Path = (
|
||||
Path("~/Library/Caches/ms-playwright").expanduser() # macos playwright cache dir
|
||||
MACOS_PLAYWRIGHT_CACHE_DIR.expanduser()
|
||||
if OPERATING_SYSTEM == "darwin" else
|
||||
Path("~/.cache/ms-playwright").expanduser() # linux playwright cache dir
|
||||
LINUX_PLAYWRIGHT_CACHE_DIR.expanduser()
|
||||
)
|
||||
playwright_install_args: List[str] = ["install"] # --with-deps
|
||||
playwright_install_args: List[str] = ["install"]
|
||||
|
||||
packages_handler: BinProviderOverrides = Field(default={
|
||||
"chrome": ["chromium"],
|
||||
|
@ -183,21 +154,3 @@ class PlaywrightBinProvider(BaseBinProvider):
|
|||
return (proc.stderr.strip() + "\n" + proc.stdout.strip()).strip()
|
||||
|
||||
PLAYWRIGHT_BINPROVIDER = PlaywrightBinProvider()
|
||||
|
||||
|
||||
|
||||
class PlaywrightPlugin(BasePlugin):
|
||||
app_label: str = 'playwright'
|
||||
verbose_name: str = 'Playwright (PIP)'
|
||||
|
||||
hooks: List[InstanceOf[BaseHook]] = [
|
||||
PLAYWRIGHT_CONFIG,
|
||||
PLAYWRIGHT_BINPROVIDER,
|
||||
PLAYWRIGHT_BINARY,
|
||||
]
|
||||
|
||||
|
||||
|
||||
PLUGIN = PlaywrightPlugin()
|
||||
# PLUGIN.register(settings)
|
||||
DJANGO_APP = PLUGIN.AppConfig
|
10
archivebox/plugins_pkg/playwright/config.py
Normal file
10
archivebox/plugins_pkg/playwright/config.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
__package__ = 'playwright'
|
||||
|
||||
from abx.archivebox.base_configset import BaseConfigSet
|
||||
|
||||
|
||||
class PlaywrightConfigs(BaseConfigSet):
|
||||
PLAYWRIGHT_BINARY: str = 'playwright'
|
||||
|
||||
|
||||
PLAYWRIGHT_CONFIG = PlaywrightConfigs()
|
Loading…
Add table
Add a link
Reference in a new issue