Skip to content

Commit 2a570f2

Browse files
authored
Merge branch 'main' into test/core-coverage-20261026
2 parents d47ef9f + 3cc4edb commit 2a570f2

43 files changed

Lines changed: 2272 additions & 1936 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/actions/harden-pip/action.yml‎

Lines changed: 0 additions & 28 deletions
This file was deleted.

‎.github/actions/lychee-links/action.yml‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ outputs:
2626
description: "Whether the current PR label explicitly enables the HTTP 429 override"
2727
value: ${{ steps.lychee-policy.outputs.allow-429 }}
2828

29-
# Callers provide Python and the checked-out repository; the build of any
30-
# rendered documentation must already be complete.
29+
# Callers provide Python through setup-hardened-python and the checked-out
30+
# repository; the build of any rendered documentation must already be complete.
3131
runs:
3232
using: composite
3333
steps:
@@ -113,9 +113,6 @@ runs:
113113
printf '[Open the cache refresh workflow](%s).\n' "$WORKFLOW_URL"
114114
} >> "$GITHUB_STEP_SUMMARY"
115115
116-
- name: Harden pip
117-
uses: ./.github/actions/harden-pip
118-
119116
- name: Check links through the configured pre-commit hook
120117
shell: bash --noprofile --norc -euo pipefail {0}
121118
env:
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
name: Set up hardened Python
6+
description: >-
7+
Install CPython with a pinned uv, create a venv from it, and put the venv
8+
first on PATH. setup-uv verifies the uv binary and uv verifies the
9+
python-build-standalone archive against embedded checksums, so the
10+
interpreter's integrity does not depend on TLS. The job then fails unless
11+
the interpreter's ssl module rejects the compromised eMudhra/emSign CA keys
12+
(CVE-2026-115557; first fixed releases: 3.11.18, 3.12.16, 3.13.18, 3.14.10,
13+
3.15.2), and pip is updated through that ssl module. Unlike setup-python,
14+
this provides patched Windows builds of maintenance series, for which
15+
python.org publishes no installers. See
16+
https://github.com/NVIDIA/cuda-python/issues/3195 and
17+
https://discuss.python.org/t/109678.
18+
19+
inputs:
20+
python-version:
21+
description: >-
22+
uv Python request, e.g. "3.12" or "3.14t" (free-threaded). The newest
23+
patch known to the pinned uv is installed. Only series with a fixed
24+
release listed in the interpreter check (3.11-3.15) are accepted.
25+
required: true
26+
venv:
27+
description: Directory for the venv. Defaults to a new directory under RUNNER_TEMP.
28+
default: ""
29+
30+
outputs:
31+
python-path:
32+
description: Absolute path of the venv's interpreter.
33+
value: ${{ steps.venv.outputs.python-path }}
34+
python-version:
35+
description: Full version of the interpreter, e.g. "3.14.10".
36+
value: ${{ steps.venv.outputs.python-version }}
37+
38+
runs:
39+
using: composite
40+
steps:
41+
- name: Install uv
42+
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
43+
with:
44+
# The newest uv whose checksum ships inside the pinned setup-uv, so
45+
# the binary is verified against the SHA-pinned action itself. The uv
46+
# release determines the newest patch of each CPython series, so
47+
# bumping the setup-uv SHA also moves the CPython patch versions.
48+
version: "latest-known"
49+
enable-cache: false
50+
# Some callers (e.g. release verification) have no checkout.
51+
ignore-empty-workdir: true
52+
53+
- name: Install Python and create venv
54+
id: venv
55+
shell: bash --noprofile --norc -euo pipefail {0}
56+
env:
57+
PY_REQUEST: ${{ inputs.python-version }}
58+
VENV_DIR: ${{ inputs.venv }}
59+
# A per-job install directory ensures the newest patch known to the
60+
# pinned uv is used, never an older interpreter left on a persistent
61+
# self-hosted runner.
62+
UV_PYTHON_INSTALL_DIR: ${{ runner.temp }}/setup-hardened-python/interpreters
63+
UV_NO_CONFIG: "1"
64+
run: |
65+
uv python install --no-bin --no-registry "${PY_REQUEST}"
66+
base="$(uv python find --managed-python --no-project "${PY_REQUEST}")"
67+
venv="${VENV_DIR}"
68+
if [[ -z "${venv}" ]]; then
69+
# A fresh directory per call, so a second call in the same job
70+
# (e.g. build-wheel.yml) leaves the first venv intact.
71+
venv="$("${base}" -c 'import sys, tempfile; print(tempfile.mkdtemp(prefix="venv-", dir=sys.argv[1]))' "${RUNNER_TEMP}")"
72+
fi
73+
# The stdlib venv seeds pip from the interpreter's bundled wheel, so
74+
# nothing is downloaded before the ssl check below.
75+
"${base}" -m venv --clear "${venv}"
76+
if [[ "${RUNNER_OS}" == Windows ]]; then
77+
py="${venv}/Scripts/python.exe"
78+
else
79+
py="${venv}/bin/python"
80+
fi
81+
# Let the interpreter report native absolute paths (Windows included).
82+
python_path="$("${py}" -c 'import sys; print(sys.executable)')"
83+
"${py}" -c 'import os, sys; print(os.path.dirname(sys.executable))' >> "${GITHUB_PATH}"
84+
{
85+
echo "python-path=${python_path}"
86+
echo "python-version=$("${py}" -c 'import platform; print(platform.python_version())')"
87+
} >> "${GITHUB_OUTPUT}"
88+
89+
- name: Check Python interpreter is patched (CVE-2026-115557)
90+
# Runs the venv's python through the PATH entry added above.
91+
shell: python {0}
92+
env:
93+
PYTHON: ${{ steps.venv.outputs.python-path }}
94+
run: |
95+
import os
96+
import platform
97+
import sys
98+
99+
if os.path.normcase(sys.executable) != os.path.normcase(os.environ["PYTHON"]):
100+
print(f"::error::PATH resolves python to {sys.executable}, not the venv interpreter {os.environ['PYTHON']}.")
101+
sys.exit(1)
102+
103+
FIXED = {(3, 11): 18, (3, 12): 16, (3, 13): 18, (3, 14): 10, (3, 15): 2}
104+
v = sys.version_info
105+
series = (v.major, v.minor)
106+
name = f"{v.major}.{v.minor}"
107+
full = platform.python_version()
108+
print("sys.version:", sys.version)
109+
if series in FIXED:
110+
floor = f"{name}.{FIXED[series]}"
111+
if v.micro < FIXED[series]:
112+
print(f"::error::Python {full} is older than {floor}, the first {name} release whose ssl module rejects the compromised eMudhra CA keys (CVE-2026-115557).")
113+
sys.exit(1)
114+
print(f"Python {full}: ssl module carries the fix (first fixed: {floor}).")
115+
else:
116+
# Fail closed: a series is only accepted once its fixed release is listed.
117+
print(f"::error::Python {full}: no {name} release is known to reject the compromised eMudhra CA keys (CVE-2026-115557).")
118+
sys.exit(1)
119+
120+
- name: Update pip
121+
shell: bash --noprofile --norc -xeuo pipefail {0}
122+
env:
123+
PYTHON: ${{ steps.venv.outputs.python-path }}
124+
run: |
125+
"${PYTHON}" -m pip install -U pip

