Skip to content

Commit bd45642

Browse files
committed
Auto-install missing installer binaries
Signed-off-by: Nick Sweeting <git@sweeting.me>
1 parent dbd6498 commit bd45642

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

abxpkg/binprovider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ def INSTALLER_BINARY(self, no_cache: bool = False) -> ShallowBinary:
876876
loaded = Binary(
877877
name=self.INSTALLER_BIN,
878878
binproviders=manual_installer_providers,
879-
).load(
879+
).install(
880880
no_cache=no_cache,
881881
)
882882
if loaded and loaded.loaded_abspath:
@@ -902,7 +902,7 @@ def INSTALLER_BINARY(self, no_cache: bool = False) -> ShallowBinary:
902902
loaded = Binary(
903903
name=self.INSTALLER_BIN,
904904
binproviders=installer_providers,
905-
).load(no_cache=no_cache)
905+
).install(no_cache=no_cache)
906906
if loaded and loaded.loaded_abspath:
907907
if loaded.loaded_version and loaded.loaded_sha256:
908908
self.write_cached_binary(

tests/test_binprovider.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
import pytest
77

88
from abxpkg import (
9+
BinName,
10+
BinProvider,
11+
BinProviderName,
912
BunProvider,
1013
DenoProvider,
1114
EnvProvider,
@@ -79,6 +82,32 @@ def test_installer_binary_abspath_resolves_without_recursing(
7982
assert installer.name == installer_bin
8083
assert installer.loaded_version is not None
8184

85+
def test_installer_binary_auto_installs_missing_dependency_into_configured_lib(
86+
self,
87+
monkeypatch,
88+
):
89+
class BlackInstallerProvider(BinProvider):
90+
name: BinProviderName = "black_bootstrap"
91+
INSTALLER_BIN: BinName = "black"
92+
93+
with tempfile.TemporaryDirectory() as tmpdir:
94+
tmpdir_path = Path(tmpdir)
95+
monkeypatch.setenv("ABXPKG_BINPROVIDERS", "pip")
96+
monkeypatch.setenv("ABXPKG_LIB_DIR", str(tmpdir_path / "abxlib"))
97+
98+
installer = BlackInstallerProvider(
99+
postinstall_scripts=True,
100+
min_release_age=0,
101+
).INSTALLER_BINARY(no_cache=True)
102+
103+
assert installer.loaded_binprovider is not None
104+
assert installer.loaded_binprovider.name == "pip"
105+
assert installer.loaded_abspath is not None
106+
assert installer.loaded_abspath.resolve().is_relative_to(
107+
(tmpdir_path / "abxlib" / "pip" / "venv" / "bin").resolve(),
108+
)
109+
assert installer.loaded_version is not None
110+
82111
def test_base_public_getters_resolve_real_host_python(self, test_machine):
83112
provider = EnvProvider(postinstall_scripts=True, min_release_age=0)
84113

0 commit comments

Comments
 (0)