Skip to content

Commit 397d19d

Browse files
committed
fix: use wheelhouse for pip + setup-python for pre-commit symlinks
Three issues fixed: 1. Pre-commit venv broken symlink: warmer used uv python install (path differs from consumer's setup-python). Fix: use setup-python 3.10 for default env, uv python install only for 3.11-3.13 test matrix (their symlinks don't matter — only wheels are cached). 2. pip has no offline mode: PIP_NO_INDEX blocks all index access including build deps like setuptools. Fix: warmer creates a pip wheelhouse (~/.cache/pip-wheelhouse), consumer sets PIP_FIND_LINKS to use it. 3. Test matrix needs version-specific wheels: restored uv python install 3.11-3.13 and test env creation for all versions.
1 parent 8f3b0ac commit 397d19d

2 files changed

Lines changed: 24 additions & 16 deletions

File tree

.github/actions/setup-python-deps/action.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ runs:
1818
path: |
1919
~/.cache/uv
2020
~/.cache/pip
21+
~/.cache/pip-wheelhouse
2122
key: python-deps-${{ hashFiles('uv.lock', 'pyproject.toml') }}-latest
2223
restore-keys: python-deps-${{ hashFiles('uv.lock', 'pyproject.toml') }}-
2324

@@ -33,11 +34,6 @@ runs:
3334
shell: bash
3435
run: |
3536
echo "UV_OFFLINE=true" >> "$GITHUB_ENV"
36-
# uv cache is index-URL-scoped. The warmer downloads via JFrog, so
37-
# cache entries are keyed by JFrog's URL hash. Set the same URL here
38-
# (without credentials — offline mode never contacts it, only uses
39-
# the hash to find the right cache bucket).
4037
echo "UV_INDEX_URL=https://databricks.jfrog.io/artifactory/api/pypi/db-pypi/simple" >> "$GITHUB_ENV"
4138
echo "PIP_NO_INDEX=1" >> "$GITHUB_ENV"
42-
mkdir -p ~/.config/pip
43-
printf '[global]\nno-index = true\n' > ~/.config/pip/pip.conf
39+
echo "PIP_FIND_LINKS=$HOME/.cache/pip-wheelhouse" >> "$GITHUB_ENV"

.github/workflows/warmDepsCache.yml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ jobs:
6262
6363
echo "Warming cache for PR #${{ inputs.pr_number }} from ${FORK_REPO}@${FORK_REF}"
6464
65-
# Fetch only lockfiles from the fork — .github/actions/ always
66-
# comes from main to prevent code injection from forks.
6765
git remote add fork "https://github.com/${FORK_REPO}.git"
6866
git fetch --depth=1 fork "${FORK_REF}"
6967
git checkout FETCH_HEAD -- uv.lock pyproject.toml .pre-commit-config.yaml
@@ -84,30 +82,43 @@ jobs:
8482
- name: Install Hatch
8583
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc # install
8684

85+
- name: Install Python versions for test matrix
86+
run: uv python install 3.11 3.12 3.13
87+
8788
- name: Create hatch environments (populates uv cache)
8889
run: |
8990
set -euo pipefail
9091
hatch env create default
92+
hatch env create test.py3.10
93+
hatch env create test.py3.11
94+
hatch env create test.py3.12
95+
hatch env create test.py3.13
9196
hatch env create verify
9297
9398
- name: Warm pre-commit cache
9499
run: hatch run pre-commit install-hooks
95100

96-
- name: Build and warm pip cache for verify environment
101+
- name: Create pip wheelhouse
97102
run: |
98103
set -euo pipefail
99-
hatch -v build
100-
# Run verify to populate ~/.cache/pip/ with runtime transitive deps.
101-
# Allow failure — we only care about populating the cache.
102-
hatch run verify:check-all || true
104+
mkdir -p ~/.cache/pip-wheelhouse
105+
hatch run pip download --dest ~/.cache/pip-wheelhouse \
106+
setuptools wheel twine check-wheel-contents
107+
hatch run pip download --dest ~/.cache/pip-wheelhouse \
108+
$(hatch run python -c "
109+
import tomllib
110+
with open('pyproject.toml', 'rb') as f:
111+
data = tomllib.load(f)
112+
print(' '.join(data['project']['dependencies']))
113+
")
114+
115+
- name: Build package
116+
run: hatch -v build
103117

104118
- name: Generate cache key
105119
id: cache-key
106120
shell: bash
107121
run: |
108-
# Hash first so consumers can prefix-match on the hash alone.
109-
# Timestamp suffix ensures each run creates a new immutable entry;
110-
# consumers pick the latest timestamp for a given hash.
111122
TIMESTAMP=$(date -u +%Y%m%d%H%M%S)
112123
LOCK_HASH="${{ hashFiles('uv.lock', 'pyproject.toml') }}"
113124
echo "python-deps-key=python-deps-${LOCK_HASH}-${TIMESTAMP}" >> "$GITHUB_OUTPUT"
@@ -121,6 +132,7 @@ jobs:
121132
path: |
122133
~/.cache/uv
123134
~/.cache/pip
135+
~/.cache/pip-wheelhouse
124136
key: ${{ steps.cache-key.outputs.python-deps-key }}
125137

126138
- name: Save pre-commit cache

0 commit comments

Comments
 (0)