astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
27.45k stars 790 forks source link

Request: Add system-site-packages using uv add --script #7999

Open Eloitor opened 1 month ago

Eloitor commented 1 month ago

First I installed sage using the package manager of my linux distribution.

This works

main.py

from sage.all import ZZ
print(ZZ)
uv run main.py

Output is Integer Ring.

This does not work

uv add --script main.py datasheet
uv run main.py

I get:

Reading inline script metadata from: main.py
Traceback (most recent call last):
  File "/home/eloi/main.py", line 7, in <module>
    from sage.all import ZZ
ModuleNotFoundError: No module named 'sage'

Request

It would be nice if it was possible to add system-site-packages using uv add --script

Eloitor commented 1 month ago

related: https://github.com/astral-sh/uv/issues/1483

jbcpollak commented 2 weeks ago

More generally, uv will dynamically make a venv if one is needed for certain commands - is it possible to set an environment variable or something so that whenever uv needs a venv, it will use --system-site-packages?