Expose a Python "identity" output (#1036)

https://github.com/pyca/cryptography/pull/15572#discussion_r3913508686
has the context for this: TL;DR our current `python-version` output
mirrors the "request" version exactly, which means that it's
insufficient for any downstream that needs to manage its own cache keys
(since caches shouldn't be shared across release candidates, but the `uv
python` request version doesn't include RC numbers).

The first commit here was my attempt to fix this by exposing the runtime
Python version, but this too is imprecise: the runtime version doesn't
indicate the interpreter variant (e.g. freethreading), which is also
important to capture in the cache identity.

My solution here is to expose `python-runtime-id`, which is just the
`key` of the active Python version from `uv python list
--output-format=json`.

---------

Signed-off-by: William Woodruff <william@yossarian.net>
This commit is contained in:
William Woodruff
2026-09-09 12:45:52 -04:00
committed by GitHub
parent a6772c8f0a
commit f634bf473a
9 changed files with 205 additions and 8 deletions
+14
View File
@@ -347,9 +347,14 @@ jobs:
if [ "$PYTHON_VERSION" != "3.13.1t" ]; then
exit 1
fi
if [ -n "$PYTHON_RUNTIME_ID" ]; then
echo "python-runtime-id should be empty without environment activation"
exit 1
fi
shell: bash
env:
PYTHON_VERSION: ${{ steps.setup-uv.outputs.python-version }}
PYTHON_RUNTIME_ID: ${{ steps.setup-uv.outputs.python-runtime-id }}
- run: uv sync
working-directory: __tests__/fixtures/uv-project
@@ -439,6 +444,15 @@ jobs:
raise SystemExit(f"Python is not running from custom venv: {sys.executable}")
PY
shell: bash
- name: Verify Python runtime ID from custom venv
run: |
case "$PYTHON_RUNTIME_ID" in
cpython-3.13.1+freethreaded-*) ;;
*) echo "Wrong Python runtime ID: $PYTHON_RUNTIME_ID"; exit 1 ;;
esac
shell: bash
env:
PYTHON_RUNTIME_ID: ${{ steps.setup-uv.outputs.python-runtime-id }}
test-activate-environment-no-project:
runs-on: ubuntu-latest