pypa / hatch

Modern, extensible Python project management
https://hatch.pypa.io/latest/
MIT License
5.96k stars 303 forks source link

Installing `hatch` masks my globally installed `uv` #1520

Open dhirschfeld opened 4 months ago

dhirschfeld commented 4 months ago

I use the uv package manager and have it globally installed as a default tool, available anywhere.

When I install hatch, my globally installed uv is masked by the version required by hatch.

It's not a big problem as hatch isn't constraining uv, but it's worth considering if there's a way to not mask a globally installed version.

ofek commented 4 months ago

Did you install using the binary?

dhirschfeld commented 4 months ago

Did you install using the binary?

Hatch or uv? Both are installed with mamba.

ofek commented 4 months ago

Have you tried this? https://hatch.pypa.io/latest/how-to/environment/select-installer/#externally-managed

dhirschfeld commented 4 months ago

I didn't know about that. Will give that a go, thanks!

ofek commented 4 months ago

Does that suffice?

dhirschfeld commented 4 months ago

Testing timeframes are likely measured in weeks - it's not causing any actual problems at present so isn't a super high priority...

polarathene commented 3 months ago

When I install hatch, my globally installed uv is masked by the version required by hatch.

Is that within a hatch environment specifically? Or on the host? If it is on the host, it's probably due to mamba in your PATH environment having higher precedence than your system uv binary?

Otherwise, in a hatch shell you probably can access uv from hatch, but not the hatch command itself (documented here in collapsed section):

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

$ cd /tmp && hatch shell --name 3.11
$ python --version
Python 3.12.3

# Fails due to modified PATH:
$ hatch --version
bash: /root/.local/share/pyapp/hatch/1303662642487178586/1.11.0/python/bin/hatch: cannot execute: required file not found
$ /usr/local/bin/hatch --version
Hatch, version 1.11.0
# UV is available however:
$ uv --version
uv 0.1.44

# hatch environment and hatch install location are given precedence for resolving binaries:
$ echo $PATH
/root/.local/share/hatch/env/virtual/opt/y8366zdl/opt/bin:/root/.local/share/pyapp/hatch/1303662642487178586/1.11.0/python/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

That happens with the curl install (PyApp), but not with pipx install. Presumably mamba would be similar for you.


HATCH_ENV_TYPE_VIRTUAL_UV_PATH IIRC only changes what uv binary hatch will use implicitly. If your issue is not that, but with explicit use of the uv command yourself, this ENV does not help AFAIK. The linked docs might not make that distinction clear though.