Skip to content

Commit 9f079c0

Browse files
authored
Make sqlite-regex pip-installable (#2)
1 parent 60db990 commit 9f079c0

File tree

16 files changed

+764
-41
lines changed

16 files changed

+764
-41
lines changed

.github/workflows/release.yaml

Lines changed: 121 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
name: "release"
1+
name: "Release"
22
on:
33
release:
44
types: [published]
55
workflow_dispatch:
66
permissions:
77
contents: read
88
jobs:
9-
build-ubuntu:
10-
name: Build ubuntu-20.04
11-
runs-on: ubuntu-20.04
9+
build-ubuntu-extension:
10+
name: Build ubuntu
11+
runs-on: ubuntu-18.04
1212
steps:
1313
- uses: actions/checkout@v2
1414
- uses: actions/cache@v3
@@ -29,7 +29,25 @@ jobs:
2929
with:
3030
name: sqlite-regex-ubuntu
3131
path: dist/release/regex0.so
32-
build-macos:
32+
build-ubuntu-python:
33+
runs-on: ubuntu-18.04
34+
needs: [build-ubuntu-extension]
35+
steps:
36+
- uses: actions/checkout@v3
37+
- name: Download workflow artifacts
38+
uses: actions/download-artifact@v3
39+
with:
40+
name: sqlite-regex-ubuntu
41+
path: dist/release/
42+
- uses: actions/setup-python@v3
43+
- run: pip install wheel
44+
- run: make python-release
45+
- run: make datasette-release
46+
- uses: actions/upload-artifact@v3
47+
with:
48+
name: sqlite-regex-ubuntu-wheels
49+
path: dist/release/wheels/*.whl
50+
build-macos-extension:
3351
name: Build macos-latest
3452
runs-on: macos-latest
3553
steps:
@@ -52,7 +70,25 @@ jobs:
5270
with:
5371
name: sqlite-regex-macos
5472
path: dist/release/regex0.dylib
55-
build-macos-arm:
73+
build-macos-python:
74+
runs-on: macos-latest
75+
needs: [build-macos-extension]
76+
steps:
77+
- uses: actions/checkout@v3
78+
- name: Download workflow artifacts
79+
uses: actions/download-artifact@v3
80+
with:
81+
name: sqlite-regex-macos
82+
path: dist/release/
83+
- uses: actions/setup-python@v3
84+
- run: pip install wheel
85+
- run: make python-release
86+
- run: make datasette-release
87+
- uses: actions/upload-artifact@v3
88+
with:
89+
name: sqlite-regex-macos-wheels
90+
path: dist/release/wheels/*.whl
91+
build-macos-arm-extension:
5692
name: Build macos-latest with arm
5793
runs-on: macos-latest
5894
steps:
@@ -70,14 +106,31 @@ jobs:
70106
with:
71107
toolchain: stable
72108
- run: rustup target add aarch64-apple-darwin
73-
- run: make target=aarch64-apple-darwin loadable
74-
#- run: make test
109+
- run: make loadable-release target=aarch64-apple-darwin
75110
- name: Upload artifacts
76111
uses: actions/upload-artifact@v3
77112
with:
78113
name: sqlite-regex-macos-arm
79-
path: dist/debug/regex0.dylib
80-
build-windows:
114+
path: dist/release/regex0.dylib
115+
build-macos-arm-python:
116+
runs-on: macos-latest
117+
needs: [build-macos-arm-extension]
118+
steps:
119+
- uses: actions/checkout@v3
120+
- name: Download workflow artifacts
121+
uses: actions/download-artifact@v3
122+
with:
123+
name: sqlite-regex-macos-arm
124+
path: dist/release/
125+
- uses: actions/setup-python@v3
126+
- run: pip install wheel
127+
- run: make python-release IS_MACOS_ARM=1
128+
- run: make datasette-release
129+
- uses: actions/upload-artifact@v3
130+
with:
131+
name: sqlite-regex-macos-arm-wheels
132+
path: dist/release/wheels/*.whl
133+
build-windows-extension:
81134
name: Build windows-latest
82135
runs-on: windows-latest
83136
steps:
@@ -100,19 +153,74 @@ jobs:
100153
with:
101154
name: sqlite-regex-windows
102155
path: dist/release/regex0.dll
103-
upload:
104-
name: upload
105-
needs: [build-macos, build-macos-arm, build-ubuntu, build-windows]
156+
build-windows-python:
157+
runs-on: windows-latest
158+
needs: [build-windows-extension]
159+
steps:
160+
- uses: actions/checkout@v3
161+
- name: Download workflow artifacts
162+
uses: actions/download-artifact@v3
163+
with:
164+
name: sqlite-regex-windows
165+
path: dist/release/
166+
- uses: actions/setup-python@v3
167+
- run: pip install wheel
168+
- run: make python-release
169+
- run: make datasette-release
170+
- uses: actions/upload-artifact@v3
171+
with:
172+
name: sqlite-regex-windows-wheels
173+
path: dist/release/wheels/*.whl
174+
upload-release-assets:
175+
name: Upload release assets
176+
needs:
177+
[
178+
build-macos-extension,
179+
build-macos-arm-extension,
180+
build-ubuntu-extension,
181+
build-windows-extension,
182+
]
106183
permissions:
107184
contents: write
108185
runs-on: ubuntu-latest
109186
steps:
110187
- uses: actions/checkout@v2
111188
- name: Download workflow artifacts
112189
uses: actions/download-artifact@v2
190+
- run: npm install tar-fs
113191
- uses: actions/github-script@v6
114192
with:
115193
github-token: ${{ secrets.GITHUB_TOKEN }}
116194
script: |
117195
const script = require('.github/workflows/upload.js')
118196
await script({github, context})
197+
upload_pypi:
198+
needs:
199+
[
200+
build-ubuntu-python,
201+
build-macos-python,
202+
build-macos-arm-python,
203+
build-windows-python,
204+
]
205+
runs-on: ubuntu-latest
206+
steps:
207+
- uses: actions/download-artifact@v3
208+
with:
209+
name: sqlite-regex-windows-wheels
210+
path: dist
211+
- uses: actions/download-artifact@v3
212+
with:
213+
name: sqlite-regex-ubuntu-wheels
214+
path: dist
215+
- uses: actions/download-artifact@v3
216+
with:
217+
name: sqlite-regex-macos-wheels
218+
path: dist
219+
- uses: actions/download-artifact@v3
220+
with:
221+
name: sqlite-regex-macos-arm-wheels
222+
path: dist
223+
- uses: pypa/gh-action-pypi-publish@release/v1
224+
with:
225+
password: ${{ secrets.PYPI_API_TOKEN }}
226+
skip_existing: true

.github/workflows/rename-wheels.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This file is a small utility that rename all .whl files in a given directory
2+
# and "generalizes" them. The wheels made by python/sqlite_ulid contain the
3+
# pre-compiled sqlite extension, but those aren't bound by a specfic Python
4+
# runtime or version, that other wheels might be. So, this file will rename
5+
# those wheels to be "generalized", like replacing "c37-cp37" to "py3-none".
6+
import sys
7+
import os
8+
from pathlib import Path
9+
10+
wheel_dir = sys.argv[1]
11+
12+
is_macos_arm_build = '--is-macos-arm' in sys.argv
13+
14+
for filename in os.listdir(wheel_dir):
15+
filename = Path(wheel_dir, filename)
16+
if not filename.suffix == '.whl':
17+
continue
18+
new_filename = (filename.name
19+
.replace('cp37-cp37', 'py3-none')
20+
.replace('cp38-cp38', 'py3-none')
21+
.replace('cp39-cp39', 'py3-none')
22+
.replace('cp310-cp310', 'py3-none')
23+
.replace('cp311-cp311', 'py3-none')
24+
.replace('linux_x86_64', 'manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux1_x86_64')
25+
26+
27+
)
28+
if is_macos_arm_build:
29+
new_filename = new_filename.replace('macosx_12_0_universal2', 'macosx_11_0_arm64')
30+
else:
31+
new_filename = (new_filename
32+
.replace('macosx_12_0_universal2', 'macosx_10_6_x86_64')
33+
.replace('macosx_12_0_x86_64', 'macosx_10_6_x86_64')
34+
)
35+
36+
os.rename(filename, Path(wheel_dir, new_filename))

0 commit comments

Comments
 (0)