-
Notifications
You must be signed in to change notification settings - Fork 0
172 lines (153 loc) · 6.36 KB
/
Copy pathbuild-lib3mf.yml
File metadata and controls
172 lines (153 loc) · 6.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# SPDX-FileCopyrightText: 2026 The RISE Project
# SPDX-License-Identifier: MIT
---
# Based on: https://github.com/3MFConsortium/lib3mf_python/blob/v2.5.0/.github/workflows/python-package.yml
name: Build lib3mf wheels (riscv64)
on:
workflow_dispatch:
inputs:
version:
description: 'Version glob to (re)build; empty builds every version of docs/packages/lib3mf.yaml not released yet'
required: false
default: ''
pull_request:
branches: [main]
paths:
- '.github/workflows/build-lib3mf.yml'
- 'docs/packages/lib3mf.yaml'
push:
branches: [main]
paths:
- '.github/workflows/build-lib3mf.yml'
- 'docs/packages/lib3mf.yaml'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read # to fetch code (actions/checkout)
env:
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64
jobs:
setup:
uses: $/.github/workflows/_setup.yml
with:
package: lib3mf
version: ${{ inputs.version }}
build_wheels:
needs: [setup]
if: needs.setup.outputs.versions != '[]'
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
name: Build lib3mf ${{ matrix.version }} py3-none-manylinux_riscv64
runs-on: ubuntu-24.04-riscv
timeout-minutes: 360
env:
LIB3MF_VERSION: ${{ matrix.version }}
steps:
- name: Checkout lib3mf_python v${{ env.LIB3MF_VERSION }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: 3MFConsortium/lib3mf_python
ref: v${{ env.LIB3MF_VERSION }}
persist-credentials: false
# lib3mf/lib3mf.so is committed to the packaging repo as an x86_64 binary,
# lifted by prepare_pypi_release.py out of the lib3mf_sdk_v<version>.zip
# release asset. That SDK is published for x86_64 Linux only, so build the
# library from its own sources instead (gotcha 77).
- name: Checkout lib3mf v${{ env.LIB3MF_VERSION }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: 3MFConsortium/lib3mf
ref: v${{ env.LIB3MF_VERSION }}
path: lib3mf-src
submodules: true
persist-credentials: false
- name: Checkout python-wheels
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: python-wheels
persist-credentials: false
- name: Patch lib3mf_python source
run: git apply python-wheels/patches/lib3mf/${{ env.LIB3MF_VERSION }}/*.patch
# lib3mf.so statically links zlib, libzip and cpp-base64 and inlines
# fast_float, but the wheel ships only the binding's own BSD licence.
- name: Stage the statically linked libraries' licences
run: |
cp lib3mf-src/submodules/zlib/LICENSE LICENSE.zlib
cp lib3mf-src/submodules/libzip/LICENSE LICENSE.libzip
cp lib3mf-src/submodules/cpp-base64/LICENSE LICENSE.cpp-base64
cp lib3mf-src/submodules/fast_float/LICENSE-MIT LICENSE.fast_float
- name: Pull manylinux_riscv64 image
run: docker pull "${MANYLINUX_RISCV64_IMAGE}"
# LIB3MF_TESTS=OFF because the default target also builds the C++ test
# suite and the vendored libressl it links, neither of which reaches the
# wheel; the wheel's own tests cover the library below.
- name: Build lib3mf.so and the wheel
run: |
docker run --rm -v "$(pwd):/work" -w /work "${MANYLINUX_RISCV64_IMAGE}" bash -c '
set -euxo pipefail
cd /work/lib3mf-src
sh cmake/GenerateMake.sh -DLIB3MF_TESTS=OFF
cmake --build build -j"$(nproc)"
readelf -hd build/lib3mf.so
cd /work
install -m644 -T lib3mf-src/build/lib3mf.so lib3mf/lib3mf.so
export PATH=/opt/python/cp312-cp312/bin:$PATH
pip install -q -U setuptools wheel
python build_wheels.py
pip install -q dist/*.whl
cd /tmp
python -c "from lib3mf import get_wrapper; print(get_wrapper().GetLibraryVersion())"
python /work/examples/create_cube_example_complete.py
python - <<PYEOF
import lib3mf
model = lib3mf.get_wrapper().CreateModel()
model.QueryReader("3mf").ReadFromFile("cube.3mf")
meshes = model.GetMeshObjects()
assert meshes.MoveNext()
cube = meshes.GetCurrentMeshObject()
assert (cube.GetVertexCount(), cube.GetTriangleCount()) == (8, 12)
assert not meshes.MoveNext()
PYEOF
python /work/tests/lib3mf_py313_exception.py
'
- name: Check the wheel carries the riscv64 lib3mf.so and every licence
run: |
python3 - dist/*.whl <<'EOF'
import sys, zipfile
expected = {"LICENSE", "LICENSE.zlib", "LICENSE.libzip",
"LICENSE.cpp-base64", "LICENSE.fast_float"}
for whl in sys.argv[1:]:
zf = zipfile.ZipFile(whl)
names = zf.namelist()
assert "lib3mf/lib3mf.so" in names, whl
e_machine = int.from_bytes(zf.read("lib3mf/lib3mf.so")[18:20], "little")
assert e_machine == 243, f"{whl}: e_machine {e_machine} is not riscv64"
licenses = {n.split(".dist-info/licenses/", 1)[1] for n in names
if ".dist-info/licenses/" in n and not n.endswith("/")}
assert licenses == expected, f"{whl}: {sorted(licenses)}"
print(whl, "ok")
EOF
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: lib3mf-${{ env.LIB3MF_VERSION }}-py3-none-manylinux_riscv64
path: dist/*.whl
if-no-files-found: error
publish:
name: Publish lib3mf ${{ matrix.version }}
needs: [setup, build_wheels]
if: needs.setup.outputs.versions != '[]'
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
permissions:
contents: write
pull-requests: write
uses: $/.github/workflows/_publish-wheel.yml
secrets:
app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }}
with:
artifact-pattern: lib3mf-${{ matrix.version }}-*-manylinux_riscv64