Skip to content

Commit e1185ef

Browse files
lhoupertclaude
andauthored
fix: use hatch's default env so the uv installer is inherited (#4023)
* fix: use hatch's `default` env so the uv installer is inherited `[tool.hatch.envs.defaults]` (plural) is a standalone environment that nothing inherits from — hatch's base environment is `default` (singular). As written, `installer = "uv"` never applied to `test`, `docs`, etc., so those envs fell back to the `virtualenv` backend. This breaks contributors whose Python is uv-managed: hatch hands the `~/.local/bin/pythonX.Y` symlink to virtualenv, which mis-relocates the python-build-standalone interpreter (`sys.base_prefix = '/install'`, `ModuleNotFoundError: No module named 'encodings'`). Creating the env with `uv venv` relocates it correctly. Renaming to `default` makes the intended uv installer apply to all envs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * ci: install uv in hatch-based workflows so the uv installer works Activating `installer = "uv"` (via the `default` env fix) means hatch now needs a uv binary to create/sync the test, gputest and hypothesis envs. These workflows install hatch via the `pypa/hatch` action (a pyapp build with its own bundled Python) but never set up uv, so hatch fell back to provisioning uv through its pyapp runtime — whose `pip` has a `python3.12` shebang that doesn't exist on non-3.12 runners: .../pyapp/hatch/.../python/bin/python3.12: No such file or directory Process completed with exit code 126 Add the repo's standard `astral-sh/setup-uv` step (already used by docs/lint workflows) before "Install Hatch" so hatch finds uv on PATH and uses it directly. With uv available, `uv venv --python <matrix>` selects the correct interpreter, so the root `.python-version` (3.12, for the dev env) no longer interferes with the 3.13/3.14 matrix envs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * ci: point hatch at the setup-uv binary to skip its broken uv bootstrap Installing uv on PATH is not enough: hatch only skips provisioning its internal `hatch-uv` env when an explicit uv path is set. Otherwise it bootstraps uv via its bundled pyapp `pip` (shebang `python3.12`), which fails on non-3.12 runners with exit code 126. Set `HATCH_ENV_TYPE_VIRTUAL_UV_PATH=uv` so hatch uses the uv provided by astral-sh/setup-uv directly instead of bootstrapping. Verified locally: with the explicit path set, `hatch env create` succeeds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * ci(test): install hatch via pip instead of the pyapp action The macOS jobs failed even with uv on PATH: hatch's pyapp (standalone) build on macOS has a `pip` whose shebang points at a non-existent `python3.12`, and activating the uv installer makes hatch invoke it (`exit code 126`). Linux pyapp builds are unaffected, which is why the GPU and Hypothesis (Linux) workflows pass. Install hatch with `python -m pip install hatch==1.16.5` (the method the contributing docs already document) so hatch runs on the runner's normal Python with a working pip on every OS. uv (from setup-uv) is still used as the env installer. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 6ce787d commit e1185ef

4 files changed

Lines changed: 26 additions & 13 deletions

File tree

.github/workflows/gpu_test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ on:
1212

1313
env:
1414
LD_LIBRARY_PATH: /usr/local/cuda/extras/CUPTI/lib64:/usr/local/cuda/lib64
15+
# Use the uv from astral-sh/setup-uv instead of hatch's bundled (pyapp) uv.
16+
HATCH_ENV_TYPE_VIRTUAL_UV_PATH: uv
1517

1618
permissions:
1719
contents: read
@@ -59,6 +61,8 @@ jobs:
5961
with:
6062
python-version: ${{ matrix.python-version }}
6163
cache: 'pip'
64+
- name: Install uv
65+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
6266
- name: Install Hatch
6367
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc
6468
with:

.github/workflows/hypothesis.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ concurrency:
1818

1919
env:
2020
FORCE_COLOR: 3
21+
# Use the uv from astral-sh/setup-uv instead of hatch's bundled (pyapp) uv.
22+
HATCH_ENV_TYPE_VIRTUAL_UV_PATH: uv
2123

2224
jobs:
2325

@@ -54,6 +56,8 @@ jobs:
5456
with:
5557
python-version: ${{ matrix.python-version }}
5658
cache: 'pip'
59+
- name: Install uv
60+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
5761
- name: Install Hatch
5862
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc
5963
with:

.github/workflows/test.yml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ on:
1313
permissions:
1414
contents: read
1515

16+
env:
17+
# Use the uv from astral-sh/setup-uv; without an explicit path hatch
18+
# bootstraps its own (pyapp) uv, which fails on non-3.12 runners.
19+
HATCH_ENV_TYPE_VIRTUAL_UV_PATH: uv
20+
1621
concurrency:
1722
group: ${{ github.workflow }}-${{ github.ref }}
1823
cancel-in-progress: true
@@ -60,10 +65,10 @@ jobs:
6065
with:
6166
python-version: ${{ matrix.python-version }}
6267
cache: 'pip'
68+
- name: Install uv
69+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
6370
- name: Install Hatch
64-
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc
65-
with:
66-
version: '1.16.5'
71+
run: python -m pip install hatch==1.16.5
6772
- name: Set Up Hatch Env
6873
env:
6974
HATCH_ENV: test.py${{ matrix.python-version }}-${{ matrix.dependency-set }}
@@ -109,10 +114,10 @@ jobs:
109114
with:
110115
python-version: ${{ matrix.python-version }}
111116
cache: 'pip'
117+
- name: Install uv
118+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
112119
- name: Install Hatch
113-
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc
114-
with:
115-
version: '1.16.5'
120+
run: python -m pip install hatch==1.16.5
116121
- name: Set Up Hatch Env
117122
env:
118123
HATCH_ENV: ${{ matrix.dependency-set }}
@@ -144,10 +149,10 @@ jobs:
144149
with:
145150
python-version: '3.13'
146151
cache: 'pip'
152+
- name: Install uv
153+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
147154
- name: Install Hatch
148-
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc
149-
with:
150-
version: '1.16.5'
155+
run: python -m pip install hatch==1.16.5
151156
- name: Set Up Hatch Env
152157
run: |
153158
hatch run doctest:pip list
@@ -168,10 +173,10 @@ jobs:
168173
with:
169174
python-version: '3.13'
170175
cache: 'pip'
176+
- name: Install uv
177+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
171178
- name: Install Hatch
172-
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc
173-
with:
174-
version: '1.16.5'
179+
run: python -m pip install hatch==1.16.5
175180
- name: Run Benchmarks
176181
run: |
177182
hatch env run --env "test.py3.13-minimal" run-benchmark

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ extra-dependencies = [
257257
'obstore==0.5.*',
258258
]
259259

260-
[tool.hatch.envs.defaults]
260+
[tool.hatch.envs.default]
261261
installer = "uv"
262262

263263
[tool.hatch.envs.docs]

0 commit comments

Comments
 (0)