You are not logged in.

#1 2025-07-10 00:27:16

Succulent of your garden
Member
Registered: 2024-02-29
Posts: 353

[SOLVED] python uv tool question

Hi !

So today i was starting to create a virt env for python so I started to use uv to install maturin, which is a tool to integrate rust into python. I do it by this command:

 uv tool install maturin 

By surprise this tool is installed like a binary  in the ~/.local/bin and not in the folder of the project  that I'm working on. So i have two questions about this:

Is this correct ? I mean does the binary of maturin in ~/.local/bin is isolated from the rest of the system ? Could it be a potential conflict with pacman while i'm updating my system or something else ?

Why uv installs the tools in ~/.local/bin ? I mean, does this break the isolation principle that a virt env is trying to do ? Is pretty strange TBH, but I imagine there is a good argument of why is the default behavior,  which the opposite of pip for example, that just add the packages and everything inside the project folder, in which is the virtual environment placed.

btw I know that uv add is for packages smile

Last edited by Succulent of your garden (2025-07-14 22:03:18)

Offline

#2 2025-07-10 09:26:17

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 13,962

Re: [SOLVED] python uv tool question

https://docs.astral.sh/uv/guides/tools/ wrote:

When a tool is installed, its executables are placed in a bin directory in the PATH which allows the tool to be run without uv. If it's not on the PATH, a warning will be displayed and uv tool update-shell can be used to add it to the PATH.

Depending on where ~/.local/bin is present in $PATH it can cause issues.
Using uvx foo or uv tool run foo may be a better option.

Last edited by Lone_Wolf (2025-07-10 09:27:19)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Online

#3 2025-07-10 11:44:43

bulletmark
Member
From: Brisbane, Australia
Registered: 2013-10-22
Posts: 700

Re: [SOLVED] python uv tool question

`uv` is a utility which does a lot of different things. The `uv tool` command is a means of installing python based programs into your local path (complete with their own isolated venv containing their required dependencies). It is exactly equivalent to the legacy `pipx` tool. If you are working on or creating a project and want to create a venv plus install packages into that venv you would use the `uv venv` + `uv pip install` commands which are equivalent to legacy `python -m venv` + `pip install` commands. So `uv tool` is not something a user would use for installing anything in or for a project.

Last edited by bulletmark (2025-07-10 11:47:16)

Offline

#4 2025-07-10 13:24:11

Succulent of your garden
Member
Registered: 2024-02-29
Posts: 353

Re: [SOLVED] python uv tool question

Lone_Wolf wrote:

Depending on where ~/.local/bin is present in $PATH it can cause issues.
Using uvx foo or uv tool run foo may be a better option.

I used uv tool update-shell which is the suggestion from the same tool when I had the $PATH conflict, that works in my case.

bulletmark wrote:

`uv` is a utility which does a lot of different things. The `uv tool` command is a means of installing python based programs into your local path (complete with their own isolated venv containing their required dependencies). It is exactly equivalent to the legacy `pipx` tool. If you are working on or creating a project and want to create a venv plus install packages into that venv you would use the `uv venv` + `uv pip install` commands which are equivalent to legacy `python -m venv` + `pip install` commands. So `uv tool` is not something a user would use for installing anything in or for a project.

I installed maturin as the documentation suggest https://docs.rs/crate/maturin/latest . Maturin is a tool to make the integration of Rust code into python, which I'm trying to do. Not sure if I use "uv pip install maturin" would work well to be honest, I'll make the try someday, but I'm not sure about this is good, since the binary it's outside of the virtual environment. Sure probably I can use the "uv pip install maturin" to get binary inside my virtual environment and omit  his commit using .gitignore, but not sure if the binary itself it's gonna work well .

Not less I have doubt if this binary could affect pacman, probably not but not 100% sure to be honest. Also another issue that I'm having is that cargo doesn't get updated by pacman -Syu, only by paru -Sua, which seems strange, since I installed Rust by the arch official repos packages. Nevertheless I'm currently reading the Rust arch wiki to understand better how all works smile

Offline

#5 2025-07-10 23:47:09

bulletmark
Member
From: Brisbane, Australia
Registered: 2013-10-22
Posts: 700

Re: [SOLVED] python uv tool question

'maturin` is just a command line tool you are installing to use. It is independent of any particular venv. Those instructions at https://docs.rs/crate/maturin/latest could be improved. It should probably first state to install `maturin` from your standard packages if available, i.e. on Arch you are best to just `sudo pacman -S maturin`. The note about using `pip` instead of `pipx` is frankly out of date as global installs using `pip` is frowned upon nowadays, particularly on Arch.

Offline

#6 2025-07-14 22:02:39

Succulent of your garden
Member
Registered: 2024-02-29
Posts: 353

Re: [SOLVED] python uv tool question

Thanks for the info bulletmark. I get it, but also tried to install maturin in the virt env and also works. But as you said, it seems just like another cli tool. Nevertheless thanks for your comments on the topic smile

Offline

Board footer

Powered by FluxBB