Skip to content

Commit

Permalink
add sqlite-utils plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
asg017 committed Aug 6, 2023
1 parent 3e6a099 commit 3a16407
Show file tree
Hide file tree
Showing 9 changed files with 250 additions and 5 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ jobs:
- uses: actions/setup-python@v3
- run: pip install wheel
- run: make python
- run: make datasette
- uses: actions/upload-artifact@v3
with:
name: sqlite-http-linux_x86-wheels
Expand Down Expand Up @@ -68,7 +67,6 @@ jobs:
- uses: actions/setup-python@v3
- run: pip install wheel
- run: make python
- run: make datasette
- uses: actions/upload-artifact@v3
with:
name: sqlite-http-macos-wheels
Expand Down Expand Up @@ -134,11 +132,21 @@ jobs:
- uses: actions/setup-python@v3
- run: pip install wheel
- run: make python
- run: make datasette
- uses: actions/upload-artifact@v3
with:
name: sqlite-http-windows-wheels
path: dist/wheels/*.whl
build-datasette-sqlite-utils:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- run: pip install wheel build
- run: make datasette sqlite-utils
- uses: actions/upload-artifact@v3
with:
name: sqlite-http-datasette-sqlite-utils-wheels
path: dist/wheels/*.whl
upload-extensions:
name: Upload release assets
needs:
Expand Down Expand Up @@ -233,13 +241,14 @@ jobs:
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
upload_pypi:
upload-pypi:
needs:
[
build-linux_x86-python,
build-macos-python,
build-macos-arm-python,
build-windows-python,
build-datasette-sqlite-utils,
]
runs-on: ubuntu-latest
steps:
Expand All @@ -259,6 +268,10 @@ jobs:
with:
name: sqlite-http-macos-arm-wheels
path: dist
- uses: actions/download-artifact@v3
with:
name: sqlite-http-datasette-sqlite-utils-wheels
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
Expand Down
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ datasette: $(TARGET_WHEELS) $(shell find python/datasette_sqlite_http -type f -n
rm $(TARGET_WHEELS)/datasette* || true
pip3 wheel python/datasette_sqlite_http/ --no-deps -w $(TARGET_WHEELS)

bindings/sqlite-utils/pyproject.toml: bindings/sqlite-utils/pyproject.toml.tmpl VERSION
VERSION=$(VERSION) envsubst < $< > $@
echo "✅ generated $@"

bindings/sqlite-utils/sqlite_utils_sqlite_http/version.py: bindings/sqlite-utils/sqlite_utils_sqlite_http/version.py.tmpl VERSION
VERSION=$(VERSION) envsubst < $< > $@
echo "✅ generated $@"

sqlite-utils: $(TARGET_WHEELS) bindings/sqlite-utils/pyproject.toml bindings/sqlite-utils/sqlite_utils_sqlite_http/version.py
python3 -m build bindings/sqlite-utils -w -o $(TARGET_WHEELS)

npm: VERSION npm/platform-package.README.md.tmpl npm/platform-package.package.json.tmpl npm/sqlite-http/package.json.tmpl scripts/npm_generate_platform_packages.sh
scripts/npm_generate_platform_packages.sh

Expand All @@ -102,6 +113,7 @@ ruby: bindings/ruby/lib/version.rb
version:
make python
make python-versions
make bindings/sqlite-utils/pyproject.toml bindings/sqlite-utils/sqlite_utils_sqlite_http/version.py
make npm
make deno
make ruby
Expand Down Expand Up @@ -148,6 +160,6 @@ publish-release:
./scripts/publish_release.sh

.PHONY: all format clean publish-release \
python python-versions datasette npm deno ruby version \
python python-versions datasette sqlite-utils npm deno ruby version \
test test-loadable test-watch httpbin \
loadable
160 changes: 160 additions & 0 deletions bindings/sqlite-utils/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
3 changes: 3 additions & 0 deletions bindings/sqlite-utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `sqlite-utils-sqlite-http`

A `sqlite-utils` plugin that registers the `sqlite-http` extension.
21 changes: 21 additions & 0 deletions bindings/sqlite-utils/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[project]
name = "sqlite-utils-sqlite-http"
version = "0.1.0"
description = "TODO"
readme = "README.md"
authors = [{name = "Alex Garcia"}]
license = {text = "Apache-2.0"}
classifiers = []

dependencies = [
"sqlite-utils",
"sqlite-http"
]

[project.urls]
Homepage = "https://github.com/asg017/sqlite-http"
Changelog = "https://github.com/asg017/sqlite-http/releases"
Issues = "https://github.com/asg017/sqlite-http/issues"

[project.entry-points.sqlite_utils]
sqlite_http = "sqlite_utils_sqlite_http"
21 changes: 21 additions & 0 deletions bindings/sqlite-utils/pyproject.toml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[project]
name = "sqlite-utils-sqlite-http"
version = "${VERSION}"
description = "TODO"
readme = "README.md"
authors = [{name = "Alex Garcia"}]
license = {text = "Apache-2.0"}
classifiers = []

dependencies = [
"sqlite-utils",
"sqlite-http"
]

[project.urls]
Homepage = "https://github.com/asg017/sqlite-http"
Changelog = "https://github.com/asg017/sqlite-http/releases"
Issues = "https://github.com/asg017/sqlite-http/issues"

[project.entry-points.sqlite_utils]
sqlite_http = "sqlite_utils_sqlite_http"
11 changes: 11 additions & 0 deletions bindings/sqlite-utils/sqlite_utils_sqlite_http/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from sqlite_utils import hookimpl
import sqlite_http

from sqlite_utils_sqlite_http.version import __version_info__, __version__


@hookimpl
def prepare_connection(conn):
conn.enable_load_extension(True)
sqlite_http.load(conn)
conn.enable_load_extension(False)
2 changes: 2 additions & 0 deletions bindings/sqlite-utils/sqlite_utils_sqlite_http/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__version__ = "0.2.1"
__version_info__ = tuple(__version__.split("."))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__version__ = "${VERSION}"
__version_info__ = tuple(__version__.split("."))

0 comments on commit 3a16407

Please sign in to comment.