Skip to content

Commit edc63ef

Browse files
committed
feat: sqlite-utils plugin
1 parent c7cf219 commit edc63ef

File tree

9 files changed

+255
-10
lines changed

9 files changed

+255
-10
lines changed

.github/workflows/release.yaml

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ jobs:
4242
- uses: actions/setup-python@v3
4343
- run: pip install wheel
4444
- run: make python-release
45-
- run: make datasette-release
4645
- uses: actions/upload-artifact@v3
4746
with:
4847
name: sqlite-regex-ubuntu-wheels
@@ -83,7 +82,6 @@ jobs:
8382
- uses: actions/setup-python@v3
8483
- run: pip install wheel
8584
- run: make python-release
86-
- run: make datasette-release
8785
- uses: actions/upload-artifact@v3
8886
with:
8987
name: sqlite-regex-macos-wheels
@@ -125,7 +123,6 @@ jobs:
125123
- uses: actions/setup-python@v3
126124
- run: pip install wheel
127125
- run: make python-release IS_MACOS_ARM=1
128-
- run: make datasette-release
129126
- uses: actions/upload-artifact@v3
130127
with:
131128
name: sqlite-regex-macos-arm-wheels
@@ -166,11 +163,21 @@ jobs:
166163
- uses: actions/setup-python@v3
167164
- run: pip install wheel
168165
- run: make python-release
169-
- run: make datasette-release
170166
- uses: actions/upload-artifact@v3
171167
with:
172168
name: sqlite-regex-windows-wheels
173169
path: dist/release/wheels/*.whl
170+
build-datasette-sqlite-utils:
171+
runs-on: ubuntu-20.04
172+
steps:
173+
- uses: actions/checkout@v3
174+
- uses: actions/setup-python@v3
175+
- run: pip install wheel build
176+
- run: make datasette-release sqlite-utils-release
177+
- uses: actions/upload-artifact@v3
178+
with:
179+
name: sqlite-regex-datasette-sqlite-utils-wheels
180+
path: dist/wheels/*.whl
174181
upload-crate:
175182
runs-on: ubuntu-latest
176183
steps:
@@ -277,12 +284,13 @@ jobs:
277284
env:
278285
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
279286
upload-gem:
280-
needs: [
281-
build-macos-extension,
282-
build-macos-arm-extension,
283-
build-ubuntu-extension,
284-
build-windows-extension,
285-
]
287+
needs:
288+
[
289+
build-macos-extension,
290+
build-macos-arm-extension,
291+
build-ubuntu-extension,
292+
build-windows-extension,
293+
]
286294
permissions:
287295
contents: write
288296
runs-on: ubuntu-latest
@@ -330,6 +338,7 @@ jobs:
330338
build-macos-python,
331339
build-macos-arm-python,
332340
build-windows-python,
341+
build-datasette-sqlite-utils,
333342
]
334343
runs-on: ubuntu-latest
335344
steps:
@@ -349,6 +358,10 @@ jobs:
349358
with:
350359
name: sqlite-regex-macos-arm-wheels
351360
path: dist
361+
- uses: actions/download-artifact@v3
362+
with:
363+
name: sqlite-regex-datasette-sqlite-utils-wheels
364+
path: dist
352365
- uses: pypa/gh-action-pypi-publish@release/v1
353366
with:
354367
password: ${{ secrets.PYPI_API_TOKEN }}

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ datasette-release: $(TARGET_WHEELS_RELEASE) python/datasette_sqlite_regex/setup.
9595
rm $(TARGET_WHEELS_RELEASE)/datasette* || true
9696
pip3 wheel python/datasette_sqlite_regex/ --no-deps -w $(TARGET_WHEELS_RELEASE)
9797

98+
bindings/sqlite-utils/sqlite_utils_sqlite_regex/version.py: bindings/sqlite-utils/sqlite_utils_sqlite_regex/version.py.tmpl VERSION
99+
VERSION=$(VERSION) envsubst < $< > $@
100+
echo "✅ generated $@"
101+
102+
sqlite-utils: $(TARGET_WHEELS) bindings/sqlite-utils/pyproject.toml bindings/sqlite-utils/sqlite_utils_sqlite_regex/version.py
103+
python3 -m build bindings/sqlite-utils -w -o $(TARGET_WHEELS)
104+
105+
sqlite-utils-release: $(TARGET_WHEELS) bindings/sqlite-utils/pyproject.toml bindings/sqlite-utils/sqlite_utils_sqlite_regex/version.py
106+
python3 -m build bindings/sqlite-utils -w -o $(TARGET_WHEELS)
107+
98108
npm: VERSION npm/platform-package.README.md.tmpl npm/platform-package.package.json.tmpl npm/sqlite-regex/package.json.tmpl scripts/npm_generate_platform_packages.sh
99109
scripts/npm_generate_platform_packages.sh
100110

@@ -119,6 +129,7 @@ version:
119129
make Cargo.toml
120130
make python/sqlite_regex/sqlite_regex/version.py
121131
make python/datasette_sqlite_regex/datasette_sqlite_regex/version.py
132+
make bindings/sqlite-utils/pyproject.toml bindings/sqlite-utils/sqlite_utils_sqlite_regex/version.py
122133
make npm
123134
make deno
124135
make ruby
@@ -171,6 +182,7 @@ publish-release:
171182
loadable loadable-release \
172183
python python-release \
173184
datasette datasette-release \
185+
sqlite-utils sqlite-utils-release \
174186
static static-release \
175187
debug release \
176188
format version publish-release \

bindings/sqlite-utils/.gitignore

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# poetry
98+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102+
#poetry.lock
103+
104+
# pdm
105+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106+
#pdm.lock
107+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108+
# in version control.
109+
# https://pdm.fming.dev/#use-with-ide
110+
.pdm.toml
111+
112+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113+
__pypackages__/
114+
115+
# Celery stuff
116+
celerybeat-schedule
117+
celerybeat.pid
118+
119+
# SageMath parsed files
120+
*.sage.py
121+
122+
# Environments
123+
.env
124+
.venv
125+
env/
126+
venv/
127+
ENV/
128+
env.bak/
129+
venv.bak/
130+
131+
# Spyder project settings
132+
.spyderproject
133+
.spyproject
134+
135+
# Rope project settings
136+
.ropeproject
137+
138+
# mkdocs documentation
139+
/site
140+
141+
# mypy
142+
.mypy_cache/
143+
.dmypy.json
144+
dmypy.json
145+
146+
# Pyre type checker
147+
.pyre/
148+
149+
# pytype static type analyzer
150+
.pytype/
151+
152+
# Cython debug symbols
153+
cython_debug/
154+
155+
# PyCharm
156+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158+
# and can be added to the global gitignore or merged into this file. For a more nuclear
159+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160+
#.idea/

bindings/sqlite-utils/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `sqlite-utils-sqlite-regex`
2+
3+
A `sqlite-utils` plugin that registers the `sqlite-regex` extension.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[project]
2+
name = "sqlite-utils-sqlite-hello"
3+
version = "0.1.0-alpha.61"
4+
description = "TODO"
5+
readme = "README.md"
6+
authors = [{name = "Alex Garcia"}]
7+
license = {text = "Apache-2.0"}
8+
classifiers = []
9+
10+
dependencies = [
11+
"sqlite-utils",
12+
"sqlite-hello"
13+
]
14+
15+
[project.urls]
16+
Homepage = "https://github.com/asg017/sqlite-hello"
17+
Changelog = "https://github.com/asg017/sqlite-hello/releases"
18+
Issues = "https://github.com/asg017/sqlite-hello/issues"
19+
20+
[project.entry-points.sqlite_utils]
21+
sqlite_hello = "sqlite_utils_sqlite_hello"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[project]
2+
name = "sqlite-utils-sqlite-regex"
3+
version = "${VERSION}"
4+
description = "TODO"
5+
readme = "README.md"
6+
authors = [{name = "Alex Garcia"}]
7+
license = {text = "Apache-2.0"}
8+
classifiers = []
9+
10+
dependencies = [
11+
"sqlite-utils",
12+
"sqlite-regex"
13+
]
14+
15+
[project.urls]
16+
Homepage = "https://github.com/asg017/sqlite-regex"
17+
Changelog = "https://github.com/asg017/sqlite-regex/releases"
18+
Issues = "https://github.com/asg017/sqlite-regex/issues"
19+
20+
[project.entry-points.sqlite_utils]
21+
sqlite_regex = "sqlite_utils_sqlite_regex"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from sqlite_utils import hookimpl
2+
import sqlite_regex
3+
4+
from sqlite_utils_sqlite_regex.version import __version_info__, __version__
5+
6+
7+
@hookimpl
8+
def prepare_connection(conn):
9+
conn.enable_load_extension(True)
10+
sqlite_regex.load(conn)
11+
conn.enable_load_extension(False)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__version__ = "0.1.0-alpha.61"
2+
__version_info__ = tuple(__version__.split("."))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__version__ = "${VERSION}"
2+
__version_info__ = tuple(__version__.split("."))

0 commit comments

Comments
 (0)