mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-09-14 11:06:13 +05:00
Resolve install targets from provider package args
This commit is contained in:
parent
491f5d43db
commit
8c68b43f46
@ -3,6 +3,7 @@
|
||||
__package__ = "archivebox.cli"
|
||||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
@ -12,6 +13,40 @@ from rich import print
|
||||
from archivebox.misc.util import docstring, enforce_types
|
||||
|
||||
|
||||
def _package_name_candidates(install_arg: object) -> set[str]:
|
||||
"""Return user-facing package tokens represented by a provider install arg."""
|
||||
value = str(install_arg).strip()
|
||||
if not value or value.startswith("-"):
|
||||
return set()
|
||||
|
||||
candidates = {value}
|
||||
package_name = re.split(r"==|>=|<=|~=|!=|>|<|\[", value, maxsplit=1)[0]
|
||||
if "@" in package_name and not package_name.startswith("@"):
|
||||
package_name = package_name.split("@", 1)[0]
|
||||
if package_name:
|
||||
candidates.add(package_name)
|
||||
candidates.add(Path(package_name).name)
|
||||
return candidates
|
||||
|
||||
|
||||
def _binary_record_candidates(binary_record: dict) -> set[str]:
|
||||
"""Return install-name tokens represented by an abx-dl binary request record."""
|
||||
name = str(binary_record.get("name") or "")
|
||||
display_name = Path(name).expanduser().name if ("/" in name or name.startswith("~")) else name
|
||||
candidates = {name, display_name}
|
||||
overrides = binary_record.get("overrides") or {}
|
||||
if isinstance(overrides, dict):
|
||||
for provider_overrides in overrides.values():
|
||||
if not isinstance(provider_overrides, dict):
|
||||
continue
|
||||
install_args = provider_overrides.get("install_args") or ()
|
||||
if isinstance(install_args, str):
|
||||
install_args = (install_args,)
|
||||
for install_arg in install_args:
|
||||
candidates.update(_package_name_candidates(install_arg))
|
||||
return {candidate for candidate in candidates if candidate}
|
||||
|
||||
|
||||
def _resolve_install_plugin_names(
|
||||
requested_names: tuple[str, ...],
|
||||
) -> list[str]:
|
||||
@ -51,10 +86,7 @@ def _resolve_install_plugin_names(
|
||||
logical_names=False,
|
||||
)
|
||||
for logical_record, actual_record in zip(logical_records, actual_records, strict=False):
|
||||
logical_name = str(logical_record["name"])
|
||||
actual_name = str(actual_record["name"])
|
||||
display_name = Path(actual_name).expanduser().name if ("/" in actual_name or actual_name.startswith("~")) else actual_name
|
||||
if requested_name in {logical_name, actual_name, display_name}:
|
||||
if requested_name in _binary_record_candidates(logical_record) | _binary_record_candidates(actual_record):
|
||||
matched_plugin_names.append(plugin_name)
|
||||
break
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "archivebox",
|
||||
"version": "0.9.35rc166",
|
||||
"version": "0.9.35rc167",
|
||||
"repository": "github:ArchiveBox/ArchiveBox",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "archivebox"
|
||||
version = "0.9.35rc166"
|
||||
version = "0.9.35rc167"
|
||||
requires-python = ">=3.13"
|
||||
description = "Self-hosted internet archiving solution."
|
||||
authors = [{name = "Nick Sweeting", email = "pyproject.toml@archivebox.io"}]
|
||||
@ -348,7 +348,7 @@ Donate = "https://github.com/ArchiveBox/ArchiveBox/wiki/Donations"
|
||||
|
||||
|
||||
[tool.bumpver]
|
||||
current_version = "v0.9.35rc166"
|
||||
current_version = "v0.9.35rc167"
|
||||
version_pattern = "vMAJOR.MINOR.PATCH[PYTAGNUM]"
|
||||
commit_message = "bump version {old_version} -> {new_version}"
|
||||
tag_message = "{new_version}"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user