Skip to content

How to have a full python environment? #12852

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

Open
youkaichao opened this issue Apr 13, 2025 · 10 comments
Open

How to have a full python environment? #12852

youkaichao opened this issue Apr 13, 2025 · 10 comments
Labels
question Asking for clarification or support

Comments

@youkaichao
Copy link

Question

I'm installing a new environment with uv venv ~/uv_envs/test --python 3.12 , it uses my system's python as the interpreter.

However, i find that my system intepreter is not complete, it does not have /usr/include/python3.12 , but python -c "from sysconfig import get_paths; print(get_paths()['include'])" still reports that directory.

Can I somehow tell uv to download a full python environment?

I can use sudo apt install python3.12-dev as a workaround, but then the environment is not reproducible, i.e. it depends on the initial python interpreter i installed.

can i make uv take the full control, downloading a full python regardless of my initial python environment?

Platform

Ubuntu 20.04, arm64

Version

uv 0.5.11

@youkaichao youkaichao added the question Asking for clarification or support label Apr 13, 2025
@pjrulez
Copy link

pjrulez commented Apr 13, 2025

EDIT & TLDR:
'uv self update' and then I could install the latest python 3.12 version.

I can't download python 3.12.10 with uv:
uv python install 3.12.10
error: No download found for request: cpython-3.12.10-linux-aarch64-gnu

Additionally, I'm using this image:
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
but it was updated from 3.12.9 which worked with my project to 3.12.10 which now doesn't work during the build process because the image now comes with 3.12.10.

For a moment I thought this was relevant. Now, I'm not so sure.

@astral-sh astral-sh deleted a comment from hypervanse Apr 13, 2025
@charliermarsh
Copy link
Member

@youkaichao -- You can try passing --python-preference only-managed -- that will force uv to use a uv-downloaded Python.

@j178
Copy link
Contributor

j178 commented Apr 14, 2025

--python-preference is now hidden from user, the new convenient equivalent is the --managed-python flag.

@youkaichao
Copy link
Author

@charliermarsh thanks, I'm using uv venv uv_envs/test_0414 --python 3.12 --managed-python --seed now, is --managed-python similar to --python-preference only-managed ?

@youkaichao
Copy link
Author

well, it seems it still links to ~/.local/share/uv/python .

The context here, is I'm in a cluster, which has a shared file system at /sharefs , and I want to put uv there, without storing anything locally to that node.

Somehow uv links ~/.local/share/uv/python to /sharefs/uv_envs/test_0414 , and this link is broken on another node.

@charliermarsh
Copy link
Member

Yeah, virtual environments on Linux and macOS will always link to a Python by default (unlike on Windows). The standard library python -m venv supports a --copies flag which lets you copy the distribution, I think? See #2103.

@youkaichao
Copy link
Author

is it possible to have a fresh new, standalone environment, without any linking?

@youkaichao
Copy link
Author

I try to add --link-mode copy to uv venv , but the include path is still not copied into this new environment.

ultimately, what i want is sysconfig.get_paths()["include"] should only contain the files in the uv env, so that i can place the full environment in the shared filesystem, and all nodes in the cluster can use it.

@youkaichao
Copy link
Author

youkaichao commented Apr 14, 2025

after fighting for a while, i end up with this:

export ROOT_DIR=/sharedfs/somewhere
export UV_HOME=$ROOT_DIR/uv_home
export UV_INSTALL_DIR="$ROOT_DIR/uv"
export UV_CACHE_DIR="$ROOT_DIR/uv_cache"
export XDG_DATA_HOME=$ROOT_DIR
export PATH="$PATH:$UV_INSTALL_DIR"
curl -LsSf https://astral.sh/uv/install.sh | sh

uv venv $ROOT_DIR/uv_envs/test_0416 --python 3.12 --managed-python --link-mode copy --seed

and then it seems all files are in the /sharedfs now.

@liquidcarbon
Copy link

As an alternative, for the last year I've been using Pixi for base python install, and wrapping uv in pixi run uv.
This way I know exactly which python is being used, despite ongoing changes in uv.

Here's a pet project that wraps this: https://github.com/liquidcarbon/puppy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for clarification or support
Projects
None yet
Development

No branches or pull requests

5 participants