Skip to content

fix: honor _fresh installs with the uv installer - #1179

Closed
r3wretrhy wants to merge 1 commit into
pypa:mainfrom
r3wretrhy:fix/uv-fresh-reinstall
Closed

fix: honor _fresh installs with the uv installer#1179
r3wretrhy wants to merge 1 commit into
pypa:mainfrom
r3wretrhy:fix/uv-fresh-reinstall

Conversation

@r3wretrhy

@r3wretrhy r3wretrhy commented Sep 4, 2026

Copy link
Copy Markdown

Description

--installer uv ignored _fresh=True. Pip maps that flag to --ignore-installed so the CLI and project_wheel_metadata reinstall build requirements when PYTHONPATH is preset. The uv backend accepted _fresh but never forwarded it.

Pass uv pip install --reinstall in that case, matching pip's behavior.

Changelog

  • Added changelog fragment: docs/changelog/1179.bugfix.rst

Checklist

  • Tests pass locally (uv run pytest tests/test_env.py::test_uv_impl_install_cmd_well_formed tests/test_env.py::test_default_impl_install_cmd_well_formed — 24 passed)
  • Code follows project style (ruff check / ruff format --check)

Pip maps _fresh to --ignore-installed so CLI and project_wheel_metadata
reinstall into the isolated env when PYTHONPATH is preset. The uv backend
accepted _fresh but never forwarded it, so those installs could reuse
already-present packages. Pass uv pip install --reinstall instead.
@r3wretrhy
r3wretrhy force-pushed the fix/uv-fresh-reinstall branch from 734e7da to 5972ab2 Compare September 4, 2026 23:15
@layday

layday commented Sep 5, 2026

Copy link
Copy Markdown
Member

Please provide evidence that uv is impacted by the same issue.

@henryiii

henryiii commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

FYI, I was suspicious too that this was valid, and ran a check with Claude:

🤖 AI text below 🤖

No, the PR fixes a bug that does not exist, and the two flags are not equivalent.

The premise is wrong. The reason pip needs --ignore-installed is that pip runs inside the target interpreter and sees packages on PYTHONPATH as "already satisfied". uv is an external binary that inspects the venv's site-packages directly, so it never sees PYTHONPATH packages. On top of that, the uv backend already strips PYTHONPATH from the subprocess environment at src/build/env.py:486. I verified this empirically with uv 0.12.10: with PYTHONPATH pointing at a directory containing packaging, uv pip install packaging into an empty venv installs it anyway, while plain pip install skips it and pip install --ignore-installed installs it. So the uv backend already behaves correctly without this change.

The flags differ in semantics:

  • --ignore-installed (pip) does not uninstall anything. It overwrites files on top of whatever is there and can leave stale files behind.
  • --reinstall (uv) uninstalls and reinstalls every package, and also implies --refresh, which forces revalidation of cached index metadata against the server. That is extra network traffic on every isolated build for no benefit, since the venv is always freshly created.

Recommendation: close the PR or ask for a reproducer. If a reproducer surfaces, the right uv analogue would be to look at why PYTHONPATH stripping did not work, not to add --reinstall.

@r3wretrhy

Copy link
Copy Markdown
Author

I don't have a uv reproducer. _UvBackend.install_dependencies already drops PYTHONPATH from the subprocess environment, so uv does not see host packages the way in-process pip does. --reinstall is also not equivalent to pip's --ignore-installed (it uninstalls and implies --refresh). Closing.

@r3wretrhy r3wretrhy closed this Sep 7, 2026
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.

3 participants