Open kozlek opened 2 months ago
I have exactly the same problem and I think this would be a big leap in adoption if the author vouches for it. Hope for the best from the developers! 🤞🏼
+1 for this!
I have a temporary solution for anyone that has this issue. I made a fork from the zsh-autoswitch-virtualenv repo and made it work with uv venv so that it automatically switches environments once you get into a working directory containing uv virtual environment: https://github.com/dannysteenman/zsh-autoswitch-virtualenv
Just load this script in your .zshrc and you're good to go!
Another +1 from me.
So far this has been my main headache with my transition to uv
since my project uses pyenv
quite extensively and it will take time to transition out of it.
My solution has been using direnv and using this layout in the project .envrc
layout_uv_pyenv() {
if [ -e ".python-version" ]; then
VENV=`cat .python-version`
VENV_PATH="$PYENV_ROOT/versions/$VENV"
export UV_PYTHON=$VENV_PATH/bin/python
export UV_PROJECT_ENVIRONMENT=$VENV_PATH
export UV_ACTIVE=1
fi
}
which works reasonably well, but it would be nice if uv
could just default (or be configured) to using the environment loaded in $VIRTUAL_ENV
.
Hello,
As a python developer, I'm currently using:
pyenv
to install specific python versionpyenv-virtualenv
(officialpyenv
plugin) to manage my virtualenvs, including auto-activationpoetry
for managing dependencies for bigger projects (mainly using groups)pip-tools
for managing dependencies for smaller projectspipx
for installing CLI toolsI'm very excited about
uv
and I started to integrate it into my workflow. Bothpoetry
andpip-tools
can be replaced quite easily asuv
supports most of my needs.pipx
is replaced byuv tool
.Now enter python version + virtualenvs management.
uv
can do a lot, but currently it lacks virtualenv auto-activation and virtualenv delocalisation. It's been discussed #1495, and I totally understand you cannot implement every behaviours a few months after the first release ! 😉However, I should be able to keep my existing python + virtualenv setup with
pyenv
+pyenv-virtualenv
(which works well), while enjoying the speed ofuv
for dependencies management, aspyenv-virtualenv
set aVIRTUAL_ENV
variable properly. In reality, it's not working due touv
expectation from.python-version
.pyenv-virtualenv
set the name of the virtualenv in.python-version
, whileuv
seems to expect a python version.To allow a progressive adoption of
uv
, it would great to be able to continue usingpyenv-virtualenv
auto-activation feature.Full workflow to reproduce the bug
pyenv
,pyenv-virtualenv
anduv
are expected to be properly setup according their official documentation.Again, my point is not about implementing a new behaviour in
uv
(yet), but instead to allow it to co-exist with existing tools likepyenv-virtualenv
, which offer interesting features thatuv
lacks for the moment 🙂I'll be happy to help if I can !