Skip to content
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 sync fails to find matching python version with pyenv #4958

Closed
konstin opened this issue Jul 10, 2024 · 4 comments
Closed

uv sync fails to find matching python version with pyenv #4958

konstin opened this issue Jul 10, 2024 · 4 comments
Labels
bug Something isn't working preview Experimental behavior

Comments

@konstin
Copy link
Member

konstin commented Jul 10, 2024

When using uv sync, uv fails to find a python interpreter even if it exists if the default python/python3 are incompatible. This happens e.g. with pyenv.

For example with both requires-python = "==3.10.*" requires-python = ">=3.10", where the default python/python3 are any other version, say 3.9:

This fails:

uv sync --python-preference only-system

This passes:

uv sync --python-preference only-system -p 3.10

uv should find the python 3.10 interpreter in either case.

Reproduction

FROM ubuntu
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update
RUN apt install -yy build-essential libssl-dev zlib1g-dev \
    libbz2-dev libreadline-dev libsqlite3-dev curl git \
    libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
RUN curl https://pyenv.run | bash
ENV PATH="/root/.pyenv/bin:$PATH"
RUN CONFIGURE_OPTS="--enable-optimizations" pyenv install 3.8.12 3.8.18
RUN CONFIGURE_OPTS="--enable-optimizations" pyenv install 3.9.18
RUN CONFIGURE_OPTS="--enable-optimizations" pyenv install 3.10.13
RUN CONFIGURE_OPTS="--enable-optimizations" pyenv install 3.11.7
RUN CONFIGURE_OPTS="--enable-optimizations" pyenv install 3.12.1
RUN pyenv global 3.8.12 3.8.18 3.9.18 3.10.13 3.11.7 3.12.1
# https://github.com/pyenv/pyenv#set-up-your-shell-environment-for-pyenv
RUN echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc \
    && echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc \
    && echo 'eval "$(pyenv init -)"' >> ~/.bashrc

Create a dummy pyproject.toml, any requires-python that mismatches the default active python will do:

[project]
name = "a"
version = "0.1.0"
requires-python = "==3.10.*"
dependencies = ["tqdm"]

Compile uv:

cargo build --release --target x86_64-unknown-linux-musl

Start the docker container, mount the uv dir to /io and run commands with

/io/target/x86_64-unknown-linux-musl/release/uv sync
@konstin konstin added bug Something isn't working preview Experimental behavior labels Jul 10, 2024
@konstin konstin changed the title uv sync fails to find matching python version uv sync fails to find matching python version with pyenv Jul 10, 2024
@zanieb
Copy link
Member

zanieb commented Jul 10, 2024

This seems like a duplicate of #4709 right...?

@konstin
Copy link
Member Author

konstin commented Jul 10, 2024

Ported it over

@mhechthz
Copy link

is there anything new on this, because is is a major show stopper for using uv in my opinion. even on modifying lock and toml uv sticks with default system version of python. furthermore, a just initialized venv with the right python is removed and replaced by the wrong python.

@charliermarsh
Copy link
Member

Please open a new issue describing your problem — it’s not clear from the above what you’re running into.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working preview Experimental behavior
Projects
None yet
Development

No branches or pull requests

4 participants