‎.github/dependabot.yml‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ version: 2
66
updates:
77
# GitHub Actions updates targeting the default branch (main)
88
- package-ecosystem: github-actions
9-
directory: /
9+
# "/" covers only .github/workflows/; composite actions must be listed.
10+
directories:
11+
- /
12+
- /.github/actions/*
1013
schedule:
1114
interval: "monthly"
1215
time: "09:00"
@@ -55,7 +58,9 @@ updates:
5558

5659
# GitHub Actions updates targeting the 12.9.x branch
5760
- package-ecosystem: github-actions
58-
directory: /
61+
directories:
62+
- /
63+
- /.github/actions/*
5964
target-branch: "12.9.x" # keep in sync with backport_branch in ci/versions.yml
6065
schedule:
6166
interval: "monthly"

‎.github/workflows/build-docs.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ jobs:
305305
# interpreter instead of the conda environment used above.
306306
- name: Set up Python for link checks
307307
if: ${{ !inputs.is-release && startsWith(github.ref_name, 'pull-request/') }}
308-
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
308+
uses: ./.github/actions/setup-hardened-python
309309
with:
310310
python-version: "3.14"
311311

‎.github/workflows/build-wheel.yml‎

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,12 @@ jobs:
107107
enable-apt: true
108108

109109
- name: Set up Python
110-
id: setup-python1
111-
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
110+
id: host-python
111+
uses: ./.github/actions/setup-hardened-python
112112
with:
113-
# WAR: setup-python is not relocatable, and cibuildwheel hard-wires to 3.12...
114-
# see https://github.com/actions/setup-python/issues/871
113+
# Also installs cibuildwheel (via python-path below), so the action
114+
# does not fall back on its own unchecked setup-python interpreter.
115115
python-version: "3.12"
116-
architecture: ${{ ((inputs.host-platform == 'linux-aarch64' || inputs.host-platform == 'win-arm64') && 'arm64') || 'x64' }}
117-
118-
- name: Harden pip
119-
uses: ./.github/actions/harden-pip
120116

121117
- name: Set up MSVC
122118
if: ${{ startsWith(inputs.host-platform, 'win') && (env.BUILD_BINDINGS == 'true' || env.BUILD_CORE == 'true' || env.TEST_BINDINGS == 'true' || env.TEST_CORE == 'true') }}
@@ -235,6 +231,7 @@ jobs:
235231
package-dir: ./cuda_bindings_13/
236232
output-dir: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
237233
extras: uv
234+
python-path: ${{ steps.host-python.outputs.python-path }}
238235
env:
239236
CIBW_BUILD: ${{ env.CIBW_BUILD }}
240237
# build[uv]: same PEP 517 orchestration, with uv instead of pip.
@@ -332,6 +329,7 @@ jobs:
332329
package-dir: ./cuda_core/
333330
output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
334331
extras: uv
332+
python-path: ${{ steps.host-python.outputs.python-path }}
335333
env:
336334
CIBW_BUILD: ${{ env.CIBW_BUILD }}
337335
# See the cuda.bindings step above for UV_* vs PIP_*.
@@ -442,16 +440,10 @@ jobs:
442440
if-no-files-found: error
443441

444442
- name: Set up Python
445-
id: setup-python2
446443
if: ${{ env.TEST_BINDINGS == 'true' || env.TEST_CORE == 'true' }}
447-
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
444+
uses: ./.github/actions/setup-hardened-python
448445
with:
449446
python-version: ${{ matrix.python-version }}
450-
allow-prereleases: ${{ startsWith(matrix.python-version, '3.16') }}
451-
452-
- name: Harden pip
453-
if: ${{ env.TEST_BINDINGS == 'true' || env.TEST_CORE == 'true' }}
454-
uses: ./.github/actions/harden-pip
455447

456448
- name: verify free-threaded build
457449
if: ${{ (env.TEST_BINDINGS == 'true' || env.TEST_CORE == 'true') && endsWith(matrix.python-version, 't') }}
@@ -460,10 +452,11 @@ jobs:
460452
- name: Set up Python include paths
461453
if: ${{ env.TEST_BINDINGS == 'true' || env.TEST_CORE == 'true' }}
462454
run: |
455+
include="$(python -c "import sysconfig; print(sysconfig.get_paths()['include'])")"
463456
if [[ "${{ inputs.host-platform }}" == linux* ]]; then
464-
echo "CPLUS_INCLUDE_PATH=${Python3_ROOT_DIR}/include/python${{ matrix.python-version }}" >> $GITHUB_ENV
457+
echo "CPLUS_INCLUDE_PATH=${include}" >> $GITHUB_ENV
465458
elif [[ "${{ inputs.host-platform }}" == win* ]]; then
466-
echo "CL=/I\"${Python3_ROOT_DIR}\include\python${{ matrix.python-version }}\"" >> $GITHUB_ENV
459+
echo "CL=/I\"${include}\"" >> $GITHUB_ENV
467460
fi
468461
# For caching
469462
echo "PY_EXT_SUFFIX=$(python -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")" >> $GITHUB_ENV
@@ -614,6 +607,7 @@ jobs:
614607
package-dir: ./cuda_core/
615608
output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
616609
extras: uv
610+
python-path: ${{ steps.host-python.outputs.python-path }}
617611
env:
618612
CIBW_BUILD: ${{ env.CIBW_BUILD }}
619613
# See the cuda.bindings step above for UV_* vs PIP_*.

‎.github/workflows/ci-nightly.yml‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ jobs:
5858
with:
5959
fetch-depth: 1
6060

61-
- name: Harden pip
62-
uses: ./.github/actions/harden-pip
61+
- name: Set up Python
62+
uses: ./.github/actions/setup-hardened-python
63+
with:
64+
python-version: "3.12"
6365

6466
- name: Run CI tools unit tests
6567
run: |

‎.github/workflows/coverage.yml‎

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,10 @@ jobs:
102102
echo "CUDA_PYTHON_COVERAGE=1" >> $GITHUB_ENV
103103
104104
- name: Set up Python
105-
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
105+
uses: ./.github/actions/setup-hardened-python
106106
with:
107107
python-version: ${{ env.PY_VER }}
108-
env:
109-
# we use self-hosted runners on which setup-python behaves weirdly...
110-
AGENT_TOOLSDIRECTORY: "/opt/hostedtoolcache"
108+
venv: .venv
111109

112110
- name: Set up mini CTK
113111
if: ${{ env.LOCAL_CTK == '1' }}
@@ -117,15 +115,6 @@ jobs:
117115
host-platform: ${{ env.HOST_PLATFORM }}
118116
cuda-version: ${{ env.CUDA_VER }}
119117

120-
- name: Create venv
121-
run: |
122-
python -m venv .venv
123-
124-
- name: Harden pip
125-
uses: ./.github/actions/harden-pip
126-
with:
127-
python: .venv/bin/python
128-
129118
- name: Build and install cuda-pathfinder wheel
130119
run: |
131120
.venv/bin/pip wheel -v --no-deps ./cuda_pathfinder -w ./wheels/
@@ -253,9 +242,10 @@ jobs:
253242
submodules: true
254243

255244
- name: Set up Python
256-
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
245+
uses: ./.github/actions/setup-hardened-python
257246
with:
258247
python-version: ${{ env.PY_VER }}
248+
venv: .venv
259249

260250
- name: Set up MSVC
261251
uses: step-security/msvc-dev-cmd@22c98154b708dbd743e6f27a933cf6ceba3305c4 # v1.13.1
@@ -267,15 +257,6 @@ jobs:
267257
host-platform: win-64
268258
cuda-version: ${{ env.CUDA_VER }}
269259

270-
- name: Create venv
271-
run: |
272-
python -m venv .venv
273-
274-
- name: Harden pip
275-
uses: ./.github/actions/harden-pip
276-
with:
277-
python: .venv/Scripts/python
278-
279260
- name: Build cuda.pathfinder wheel
280261
run: |
281262
.venv/Scripts/python -m pip install wheel setuptools Cython
@@ -392,9 +373,10 @@ jobs:
392373
nvidia-smi
393374
394375
- name: Set up Python
395-
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
376+
uses: ./.github/actions/setup-hardened-python
396377
with:
397378
python-version: ${{ env.PY_VER }}
379+
venv: .venv
398380

399381
- name: Set up mini CTK
400382
uses: ./.github/actions/fetch_ctk
@@ -414,15 +396,6 @@ jobs:
414396
echo "=== Downloaded wheel artifacts ==="
415397
ls -lahR ./wheels/
416398
417-
- name: Create venv
418-
run: |
419-
python -m venv .venv
420-
421-
- name: Harden pip
422-
uses: ./.github/actions/harden-pip
423-
with:
424-
python: .venv/Scripts/python
425-
426399
- name: Install wheels from build job
427400
run: |
428401
.venv/Scripts/pip install ./wheels/cuda_pathfinder*.whl
@@ -502,13 +475,10 @@ jobs:
502475
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
503476

504477
- name: Set up Python
505-
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
478+
uses: ./.github/actions/setup-hardened-python
506479
with:
507480
python-version: ${{ env.PY_VER }}
508481

509-
- name: Harden pip
510-
uses: ./.github/actions/harden-pip
511-
512482
- name: Install coverage
513483
run: |
514484
# .coveragerc enables Cython.Coverage plugin; ensure it's available here too.

0 commit comments

Comments
 (0)