Skip to content

Commit c77de97

Browse files
committed
Scope PYTHON_GIL=0 off the PyPI publish job.
Keep free-threaded GIL=0 on gate/build only, never workflow-wide or on pypa/gh-action-pypi-publish, matching the shared Trusted Publishing rule.
1 parent 02ad683 commit c77de97

3 files changed

Lines changed: 37 additions & 9 deletions

File tree

.github/workflows/python-publish.yml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
# This workflow will upload a Python Package to PyPI when a release is created
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3-
4-
# This workflow uses actions that are not certified by GitHub.
5-
# They are provided by a third-party and are governed by
6-
# separate terms of service, privacy policy, and support
7-
# documentation.
1+
# Upload to PyPI when a GitHub release is published.
2+
#
3+
# Authentication: PyPI Trusted Publishing (OIDC). No API token in this repo.
4+
#
5+
# Free-threaded rule (shared across chirp / kida / furatena / pounce / milo-cli):
6+
# - Set PYTHON_GIL=0 only on jobs that run this repo's 3.14t code
7+
# (release-gate / release-build).
8+
# - Never set PYTHON_GIL at workflow scope, and never on pypi-publish —
9+
# pypa/gh-action-pypi-publish uses a non-free-threaded interpreter and
10+
# aborts if PYTHON_GIL=0 is inherited.
11+
#
12+
# Trusted Publishing registration:
13+
# PyPI project name: kida-templates
14+
# Owner: lbliii
15+
# Repository: kida
16+
# Workflow name: python-publish.yml
17+
# Environment name: pypi
818

919
name: Upload Python Package
1020

@@ -18,6 +28,8 @@ permissions:
1828
jobs:
1929
release-gate:
2030
runs-on: ubuntu-latest
31+
env:
32+
PYTHON_GIL: "0"
2133
steps:
2234
- uses: actions/checkout@v7
2335

@@ -40,7 +52,6 @@ jobs:
4052
env:
4153
CI: true
4254
BENCHMARK_SUITE: core
43-
PYTHON_GIL: "0"
4455
run: |
4556
uv run pytest -n 0 -q --tb=short \
4657
tests/test_kida_expressions.py \
@@ -52,7 +63,8 @@ jobs:
5263
runs-on: ubuntu-latest
5364
needs:
5465
- release-gate
55-
66+
env:
67+
PYTHON_GIL: "0"
5668
steps:
5769
- uses: actions/checkout@v7
5870

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PyPI Trusted Publishing keeps ``PYTHON_GIL=0`` on free-threaded gate/build
2+
jobs only, never on the ``pypa/gh-action-pypi-publish`` upload job.

tests/templates/test_github_report_contracts.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,20 @@ def test_release_workflow_keeps_exact_free_threaded_python_setup():
175175
assert "allow-prereleases: true" in setup_python_step
176176

177177

178+
def test_pypi_publish_does_not_inherit_python_gil():
179+
"""pypa upload container is not free-threaded; GIL=0 belongs on our jobs only."""
180+
workflow = (WORKFLOWS_DIR / "python-publish.yml").read_text(encoding="utf-8")
181+
182+
assert "\nenv:\n PYTHON_GIL:" not in workflow
183+
assert "Never set PYTHON_GIL at workflow scope" in workflow
184+
gate_env = workflow.split("release-gate:", 1)[1].split("steps:", 1)[0]
185+
build_env = workflow.split("release-build:", 1)[1].split("steps:", 1)[0]
186+
publish_job = workflow.split("pypi-publish:", 1)[1]
187+
assert 'PYTHON_GIL: "0"' in gate_env
188+
assert 'PYTHON_GIL: "0"' in build_env
189+
assert "PYTHON_GIL" not in publish_job
190+
191+
178192
def test_local_ruff_targets_use_the_same_repository_scope_as_ci():
179193
"""Local lint, fix, format, and format-check targets cover the whole repo."""
180194
makefile = (ROOT_DIR / "Makefile").read_text(encoding="utf-8")

0 commit comments

Comments
 (0)