Skip to content

Commit 102b815

Browse files
committed
Rename wheels.yml and release.yml in a more explicit way
1 parent d624e04 commit 102b815

File tree

2 files changed

+382
-1
lines changed

2 files changed

+382
-1
lines changed
Lines changed: 376 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,376 @@
1+
# SPDX-FileCopyrightText: 2024 Howetuft
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
# This action is the 1st part of a larger toolchain. You will find the other
6+
# components in LuxCoreRender/LuxCoreWheels repository
7+
8+
9+
name: LuxCore Python Wheels Builder
10+
11+
on:
12+
workflow_dispatch:
13+
workflow_call:
14+
inputs:
15+
repository:
16+
description: 'Repository to check out'
17+
required: false
18+
default: ''
19+
type: string
20+
ref:
21+
description: 'The branch, tag or SHA to checkout.'
22+
required: false
23+
default: ''
24+
type: string
25+
version:
26+
description: 'The version to build - must comply to semver, or blank for default'
27+
type: string
28+
outputs:
29+
commit:
30+
description: "The commit that has been checked out"
31+
value: ${{ jobs.build-wheels.outputs.commit }}
32+
branch:
33+
description: "The branch that has been checked out"
34+
value: ${{ jobs.build-wheels.outputs.branch }}
35+
attestation-url:
36+
description: "The url to the attestations"
37+
value: ${{ jobs.attest-wheels.outputs.attestation-url }}
38+
version:
39+
description: "The version actually built"
40+
value: ${{ jobs.build-wheels.outputs.version }}
41+
push:
42+
43+
jobs:
44+
build-wheels:
45+
name: Build wheel ${{ matrix.os }}-3.${{ matrix.python-minor }}
46+
runs-on: ${{ matrix.os }}
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
python-minor: [9, 10, 11, 12, 13]
51+
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
52+
#python-minor: [ 9 ]
53+
#python-minor: [ 12]
54+
#os: [macos-14]
55+
#python-minor: [ 11]
56+
#os: [windows-latest]
57+
#python-minor: [ 11]
58+
#os: [macos-13]
59+
env:
60+
# Reminder: report all variables here to CIBW_ENVIRONMENT_PASS_LINUX
61+
BUILD_TYPE: Release
62+
CXX_VERSION: 20
63+
GCC_VERSION: 14
64+
GLIBC_VERSION: 2_28
65+
GH_TOKEN: ${{ github.token }}
66+
PYTHON_MINOR: ${{ matrix.python-minor }}
67+
outputs:
68+
commit: ${{ steps.current-commit.outputs.commit }}
69+
branch: ${{ steps.current-commit.outputs.branch }}
70+
version: ${{ steps.output-version.outputs.version }}
71+
72+
steps:
73+
74+
- name: Configure git for long paths
75+
shell: bash
76+
if: runner.os == 'Windows'
77+
run: git config --system core.longpaths true
78+
79+
- name: Checkout main repository (standard context)
80+
if: ${{ !env.ACT }}
81+
uses: actions/checkout@v4
82+
with:
83+
repository: ${{ inputs.repository }}
84+
ref: ${{ inputs.ref }}
85+
86+
- name: Checkout main repository (act context)
87+
if: env.ACT
88+
uses: actions/checkout@v4
89+
90+
- name: Get current commit
91+
id: current-commit
92+
run: |
93+
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
94+
echo "branch=$(git symbolic-ref HEAD)" >> $GITHUB_OUTPUT
95+
echo "commit=$(git rev-parse HEAD)"
96+
echo "branch=$(git symbolic-ref HEAD)"
97+
98+
- name: Find workspace
99+
shell: bash
100+
run: |
101+
case ${{ runner.os }} in
102+
Linux) _workspace="/project";;
103+
Windows) _workspace=$(cygpath -u $GITHUB_WORKSPACE);;
104+
macOS) _workspace="$GITHUB_WORKSPACE";;
105+
*) echo "Unhandled os ${{ runner.os }}";exit 64;;
106+
esac
107+
echo "WORKSPACE=${_workspace}" >> $GITHUB_ENV
108+
109+
- name: Set Conan parameters
110+
shell: bash
111+
run: |
112+
_build_type=$(echo "${{ env.BUILD_TYPE }}" | tr '[:upper:]' '[:lower:]')
113+
_conan_home="${{ env.WORKSPACE }}/.conan2"
114+
echo "CONAN_PRESET=conan-${_build_type}" >> $GITHUB_ENV
115+
echo "CONAN_HOME=${_conan_home}" >> $GITHUB_ENV
116+
117+
- name: Configure ccache
118+
uses: actions/github-script@v7
119+
with:
120+
script: |
121+
const workspace = String.raw`${{ github.workspace }}`;
122+
123+
const envVariables = {
124+
'cache-variant': String.raw`ccache`,
125+
'CMAKE_CXX_COMPILER_LAUNCHER': String.raw`ccache`,
126+
'CMAKE_C_COMPILER_LAUNCHER': String.raw`ccache`,
127+
'CCACHE_CONFIGPATH': String.raw`${workspace}/ccache.conf`,
128+
'CCACHE_DIR': String.raw`${workspace}/.ccache`,
129+
'CCACHE_DEBUGDIR': String.raw`${workspace}/ccache-debug`,
130+
'CCACHE_LOGFILE': String.raw`${workspace}/ccache.log`
131+
};
132+
133+
for (const [key, value] of Object.entries(envVariables)) {
134+
core.exportVariable(key, value);
135+
}
136+
137+
# Update apt: needed to install ccache
138+
- name: Update apt (Linux)
139+
if: runner.os == 'Linux'
140+
shell: bash
141+
run: |
142+
sudo apt-get update -y
143+
144+
- name: ccache
145+
uses: hendrikmuhs/ccache-action@v1.2
146+
with:
147+
create-symlink: false
148+
variant: ${{ env.cache-variant }}
149+
key: cpl-${{ matrix.os }}-${{ matrix.python-minor}}
150+
restore-keys: cpl-${{ matrix.os }}-${{ matrix.python-minor}}-
151+
max-size: 5G
152+
verbose: 1
153+
154+
- name: Prepare msvc
155+
if: runner.os == 'Windows'
156+
uses: ilammy/msvc-dev-cmd@v1
157+
158+
- name: Prepare Linux
159+
if: runner.os == 'Linux'
160+
shell: bash
161+
run: |
162+
_V=${{ env.GCC_VERSION }}
163+
_T=/opt/rh/gcc-toolset-${_V}/root
164+
165+
echo "TOOLSET_ROOT=${_T}" >> $GITHUB_ENV
166+
echo "CXX=${_T}/usr/bin/g++" >> $GITHUB_ENV
167+
echo "CC=${_T}/usr/bin/gcc" >> $GITHUB_ENV
168+
echo "AR=${_T}/usr/bin/ar" >> $GITHUB_ENV
169+
echo "RANLIB=${_T}/usr/bin/ranlib" >> $GITHUB_ENV
170+
171+
- name: Set MacOS deployment target
172+
if: runner.os == 'macOS'
173+
uses: actions/github-script@v7
174+
with:
175+
script: |
176+
if ('${{ runner.arch }}' == 'X64') {
177+
target = '10.15';
178+
arch='x86_64';
179+
}
180+
else if ('${{ env.PYTHON_MINOR }}' != '8') {
181+
target = '11.0';
182+
arch='armv8';
183+
}
184+
else {
185+
target = '12.0';
186+
arch='armv8';
187+
}
188+
core.exportVariable('MACOSX_DEPLOYMENT_TARGET', target);
189+
core.exportVariable('PKG_ARCH', arch);
190+
191+
# TODO: The following block is an ugly hack but, at the moment (2025-02-25),
192+
# scikit-build-core lacks a preset parameter, so this is the only way
193+
# I found to pass a calculated environment var to CMake build step
194+
- name: Set M4 env var
195+
if: runner.os != 'Windows'
196+
uses: actions/github-script@v7
197+
with:
198+
script: |
199+
if ('${{ runner.arch }}' == 'X64') {
200+
arch = 'x86_64'
201+
} else {
202+
arch = 'armv8'
203+
}
204+
base = '${{ env.WORKSPACE }}/out/dependencies/full_deploy/host/m4/1.4.19/Release/'
205+
core.exportVariable('M4', base + arch + '/bin/m4')
206+
207+
- name: Export version for scikit-build-core
208+
shell: python
209+
run: |
210+
import json
211+
if (input_version := "${{ inputs.release-version }}"):
212+
result = input_version
213+
else:
214+
with open("luxcore.json") as in_file:
215+
default_version = json.load(in_file)["DefaultVersion"]
216+
result = ".".join(default_version[i] for i in ("major", "minor", "patch"))
217+
if (prerelease := default_version["prerelease"]):
218+
result = f"{result}-{prerelease}"
219+
220+
print(f"Version: {result}")
221+
222+
with open("SKVERSION", "w+") as out_file:
223+
out_file.write(result)
224+
225+
- name: Output version
226+
id: output-version
227+
shell: bash
228+
run: |
229+
_version=$(cat SKVERSION)
230+
echo "version=${_version}" >> "$GITHUB_OUTPUT"
231+
232+
233+
# Build wheel
234+
- name: Build wheels
235+
uses: pypa/cibuildwheel@v2.22.0
236+
env:
237+
CIBW_BUILD_FRONTEND: build
238+
CIBW_BUILD_VERBOSITY: 1
239+
CIBW_BUILD: cp3${{ matrix.python-minor }}-*
240+
CIBW_SKIP: "*musllinux*"
241+
CIBW_ARCHS: auto64
242+
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_${{ env.GLIBC_VERSION }}_x86_64
243+
CIBW_ENVIRONMENT: >
244+
SKBUILD_CMAKE_ARGS='--preset ${{ env.CONAN_PRESET }};-G Ninja;--log-level=VERBOSE;-DLUXCORE_VERSION=${{ steps.output-version.outputs.version }}'
245+
SKBUILD_CMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
246+
LUX_GENERATOR='Ninja'
247+
CIBW_ENVIRONMENT_PASS_LINUX: |
248+
CC
249+
CXX
250+
BUILD_TYPE
251+
GCC_VERSION
252+
SANITIZE
253+
ASAN_PATH
254+
RUNNER_OS
255+
RUNNER_ARCH
256+
WORKSPACE
257+
CMAKE_CXX_COMPILER_LAUNCHER
258+
CMAKE_C_COMPILER_LAUNCHER
259+
PYTHON_MINOR
260+
BOOST_INSTALL_LAYOUT
261+
SPDLOG_FMT_EXTERNAL
262+
CXX_VERSION
263+
CONAN_HOME
264+
CONAN_PRESET
265+
M4
266+
CIBW_BEFORE_ALL_LINUX: |
267+
# Install toolchain (gcc, ccache...)
268+
dnf install -y epel-release
269+
dnf install -y almalinux-release-devel
270+
dnf install -y ccache
271+
dnf install -y sudo # for gtk3...
272+
dnf install -y perl-IPC-Cmd perl-Digest-SHA
273+
274+
# Manylinux_2_34 compatibility
275+
if [[ ${{ env.GLIBC_VERSION }} != 2_28 ]]; then
276+
dnf install -y perl-FindBin perl-lib
277+
fi
278+
279+
pip install conan && make deps
280+
281+
CIBW_BEFORE_ALL_MACOS: |
282+
pip install conan && make deps
283+
284+
CIBW_BEFORE_ALL_WINDOWS: |
285+
pip install conan && make deps
286+
287+
288+
CIBW_REPAIR_WHEEL_COMMAND_LINUX: |
289+
paths=$(find /project -type d -wholename "*/lib" -print0 | xargs -0 realpath | tr "\n" ":")
290+
LD_LIBRARY_PATH=$paths:$LD_LIBRARY_PATH
291+
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}"
292+
export LD_LIBRARY_PATH
293+
294+
## Check build data
295+
unzip {wheel} -d /tmp/wheel
296+
297+
auditwheel \
298+
--verbose repair -w {dest_dir} \
299+
--plat manylinux_${{ env.GLIBC_VERSION }}_x86_64 \
300+
--only-plat \
301+
${{ env.BUILD_TYPE == 'Release' && '--strip' || '' }} \
302+
{wheel}
303+
304+
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: |
305+
bash.exe ${{ env.WORKSPACE }}/scripts/repair_wheel_windows.sh '{wheel}' '{dest_dir}' '%VCToolsRedistDir%%Platform%' '${{ env.WORKSPACE }}'
306+
CIBW_REPAIR_WHEEL_COMMAND_MACOS: |
307+
cp {wheel} ${{ env.WORKSPACE }}
308+
paths=$(find ${{ env.WORKSPACE }} -type d -wholename "*/lib" -print0 | xargs -0 realpath | tr "\n" ":")
309+
DYLD_LIBRARY_PATH=$paths:$DYLD_LIBRARY_PATH
310+
echo "DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}"
311+
export DYLD_LIBRARY_PATH
312+
delocate-listdeps -v {wheel}
313+
delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}
314+
CIBW_TEST_COMMAND_LINUX: pyluxcoretest
315+
CIBW_TEST_COMMAND_WINDOWS: pyluxcoretest
316+
CIBW_TEST_COMMAND_MACOS: |
317+
if [[ ${{ matrix.os }} == 'macos-13' ]]; then
318+
# Only for Intel: ARM runner raises an OpenCL driver issue
319+
pyluxcoretest
320+
fi
321+
CIBW_CONTAINER_ENGINE: >
322+
docker;
323+
create_args:
324+
--mount type=bind,source=${{ env.CCACHE_DIR }},target=/root/.ccache
325+
326+
with:
327+
package-dir: .
328+
output-dir: wheelhouse
329+
config-file: "{package}/pyproject.toml"
330+
331+
332+
- name: Save dependency cache
333+
if: always()
334+
id: cache-deps-save
335+
uses: actions/cache/save@v4
336+
with:
337+
path: conan-cache
338+
key: deps-${{ matrix.os }}-${{ matrix.python-minor}}-${{ hashFiles('**/conan-cache') }}
339+
340+
#- name: Setup tmate session
341+
#uses: mxschmitt/action-tmate@v3
342+
343+
#- name: Setup tmate session (debug)
344+
#if: ${{ failure() }}
345+
#uses: mxschmitt/action-tmate@v3
346+
347+
# Upload artifacts
348+
- uses: actions/upload-artifact@v4
349+
id: upload
350+
with:
351+
name: cibw-wheels-${{ matrix.os }}-${{ matrix.python-minor }}
352+
path: ./wheelhouse/*.whl
353+
354+
attest-wheels:
355+
needs: [build-wheels]
356+
runs-on: ubuntu-latest
357+
permissions:
358+
attestations: write
359+
id-token: write
360+
outputs:
361+
attestation-url: ${{ steps.attestation-step.outputs.attestation-url }}
362+
363+
steps:
364+
- uses: actions/download-artifact@v4
365+
if: ${{ !env.ACT }}
366+
with:
367+
pattern: cibw-wheels-*
368+
path: ${{ github.workspace }}/dist
369+
merge-multiple: false
370+
371+
- name: Generate artifact attestations
372+
id: attestation-step
373+
if: ${{ !env.ACT }}
374+
uses: actions/attest-build-provenance@v2
375+
with:
376+
subject-path: ${{ github.workspace }}/dist/*
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ on:
4141

4242
jobs:
4343
call-build-wheels:
44-
uses: ./.github/workflows/wheels.yml
44+
name: 'Build wheels'
45+
needs: [check-version]
46+
uses: ./.github/workflows/wheel-builder.yml
47+
with:
48+
repository: LuxCoreRender/LuxCore
49+
version: ${{ inputs.release-version }}
4550

4651
create-release:
4752
name: 'Create release'

0 commit comments

Comments
 (0)