rename pkgs app to pkg

This commit is contained in:
Nick Sweeting 2024-08-30 03:32:36 -07:00
parent 6e13cd4820
commit da76a84c45
No known key found for this signature in database
13 changed files with 80 additions and 5 deletions

View file

@ -17,7 +17,7 @@ from plugantic.extractors import Extractor, ExtractorName
from plugantic.plugins import Plugin
from plugantic.configs import ConfigSet, ConfigSectionName
from pkgs.settings import env
from pkg.settings import env
###################### Config ##########################

View file

@ -66,7 +66,7 @@ INSTALLED_APPS = [
'plugantic',
'core',
'api',
'pkgs',
'pkg',
*INSTALLED_PLUGINS.keys(),

View file

@ -1,11 +1,11 @@
__package__ = 'archivebox.pkgs'
__package__ = 'archivebox.pkg'
from django.apps import AppConfig
class PkgsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'pkgs'
name = 'pkg'
def ready(self):
from .settings import LOADED_DEPENDENCIES

View file

@ -0,0 +1,75 @@
__package__ = 'archivebox.pkg.management.commands'
from django.core.management.base import BaseCommand
from django.conf import settings
from pydantic_pkgr import Binary, BinProvider, BrewProvider, EnvProvider, SemVer
from pydantic_pkgr.binprovider import bin_abspath
from ....config import NODE_BIN_PATH, bin_path
from plugantic.plugins import LOADED_PLUGINS
from pkg.settings import env
class Command(BaseCommand):
def handle(self, *args, method, **options):
method(*args, **options)
def add_arguments(self, parser):
subparsers = parser.add_subparsers(title="sub-commands", required=True)
list_parser = subparsers.add_parser("list", help="List archivebox runtime dependencies.")
list_parser.set_defaults(method=self.list)
install_parser = subparsers.add_parser("install", help="Install archivebox runtime dependencies.")
install_parser.add_argument("--update", action="store_true", help="Update dependencies to latest versions.")
install_parser.add_argument("package_names", nargs="+", type=str)
install_parser.set_defaults(method=self.install)
def list(self, *args, **options):
self.stdout.write('################# PLUGINS ####################')
for plugin in LOADED_PLUGINS:
self.stdout.write(f'{plugin.name}:')
for binary in plugin.binaries:
try:
binary = binary.install()
except Exception as e:
# import ipdb; ipdb.set_trace()
raise
self.stdout.write(f' {binary.name.ljust(14)} {str(binary.version).ljust(11)} {binary.binprovider.INSTALLER_BIN.ljust(5)} {binary.abspath}')
self.stdout.write('\n################# LEGACY ####################')
for bin_key, dependency in settings.CONFIG.DEPENDENCIES.items():
bin_name = settings.CONFIG[bin_key]
self.stdout.write(f'{bin_key}: {bin_name}')
# binary = Binary(name=package_name, providers=[env])
# print(binary)
# try:
# loaded_bin = binary.load()
# self.stdout.write(
# self.style.SUCCESS(f'Successfully loaded {package_name}:') + str(loaded_bin)
# )
# except Exception as e:
# self.stderr.write(
# self.style.ERROR(f"Error loading {package_name}: {e}")
# )
def install(self, *args, bright, **options):
for package_name in options["package_names"]:
binary = Binary(name=package_name, providers=[env])
print(binary)
try:
loaded_bin = binary.load()
self.stdout.write(
self.style.SUCCESS(f'Successfully loaded {package_name}:') + str(loaded_bin)
)
except Exception as e:
self.stderr.write(
self.style.ERROR(f"Error loading {package_name}: {e}")
)

View file

View file

@ -1,4 +1,4 @@
__package__ = 'archivebox.pkgs'
__package__ = 'archivebox.pkg'
import os
import sys