1- name : _Build
1+ name : 15. _Build Distribution
22
33on :
44 workflow_call :
5+ inputs :
6+ os_json :
7+ description : ' JSON string of OS to build on'
8+ required : false
9+ type : string
10+ default : ' ["ubuntu-latest", "macos-latest", "macos-15-intel", "windows-latest"]'
11+ python_json :
12+ description : ' JSON string of Python versions'
13+ required : false
14+ type : string
15+ default : ' ["3.9", "3.10", "3.11", "3.12"]'
516 workflow_dispatch :
17+ inputs :
18+ os_json :
19+ description : ' JSON string of OS to build on'
20+ required : false
21+ default : ' ["ubuntu-latest", "macos-latest", "macos-15-intel", "windows-latest"]'
22+ python_json :
23+ description : ' JSON string of Python versions'
24+ required : false
25+ default : ' ["3.9", "3.10", "3.11", "3.12"]'
626
727jobs :
828 build-linux :
929 name : Build distribution on Linux (glibc 2.31) py${{ matrix.python-version }}
30+ # Only run if inputs.os_json contains 'ubuntu' or 'linux'
31+ if : contains(inputs.os_json, 'ubuntu') || contains(inputs.os_json, 'linux')
1032 runs-on : ubuntu-latest
1133 container : ubuntu:20.04
1234 env :
1335 DEBIAN_FRONTEND : noninteractive
1436 TZ : Etc/UTC
1537 strategy :
38+ fail-fast : false
1639 matrix :
17- include :
18- - python-version : ' 3.9'
19- python-full : ' 3.9.18'
20- - python-version : ' 3.10'
21- python-full : ' 3.10.13'
22- - python-version : ' 3.11'
23- python-full : ' 3.11.8'
24- - python-version : ' 3.12'
25- python-full : ' 3.12.2'
26-
40+ python-version : ${{ fromJson(inputs.python_json) }}
41+
2742 steps :
2843 - name : Install system dependencies (Linux)
2944 run : |
@@ -39,10 +54,25 @@ jobs:
3954 - uses : actions/checkout@v4
4055 with :
4156 submodules : recursive
57+ fetch-depth : 0 # Required for setuptools_scm to detect version from git tags
4258
43- - name : Build CPython ${{ matrix.python-full }} (Linux )
59+ - name : Build CPython (Dynamic Selection )
4460 run : |
45- PYTHON_FULL="${{ matrix.python-full }}"
61+ # Map short version to full version for our specific build environment
62+ declare -A PYTHON_MAP
63+ PYTHON_MAP["3.9"]="3.9.18"
64+ PYTHON_MAP["3.10"]="3.10.13"
65+ PYTHON_MAP["3.11"]="3.11.8"
66+ PYTHON_MAP["3.12"]="3.12.2"
67+
68+ PYTHON_VERSION="${{ matrix.python-version }}"
69+ PYTHON_FULL="${PYTHON_MAP[$PYTHON_VERSION]}"
70+
71+ if [ -z "$PYTHON_FULL" ]; then
72+ echo "Error: Unknown python version $PYTHON_VERSION"
73+ exit 1
74+ fi
75+
4676 PYTHON_PREFIX="/opt/python/${PYTHON_FULL}"
4777 PYTHON_BIN="${PYTHON_PREFIX}/bin/python${{ matrix.python-version }}"
4878 if [ ! -x "$PYTHON_BIN" ]; then
80110 run : uv sync
81111
82112 - name : Install build dependencies
83- run : uv pip install setuptools pybind11 cmake wheel build
113+ run : uv pip install setuptools setuptools_scm pybind11 cmake wheel build
84114
85115 - name : Build package
86116 run : uv run python -m build
@@ -116,16 +146,23 @@ jobs:
116146
117147 build-other :
118148 name : Build distribution on ${{ matrix.os }}
149+ # Filter out ubuntu-latest from this job since it's handled by build-linux
150+ if : ${{ matrix.os != 'ubuntu-latest' }}
119151 runs-on : ${{ matrix.os }}
120152 strategy :
153+ fail-fast : false
121154 matrix :
122- os : [macos-latest, macos-15-intel, windows-latest]
123- python-version : ['3.9', '3.10', '3.11', '3.12']
155+ os : ${{ fromJson(inputs.os_json) }}
156+ python-version : ${{ fromJson(inputs.python_json) }}
157+ # Exclude ubuntu-latest from this matrix if it was passed in inputs
158+ exclude :
159+ - os : ubuntu-latest
124160
125161 steps :
126162 - uses : actions/checkout@v4
127163 with :
128164 submodules : recursive
165+ fetch-depth : 0 # Required for setuptools_scm to detect version from git tags
129166
130167 - name : Set up Python
131168 uses : actions/setup-python@v6
@@ -156,7 +193,7 @@ jobs:
156193 run : uv sync
157194
158195 - name : Install build dependencies
159- run : uv pip install setuptools pybind11 cmake wheel build
196+ run : uv pip install setuptools setuptools_scm pybind11 cmake wheel build
160197
161198 - name : Build package
162199 run : uv run python -m build
0 commit comments