mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 10:15:27 -04:00
The dependency-install fallback chain unconditionally ran 'pip install --user', which fails inside a virtualenv (and as root in LXC/containers) with 'Can not perform a --user install. User site-packages are not visible in this virtualenv.' — even though the function's docstring already noted --user is invalid in venvs. Guard the --user fallback with a venv check so it only runs outside a venv (where --user is actually valid for PEP-668 system Pythons). Derive the venv probe interpreter from the install command (python for 'pip', python3 for 'pip3'/'python3 -m pip') so the check runs in pip's own environment. System PEP-668 installs keep the --user fallback; venv/LXC-root installs no longer hit the --user error. Updated the unit test for the new chain. Closes #388
This commit is contained in:
@@ -92,8 +92,9 @@ def test_pip_install_fallback_chain_prefers_venv_safe_install():
|
||||
def test_pip_install_fallback_chain_allows_custom_python_command():
|
||||
chain = _pip_install_fallback_chain("hf_transfer", python_cmd="pip", upgrade=False)
|
||||
assert chain == (
|
||||
"pip install -q hf_transfer 2>/dev/null || "
|
||||
"pip install --user --break-system-packages -q hf_transfer 2>/dev/null"
|
||||
'pip install -q hf_transfer 2>/dev/null || { '
|
||||
'python -c "import sys; sys.exit(0 if sys.prefix != sys.base_prefix else 1)"'
|
||||
' || pip install --user --break-system-packages -q hf_transfer 2>/dev/null; }'
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user