Skip to content

Pass --python sys.executable to the uv download fallback - #14064

Open
vshalpnjabi wants to merge 1 commit into
explosion:masterfrom
vshalpnjabi:fix-uv-download-python
Open

vshalpnjabi wants to merge 1 commit into
explosion:masterfrom
vshalpnjabi:fix-uv-download-python

Conversation

@vshalpnjabi

Copy link
Copy Markdown

Description

python -m spacy download fails with exit 2 in a uv-created venv that isn't
activated. When pip isn't available, _get_pip_install_cmd() falls back to
["uv", "pip", "install"] with no --python, so uv can't find the
environment ("No virtual environment found").

This passes --python sys.executable so uv installs into the running
interpreter, the same target the pip branch uses (sys.executable -m pip).
Activated venvs still work, since --python takes precedence over
VIRTUAL_ENV.

Fixes #14055

Tested on Linux, Python 3.12.3, uv 0.13.6:

  • Before: spaCy 3.8.18 in an unactivated uv venv,
    cd / && env -u VIRTUAL_ENV /tmp/v/bin/python -m spacy download en_core_web_sm
    exits 2 with "No virtual environment found".
  • After: the same command with this branch installs en_core_web_sm 3.8.0.
  • python -m pytest spacy/tests/test_cli.py: 121 passed, 4 skipped.
  • ruff check and ruff format --check on the touched files.

Types of change

Bug fix

Checklist

  • I confirm that I have the right to submit this contribution under the project's MIT license.
  • I ran the tests, and all new and existing tests passed.
  • My changes don't require a change to the documentation, or if they do, I've added all required information.

uv pip install without --python cannot find an unactivated uv venv
and exits 2. Target the running interpreter, as the pip branch does.

Fixes explosion#14055

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spacy download fails in a uv-created venv: the uv fallback in _get_pip_install_cmd() omits --python sys.executable

1 participant