astral-sh / uv

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

Install packages in managed python #8202

Open ion-elgreco opened 1 month ago

ion-elgreco commented 1 month ago

Currently when you install packages with --system it will use the system installation. Is there a way to force to install packages in the managed installation without creating a venv?

charliermarsh commented 1 month ago

Are you asking if there's a way to achieve the --system behavior without passing --system?

zanieb commented 1 month ago

We explicitly don't allow installing packages into the managed Python installation environments.

ion-elgreco commented 1 month ago

We explicitly don't allow installing packages into the managed Python installation environments.

Why not?

zanieb commented 1 month ago

Because they're only intended to be sources for creating virtual environments. We are trying to move away from mutable global state.

ion-elgreco commented 1 month ago

Because they're only intended to be sources for creating virtual environments. We are trying to move away from mutable global state.

Hmm I need to setup a system wide installation which has all the packages since the environment has no internet access. I think there is still some domains that need this

zanieb commented 1 month ago

Perhaps our Docker guide would be helpful to demonstrate how to setup a system-wide environment.

ion-elgreco commented 1 month ago

Perhaps our Docker guide would be helpful to demonstrate how to setup a system-wide environment.

I'm using a custom base image, so I wanted to avoid the hassle of installing a specific python version and use UV for that, and then install packages in that managed python version.

But I will install the python version I need explicitly then

zanieb commented 1 month ago

You can still do that, you just need to put create a virtual environment and put it on the path (as described in the linked guide). Is there a reason that's not an option?

ion-elgreco commented 1 month ago

You can still do that, you just need to put create a virtual environment and put it on the path (as described in the linked guide). Is there a reason that's not an option?

There is no project to install so to say, also the directory where stuff will happen is not fixed

zanieb commented 1 month ago

I'm not sure I really understand your point, why isn't this sufficient:

uv venv
export VIRTUAL_ENV="$(pwd)/.venv"
export PATH="$VIRTUAL_ENV/bin:$PATH"
ion-elgreco commented 1 month ago

I'm not sure I really understand your point, why isn't this sufficient:

uv venv
export VIRTUAL_ENV="$(pwd)/.venv"
export PATH="$VIRTUAL_ENV/bin:$PATH"

Because the working directory might not be known, so someone has to specifically know the venv path since our IDE's don't recognize it automatically.

I tried this now with a small test but having a system installation with packages installed in it, has the preference

zanieb commented 1 month ago

so someone has to specifically know the venv path since our IDE's don't recognize it automatically.

Why don't you make the virtual environment in a specific location then? One that your IDE looks in?

The IDE won't look in the managed Python environment either, it's in an arbitrary location.