-
-
Notifications
You must be signed in to change notification settings - Fork 538
140 lines (120 loc) · 4.51 KB
/
build-and-cache-libpq.yml
File metadata and controls
140 lines (120 loc) · 4.51 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
name: Build and cache libpq
# Build the libpq package and cache the artifacts.
#
# Every Python version on the same architecture will use the same libpq.
# Therefore building and caching the libpq together with the binary packages
# result in multiple concurrent builds, and the github artifacts manageer very
# confused.
#
# This job builds the libpq and then caches the artifacts so that the
# packages.yml workflow will find the library in the cache.
#
# You can see the caches at https://github.com/psycopg/psycopg2/actions/caches
#
# Or from the API:
#
# curl -fsSL -X GET \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer $GITHUB_TOKEN" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# "https://api.github.com/repos/psycopg/psycopg2/actions/caches" \
# | jq -r '.actions_caches[].key'
#
# You can delete a cache using:
#
# curl -fsSL -X DELETE \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer $GITHUB_TOKEN" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# "https://api.github.com/repos/psycopg/psycopg2/actions/caches?key=libpq-manylinux-ppc64le-17.2-3.4.0"
#
# ref: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-github-actions-caches-for-a-repository-using-a-cache-key
on:
workflow_dispatch:
push:
paths:
- .github/workflows/build-and-cache-libpq.yml
- scripts/build/build_libpq.sh
# TODO: move these env vars in an external env file in order to share them
# across workflows.
env:
# Latest release: https://www.postgresql.org/ftp/source/
LIBPQ_VERSION: "17.9"
# Latest release: https://www.openssl.org/source/
OPENSSL_VERSION: "3.5.6"
PQ_FLAGS: ""
concurrency:
# Cancel older requests of the same workflow in the same branch.
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
linux: # {{{
runs-on: ubuntu-latest
if: true
strategy:
fail-fast: false
matrix:
arch: [x86_64, ppc64le, aarch64, riscv64]
platform: [manylinux, musllinux]
steps:
- uses: actions/checkout@v6
- name: Set up QEMU for multi-arch build
# Check https://github.com/docker/setup-qemu-action for newer versions.
uses: docker/setup-qemu-action@v4
with:
# https://github.com/pypa/cibuildwheel/discussions/2256
image: tonistiigi/binfmt:qemu-v8.1.5
- name: Cache libpq build
uses: actions/cache@v5
with:
path: /tmp/libpq.build
key: libpq-${{ matrix.platform }}-${{ matrix.arch }}-${{ env.LIBPQ_VERSION }}-${{ env.OPENSSL_VERSION }}${{ env.PQ_FLAGS }}
- name: Build wheels
uses: pypa/cibuildwheel@v3.4.1
env:
CIBW_SKIP: "cp31?t-*"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_I686_IMAGE: manylinux2014
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
CIBW_MANYLINUX_PPC64LE_IMAGE: manylinux2014
CIBW_MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64
CIBW_BUILD: cp313-${{matrix.platform}}_${{matrix.arch}}
CIBW_ARCHS_LINUX: auto aarch64 ppc64le riscv64
CIBW_BEFORE_ALL_LINUX: ./scripts/build/build_libpq.sh
CIBW_REPAIR_WHEEL_COMMAND: >-
./scripts/build/strip_wheel.sh {wheel}
&& auditwheel repair -w {dest_dir} {wheel}
CIBW_ENVIRONMENT_PASS_LINUX: LIBPQ_VERSION OPENSSL_VERSION
CIBW_ENVIRONMENT: >-
LIBPQ_BUILD_PREFIX=/host/tmp/libpq.build
PATH="$LIBPQ_BUILD_PREFIX/bin:$PATH"
LD_LIBRARY_PATH="$LIBPQ_BUILD_PREFIX/lib:$LIBPQ_BUILD_PREFIX/lib64"
# }}}
macos: # {{{
runs-on: macos-latest
if: true
strategy:
fail-fast: false
matrix:
arch: [x86_64, arm64]
steps:
- name: Checkout repos
uses: actions/checkout@v6
- name: Cache libpq build
uses: actions/cache@v5
with:
path: /tmp/libpq.build
key: libpq-macos-${{ env.LIBPQ_VERSION }}-${{ matrix.arch }}-${{ env.OPENSSL_VERSION }}${{ env.PQ_FLAGS }}
- name: Build wheels
uses: pypa/cibuildwheel@v3.4.1
env:
CIBW_SKIP: "cp31?t-*"
CIBW_BUILD: cp313-macosx_${{matrix.arch}}
CIBW_ARCHS_MACOS: ${{matrix.arch}}
MACOSX_ARCHITECTURE: ${{matrix.arch}}
CIBW_BEFORE_ALL_MACOS: ./scripts/build/build_libpq.sh
CIBW_ENVIRONMENT: >-
PSYCOPG_IMPL=binary
LIBPQ_BUILD_PREFIX=/tmp/libpq.build
PATH="$LIBPQ_BUILD_PREFIX/bin:$PATH"
# }}}