mirror of
https://github.com/ArchiveBox/ArchiveBox
synced 2024-11-24 21:23:22 +00:00
fix LIB_NPM provider loading and euid
This commit is contained in:
parent
861b9cd16f
commit
f4f9ae2f28
4 changed files with 10 additions and 9 deletions
|
@ -2,7 +2,6 @@ __package__ = 'plugins_extractor.mercury'
|
|||
|
||||
from typing import List, Optional, Dict
|
||||
from pathlib import Path
|
||||
from subprocess import run
|
||||
|
||||
from pydantic import InstanceOf, Field
|
||||
from pydantic_pkgr import BinProvider, BinName, BinProviderName, ProviderLookupDict, bin_abspath
|
||||
|
@ -42,11 +41,10 @@ class MercuryBinary(BaseBinary):
|
|||
provider_overrides: Dict[BinProviderName, ProviderLookupDict] = {
|
||||
LIB_NPM_BINPROVIDER.name: {
|
||||
'packages': lambda: ['@postlight/parser@^2.2.3'],
|
||||
'version': lambda: run([str(LIB_NPM_BINPROVIDER.INSTALLER_BIN_ABSPATH), f'--prefix={LIB_NPM_BINPROVIDER.npm_prefix}', 'info', '@postlight/parser', 'version'], text=True, capture_output=True).stdout.strip(),
|
||||
},
|
||||
SYS_NPM_BINPROVIDER.name: {
|
||||
'packages': lambda: [], # never try to install things globally
|
||||
'version': lambda: run([str(SYS_NPM_BINPROVIDER.INSTALLER_BIN_ABSPATH), '-g', 'info', '@postlight/parser', 'version'], text=True, capture_output=True).stdout.strip(),
|
||||
'packages': lambda: ['@postlight/parser@^2.2.3'],
|
||||
'install': lambda: False, # never try to install things into global prefix
|
||||
},
|
||||
env.name: {
|
||||
'version': lambda: '999.999.999' if bin_abspath('postlight-parser', PATH=env.PATH) else None,
|
||||
|
|
|
@ -35,12 +35,12 @@ NPM_CONFIG = NpmDependencyConfigs(**DEFAULT_GLOBAL_CONFIG)
|
|||
OLD_NODE_BIN_PATH = DATA_DIR / 'node_modules' / '.bin'
|
||||
NEW_NODE_BIN_PATH = CONSTANTS.LIB_NPM_DIR / 'node_modules' / '.bin'
|
||||
|
||||
class SystemNpmProvider(NpmProvider, BaseBinProvider):
|
||||
class SystemNpmBinProvider(NpmProvider, BaseBinProvider):
|
||||
name: BinProviderName = "sys_npm"
|
||||
|
||||
npm_prefix: Optional[Path] = None
|
||||
|
||||
class LibNpmProvider(NpmProvider, BaseBinProvider):
|
||||
class LibNpmBinProvider(NpmProvider, BaseBinProvider):
|
||||
name: BinProviderName = "lib_npm"
|
||||
PATH: PATHStr = f'{NEW_NODE_BIN_PATH}:{OLD_NODE_BIN_PATH}'
|
||||
|
||||
|
@ -52,8 +52,8 @@ class LibNpmProvider(NpmProvider, BaseBinProvider):
|
|||
return self
|
||||
|
||||
|
||||
SYS_NPM_BINPROVIDER = SystemNpmProvider()
|
||||
LIB_NPM_BINPROVIDER = LibNpmProvider()
|
||||
SYS_NPM_BINPROVIDER = SystemNpmBinProvider()
|
||||
LIB_NPM_BINPROVIDER = LibNpmBinProvider()
|
||||
npm = LIB_NPM_BINPROVIDER
|
||||
|
||||
class NodeBinary(BaseBinary):
|
||||
|
|
|
@ -17,6 +17,7 @@ from pydantic_pkgr import (
|
|||
)
|
||||
|
||||
from archivebox.config import CONSTANTS
|
||||
from archivebox.config.permissions import ARCHIVEBOX_USER
|
||||
|
||||
# Depends on other Django apps:
|
||||
from abx.archivebox.base_plugin import BasePlugin
|
||||
|
@ -61,6 +62,8 @@ class PuppeteerBinProvider(BaseBinProvider):
|
|||
|
||||
PATH: PATHStr = str(CONSTANTS.LIB_BIN_DIR)
|
||||
|
||||
euid: Optional[int] = ARCHIVEBOX_USER
|
||||
|
||||
puppeteer_browsers_dir: Optional[Path] = LIB_DIR_BROWSERS
|
||||
puppeteer_install_args: List[str] = ["@puppeteer/browsers", "install", "--path", str(LIB_DIR_BROWSERS)]
|
||||
|
||||
|
|
2
archivebox/vendor/pydantic-pkgr
vendored
2
archivebox/vendor/pydantic-pkgr
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 830b3738f49109a05c8068df12f1e2167901953f
|
||||
Subproject commit ec4c2d5f5a034ea6c10a5337c3115fbe1504f52b
|
Loading…
Reference in a new issue