-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uv conflicts with pyenv-virtualenv auto-activation #6204
Comments
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 My solution has been using direnv and using this layout in the project 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 |
In case it helps anyone, I've got this in my function virtual_env_activate() {
# check the current folder belong to earlier VIRTUAL_ENV folder, potentially deactivate.
if [[ -n "$VIRTUAL_ENV" ]]; then
parentdir="$(dirname "$VIRTUAL_ENV")"
if [[ "$PWD"/ != "$parentdir"/* ]]; then
deactivate
fi
fi
# if .python-version is found, create/show .venv
if [ -f .python-version ] && [ ! -d ./.venv ]; then
uv venv
fi
# if .venv is found and not activated, activate it
if [[ -z "$VIRTUAL_ENV" ]]; then
# if .venv folder is found then activate the vitualenv
if [ -d ./.venv ] && [ -f ./.venv/bin/activate ]; then
source ./.venv/bin/activate
fi
fi
}
function cd() {
builtin cd "$@" || return
virtual_env_activate
# node_version_manager # TODO: with pkgx, maybe nvm is no longer needed?
}
cd . # trigger cd overrides when shell starts
function z() {
__zoxide_z "$@" && cd . || return
}
function zi() {
__zoxide_zi "$@" && cd . || return
} Full source: https://github.com/fredrikaverpil/dotfiles/blob/main/shell/sourcing.sh |
+1 here too. I'm too in the process of assessing if I'll switch from pyenv (which I'm 100% satisfied with) to uv and have to manage the coexistence with projects using pyenv and that won't be modified. uv using the same .python-version file as pyenv is not a good choice because this raises the probabilities of conflicts. This doesn't help in favoring uv because the resulting hiccups tend to be annoying and prevent from using the tool in the best possible conditions. |
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.Both
poetry
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 to
uv
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 !
The text was updated successfully, but these errors were encountered: