-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (132 loc) · 5.29 KB
/
Copy pathbuild-cffi.yml
File metadata and controls
152 lines (132 loc) · 5.29 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
---
name: Build cffi wheels (riscv64)
on:
workflow_dispatch:
inputs:
version:
description: 'cffi version to build (git tag without leading v, e.g. 2.1.0)'
required: true
default: '2.1.0'
pull_request:
paths:
- '.github/workflows/build-cffi.yml'
concurrency:
group: ${{ github.workflow }}-${{ inputs.version || '2.1.0' }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read # to fetch code (actions/checkout)
env:
CFFI_VERSION: ${{ inputs.version || '2.1.0' }}
UV_EXTRA_INDEX_URL: https://pypi.riseproject.dev/simple/
UV_INDEX_STRATEGY: unsafe-best-match
UV_ONLY_BINARY: ':all:'
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64
jobs:
python_sdist:
runs-on: ubuntu-24.04-riscv
outputs:
sdist_artifact_name: ${{ steps.build_sdist.outputs.sdist_artifact_name }}
package_version: ${{ steps.build_sdist.outputs.package_version }}
steps:
- name: checkout cffi
uses: actions/checkout@v7
with:
repository: python-cffi/cffi
ref: v${{ env.CFFI_VERSION }}
submodules: true
persist-credentials: false
- name: setup uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
python-version: '3.12'
activate-environment: true
enable-cache: false
- name: build sdist
id: build_sdist
run: |
rm -rf dist/
uv pip install build
python -m build --sdist
echo "sdist_artifact_name=$(ls ./dist)" >> "$GITHUB_OUTPUT"
echo "package_version=$(ls ./dist | sed -En 's/cffi-(.+)\.tar\.gz/\1/p')" >> "$GITHUB_OUTPUT"
- name: upload sdist artifact
uses: actions/upload-artifact@v7
with:
name: ${{ steps.build_sdist.outputs.sdist_artifact_name }}
path: dist/${{ steps.build_sdist.outputs.sdist_artifact_name }}
if-no-files-found: error
# always upload the sdist artifact- all the wheel build jobs require it
linux:
# Unlike upstream, we depend only on python_sdist, since we don't need to
# build a large matrix of targets
needs: [python_sdist]
name: Build cffi ${{ inputs.version || '2.1.0' }} ${{ matrix.python }}-manylinux_riscv64
runs-on: ubuntu-24.04-riscv
strategy:
fail-fast: false
matrix:
python: ["cp312", "cp313", "cp314", "cp314t"]
steps:
- name: fetch sdist artifact
id: fetch_sdist
uses: actions/download-artifact@v8
with:
name: ${{ needs.python_sdist.outputs.sdist_artifact_name }}
- name: setup uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
python-version: '3.12'
activate-environment: true
enable-cache: false
- name: build/test wheels
id: build
env:
CFLAGS: -Dffi_call=cffistatic_ffi_call # override name for ffi_call to break hard if we linked against someone else's libffi
CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64
CIBW_ENVIRONMENT_PASS_LINUX: CFLAGS # ensure that the build container can see our overridden build config
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }}
CIBW_BEFORE_BUILD: |
set -eux && \
curl -L -O https://github.com/libffi/libffi/archive/v3.4.6.tar.gz && \
tar zxf v3.4.6.tar.gz && cd libffi-3.4.6 && \
((command -v apk && apk add libtool) || true) && \
./autogen.sh && \
./configure --without-gcc-arch --disable-docs --with-pic --enable-shared=no && \
make install && \
cd .. && \
rm -rf libffi-3.4.6
CIBW_TEST_REQUIRES: pytest setuptools meson-python ninja # 3.12+ no longer includes distutils, just always ensure setuptools is present
CIBW_TEST_COMMAND: PYTHONUNBUFFERED=1 python -m pytest {project}
run: |
set -eux
mkdir cffi
tar zxf ${{ steps.fetch_sdist.outputs.download-path }}/cffi*.tar.gz --strip-components=1 -C cffi
uv pip install --upgrade cibuildwheel
# actually build libffi + wheel (using env tweaks above)
python -m cibuildwheel --output-dir dist ./cffi
echo "artifact_name=$(ls ./dist/)" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: cffi-${{ env.CFFI_VERSION }}-${{ matrix.python }}-manylinux_riscv64
path: ./dist/*.whl
if-no-files-found: error
publish:
name: Publish cffi ${{ inputs.version || '2.1.0' }} to GitLab
needs: [linux]
# Only publish when the workflow was triggered from main with a specific
# version. Manual trigger is the only entry point, so checking the ref is
# enough to gate uploads.
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Publish wheels and open docs PR
uses: riseproject-dev/python-wheels/actions/publish-wheels@main
with:
artifact-pattern: cffi-${{ env.CFFI_VERSION }}-*-manylinux_riscv64
gitlab-username: ${{ vars.GITLAB_DEPLOY_USER }}
gitlab-token: ${{ secrets.GITLAB_DEPLOY_TOKEN }}
gitlab-project-id: ${{ vars.GITLAB_PROJECT_ID }}
gh-token: ${{ secrets.GITHUB_TOKEN }}