You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to run uv run --with pylint -- pylint ..., and pylint is complaining about not being able to resolve import statements in my source. Indeed, sys.path in that context doesn't have the virtual environment's packages.
[project]
name = "test"version = "1.2.3"requires-python = "==3.11.*"dependencies = [
"regex", # or whatever
]
$ uv run --with pylint -- python -c 'import sys; print("\n".join(sys.path))'Using Python 3.11.9 interpreter at: /opt/homebrew/opt/python@3.11/bin/python3.11Removed virtual environment at: .venvCreating virtualenv at: .venvInstalled 1 package in 4ms/opt/homebrew/Cellar/python@3.11/3.11.9_1/Frameworks/Python.framework/Versions/3.11/lib/python311.zip/opt/homebrew/Cellar/python@3.11/3.11.9_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/opt/homebrew/Cellar/python@3.11/3.11.9_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/Users/duvall/Library/Caches/uv/archive-v0/rpeJdmPWBfImmHdlLv7hN/lib/python3.11/site-packages
$ uv run --with pylint -- python -c "import regex"Traceback (most recent call last): File "<string>", line 1, in <module>ModuleNotFoundError: No module named 'regex'
Interestingly, this works fine with the Python 3.9 installed on the system, but not on any version installed by Homebrew (3.9 included):
I think this has something to do with sitecustomize.py - homebrew pythons are for some reason installing such a file? And it interferes with how uv is creating the overlay effect (ephemeral virtualenv layered on top of .venv).
## Summary
Use a path file (`.pth`) instead of `sitecustomize.py` for configuring
path in emphemeral virtualenvs, overlaying the ephemeral venv on top of
the base `.venv`.
`sitecustomize.py` is a module in the python installation and as such a
unique resource - homebrew pythons on macos already install such a file
and thus uv's `sitecustomize.py`, placed in the ephemeral env, did not
have any effect.
I don't find any documentation explicitly saying that addsitedir is
valid in `.pth` files but from trial it seems to be - and there is the
precedent of the existing _virtualenv.pth _virtualenv.py pair that do
nontrivial operations.
## Test Plan
- Testing on ephemeral venv, resolving to base venv including editable
install in base: done (py3.7, 3.12)
- Testing on homebrew python/macos: done (py3.11)
- tests: run_editable
Fixes#7152
I'm trying to run
uv run --with pylint -- pylint ...
, andpylint
is complaining about not being able to resolveimport
statements in my source. Indeed,sys.path
in that context doesn't have the virtual environment's packages.Interestingly, this works fine with the Python 3.9 installed on the system, but not on any version installed by Homebrew (3.9 included):
though I was seeing this with
0.4.4
as well.The text was updated successfully, but these errors were encountered: