-
Notifications
You must be signed in to change notification settings - Fork 219
Description
Summary
Site-packages not found in system environment
I'm using ty on Ubuntu, where I want to use the system installation of python (/usr/bin/python3), but I get an
error whenever I am explicitly using it.
This error propogates all the way through to vscode - the server seems to function afterwards, but the error on
startup is a bit annoying.
Relevant Issues:
- support finding packages installed into Debian
dist-packagesdirectories #1323 looks like might be a downstream symptom of this.
Reproduction Steps
In a clean ubuntu docker docker run --rm -it ubuntu:
# Install ty
apt update ; apt install curl python3
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.local/bin/env
# Create a test file
echo "" > test.py
# Run ty using the system python3 install
uvx ty check test.py --python /usr/bin/python3
This results in the following error:
ty failed
Cause: Failed to discover the site-packages directory
Cause: Invalid `--python` argument `/usr`: Could not find a `site-packages` directory for this Python installation/executable
interestingly this error only occurs if --python is provided - I haven't been able to decern which interpreter is being used if not provided (-vvv does not reveal this information - perhaps it should?).
Please note that this is NOT an issue in some other distros. I've tested using the following container mages and the same reproduction steps:
alpine:latest(usingapkinstead ofaptof course)archlinux:latest(usingpacmaninstead ofaptof course)
It seems that this is a uniquely debian (and debian-derivative) issue. Those distros are also weird about their python3 installation methods, so that makes sense.
It looks like site_packages.rs is only looking at sys.prefix / lib for site-packages, whereas on debian-derivative platforms it's located in sys.prefix / local / lib instead.
I would suggest a patch where local is optionally traversed during the site packages search. I might give it a try myself, but my rust is very... rusty... So I'm not confident that I'll be able to get it done properly.
Version
0.0.10