mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-13 22:54:27 -04:00
fix loading of plugin dependencies and bump pydantic_pkgr version
This commit is contained in:
parent
a8f00caff8
commit
6e13cd4820
4 changed files with 28 additions and 8 deletions
|
@ -13,7 +13,7 @@ from pydantic import (
|
||||||
SerializeAsAny,
|
SerializeAsAny,
|
||||||
)
|
)
|
||||||
|
|
||||||
from pydantic_pkgr import BinProvider, BinProviderName, ProviderLookupDict, BinName, Binary, EnvProvider, NpmProvider
|
from pydantic_pkgr import SemVer, BinProvider, BinProviderName, ProviderLookupDict, BinName, Binary, EnvProvider, NpmProvider
|
||||||
|
|
||||||
from plugantic.extractors import Extractor, ExtractorName
|
from plugantic.extractors import Extractor, ExtractorName
|
||||||
from plugantic.plugins import Plugin
|
from plugantic.plugins import Plugin
|
||||||
|
@ -42,12 +42,13 @@ class SqliteBinary(Binary):
|
||||||
provider_overrides: Dict[BinProviderName, ProviderLookupDict] = {
|
provider_overrides: Dict[BinProviderName, ProviderLookupDict] = {
|
||||||
'env': {
|
'env': {
|
||||||
'abspath': \
|
'abspath': \
|
||||||
lambda: inspect.getfile(sqlite3),
|
lambda: Path(inspect.getfile(sqlite3)),
|
||||||
'version': \
|
'version': \
|
||||||
lambda: sqlite3.version,
|
lambda: SemVer(sqlite3.version),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class DjangoBinary(Binary):
|
class DjangoBinary(Binary):
|
||||||
name: BinName = 'django'
|
name: BinName = 'django'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import List, Optional
|
from typing import List, Optional, Dict
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
@ -10,11 +10,15 @@ from pydantic import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from pydantic_pkgr import BinProvider, BinName, Binary, EnvProvider, NpmProvider
|
from pydantic_pkgr import BinProvider, BinName, Binary, EnvProvider, NpmProvider
|
||||||
|
from pydantic_pkgr.binprovider import bin_abspath
|
||||||
|
from pydantic_pkgr.binary import BinProviderName, ProviderLookupDict
|
||||||
|
|
||||||
from plugantic.extractors import Extractor, ExtractorName
|
from plugantic.extractors import Extractor, ExtractorName
|
||||||
from plugantic.plugins import Plugin
|
from plugantic.plugins import Plugin
|
||||||
from plugantic.configs import ConfigSet, ConfigSectionName
|
from plugantic.configs import ConfigSet, ConfigSectionName
|
||||||
|
|
||||||
|
from pkgs.settings import env
|
||||||
|
|
||||||
|
|
||||||
###################### Config ##########################
|
###################### Config ##########################
|
||||||
|
|
||||||
|
@ -58,9 +62,23 @@ PLUGIN_CONFIG = [
|
||||||
|
|
||||||
###################### Binaries ############################
|
###################### Binaries ############################
|
||||||
|
|
||||||
|
min_version: str = "1.1.54"
|
||||||
|
max_version: str = "2.0.0"
|
||||||
|
|
||||||
class SinglefileBinary(Binary):
|
class SinglefileBinary(Binary):
|
||||||
name: BinName = 'single-file'
|
name: BinName = 'single-file'
|
||||||
providers_supported: List[BinProvider] = [EnvProvider(), NpmProvider()]
|
providers_supported: List[BinProvider] = [NpmProvider()]
|
||||||
|
|
||||||
|
|
||||||
|
provider_overrides: Dict[BinProviderName, ProviderLookupDict] ={
|
||||||
|
'env': {
|
||||||
|
'abspath': lambda: bin_abspath('single-file-node.js', PATH=env.PATH) or bin_abspath('single-file', PATH=env.PATH),
|
||||||
|
},
|
||||||
|
'npm': {
|
||||||
|
# 'abspath': lambda: bin_abspath('single-file', PATH=NpmProvider().PATH) or bin_abspath('single-file', PATH=env.PATH),
|
||||||
|
'subdeps': lambda: f'single-file-cli@>={min_version} <{max_version}',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
###################### Extractors ##########################
|
###################### Extractors ##########################
|
||||||
|
|
|
@ -66,7 +66,7 @@ for bin_key, dependency in settings.CONFIG.DEPENDENCIES.items():
|
||||||
try:
|
try:
|
||||||
binary = binary_spec.load()
|
binary = binary_spec.load()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"- ❌ Binary {bin_name} failed to load with error: {e}")
|
# print(f"- ❌ Binary {bin_name} failed to load with error: {e}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
assert isinstance(binary.loaded_version, SemVer)
|
assert isinstance(binary.loaded_version, SemVer)
|
||||||
|
@ -76,7 +76,8 @@ for bin_key, dependency in settings.CONFIG.DEPENDENCIES.items():
|
||||||
assert str(binary.loaded_respath) == str(bin_abspath(dependency['path']).resolve()), f"Expected {bin_name} abspath {bin_abspath(dependency['path']).resolve()}, got {binary.loaded_respath}"
|
assert str(binary.loaded_respath) == str(bin_abspath(dependency['path']).resolve()), f"Expected {bin_name} abspath {bin_abspath(dependency['path']).resolve()}, got {binary.loaded_respath}"
|
||||||
assert binary.is_valid == dependency['is_valid'], f"Expected {bin_name} is_valid={dependency['is_valid']}, got {binary.is_valid}"
|
assert binary.is_valid == dependency['is_valid'], f"Expected {bin_name} is_valid={dependency['is_valid']}, got {binary.is_valid}"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"WARNING: Error loading {bin_name}: {e}")
|
pass
|
||||||
|
# print(f"WARNING: Error loading {bin_name}: {e}")
|
||||||
# import ipdb; ipdb.set_trace()
|
# import ipdb; ipdb.set_trace()
|
||||||
|
|
||||||
# print(f"- ✅ Binary {bin_name} loaded successfully")
|
# print(f"- ✅ Binary {bin_name} loaded successfully")
|
||||||
|
|
2
archivebox/vendor/pydantic-pkgr
vendored
2
archivebox/vendor/pydantic-pkgr
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 3711257c2080634f266600af7ea61c92d9c364c9
|
Subproject commit 2cd844533d888ce29b9bf32b8363510dd0d76166
|
Loading…
Add table
Add a link
Reference in a new issue