astral-sh / uv

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

Pyenv and UV virtualenv directories coexistence #8072

Open WSF-SEO-AM opened 1 month ago

WSF-SEO-AM commented 1 month ago

I've a couple of projects of mine that have been started with pyenv only.. I'm now attracted by the idea of using UV as a factotum, but I'm unsure whether the existing pyenv virtual environment can be designated as a location for UV too.

See below a preliminary attempt of setting the environment path:

Is this concurrent setup something for which support should be expected, or UV is meant to run only on its own?

WSF-SEO-AM commented 1 month ago

So, it seems like this co-existince is possible so long that pyenv creates the virtual environment and the uv venv is not used, rather the environment is activated and deactivated via pyenv itself. By doing this it is possible to leverage on uv managing the pyproject.toml file as well as the pip command and it's increased speed.

The only problem is that the management of the pyproject file stick to the uv creating its own .venv directory. And this to me is something that could be improved.

zanieb commented 1 month ago

Hi! Did you see the UV_PROJECT_ENVIRONMENT setting?

WSF-SEO-AM commented 1 month ago

Nope. I'm currently discovering the bits and bobs. Can you suggest how this is used? Is it a one off when the venv is invoked for the first time? Or, like the TLS setting one, it has to be specified all the times?

zanieb commented 1 month ago

It has to be specified at all times. In your case, I'd set it up so it automatically changes per directory, e.g., with direnv or as a variable in the pyenv environment?

WSF-SEO-AM commented 1 month ago

So that I understand ... all the times I invoke a source venv activate? Do I need to specify it there all the times? Is any place where I can hardcode the path on a per project basis?

WSF-SEO-AM commented 1 week ago

@zanieb sorry to chase. Can u please help me here providing more guidance on how to setup uv with a conf file if necessary that specify a variable it can read without the need to make very much complicate command lines?