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 2535b3f commit 4b840aa
Show file tree
Hide file tree
Showing 10 changed files with 255 additions and 6 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ env:
ARTIFACT-LINUX-X86_64-WHEELS: sqlite-vss-linux-x86_64-wheels
ARTIFACT-MACOS-X86_64-WHEELS: sqlite-vss-macos-x86_64-wheels
ARTIFACT-MACOS-AARCH64-WHEELS: sqlite-vss-macos-aarch64-wheels
ARTIFACT-DATASETTE-SQLITE-UTILS-WHEELS: sqlite-vss-datasette-sqlite-utils-wheels
jobs:
build-linux-x86_64-extension:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -50,7 +51,6 @@ jobs:
- uses: actions/setup-python@v3
- run: pip install wheel
- run: make python-release
- run: make datasette-release
- uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT-LINUX-X86_64-WHEELS }}
Expand Down Expand Up @@ -101,7 +101,6 @@ jobs:
- uses: actions/setup-python@v3
- run: pip install wheel
- run: make python-release
- run: make datasette-release
- uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT-MACOS-X86_64-WHEELS }}
Expand Down Expand Up @@ -145,11 +144,21 @@ jobs:
path: dist/release/
- run: pip3 install wheel
- run: make python-release IS_MACOS_ARM=1
- run: make datasette-release
- uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT-MACOS-AARCH64-WHEELS }}
path: dist/release/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-release sqlite-utils-release
- uses: actions/upload-artifact@v3
with:
name: ${{ ENV.ARTIFACT-DATASETTE-SQLITE-UTILS-WHEELS }}
path: dist/release/wheels/*.whl
upload-deno:
needs:
[
Expand Down Expand Up @@ -291,6 +300,7 @@ jobs:
build-linux-x86_64-python,
build-macos-x86_64-python,
build-macos-aarch64-python,
build-datasette-sqlite-utils,
]
runs-on: ubuntu-latest
steps:
Expand All @@ -306,6 +316,10 @@ jobs:
with:
name: ${{ env.ARTIFACT-MACOS-AARCH64-WHEELS }}
path: dist
- uses: actions/download-artifact@v3
with:
name: ${{ ENV.ARTIFACT-DATASETTE-SQLITE-UTILS-WHEELS }}
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
Expand Down
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,20 @@ datasette-release: $(TARGET_WHEELS_RELEASE) bindings/datasette/setup.py bindings
rm $(TARGET_WHEELS_RELEASE)/datasette* || true
pip3 wheel bindings/datasette/ --no-deps -w $(TARGET_WHEELS_RELEASE)

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

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

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

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

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

Expand Down Expand Up @@ -182,6 +196,7 @@ elixir: bindings/elixir/VERSION
version:
make python-versions
make python
make bindings/sqlite-utils/pyproject.toml bindings/sqlite-utils/sqlite_utils_sqlite_vss/version.py
make npm
make deno
make bindings/ruby/lib/version.rb
Expand Down Expand Up @@ -230,4 +245,4 @@ publish-release:
loadable loadable-release static static-release \
publish-release \
patch-openmp patch-openmp-undo \
python python-release python-versions datasette elixir npm deno go rust version
python python-release python-versions datasette sqlite-utils sqlite-utils-release elixir npm deno go rust version
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ npm install sqlite-vss

```js
import Database from "better-sqlite3"; // also compatible with node-sqlite3
import * as sqlite_vss from "sqlite-ulid";
import * as sqlite_vss from "sqlite-vss";

const db = new Database(":memory:");
sqlite_ulid.load(db);
sqlite_vss.load(db);

const version = db.prepare("select vss_version()").pluck().get();
console.log(version);
Expand Down
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-vss`

A `sqlite-utils` plugin that registers the `sqlite-vss` 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-vss"
version = "0.1.2-alpha.2"
description = "TODO"
readme = "README.md"
authors = [{name = "Alex Garcia"}]
license = {text = "Apache-2.0"}
classifiers = []

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

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

[project.entry-points.sqlite_utils]
sqlite_vss = "sqlite_utils_sqlite_vss"
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-vss"
version = "${VERSION}"
description = "TODO"
readme = "README.md"
authors = [{name = "Alex Garcia"}]
license = {text = "Apache-2.0"}
classifiers = []

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

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

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

from sqlite_utils_sqlite_vss.version import __version_info__, __version__


@hookimpl
def prepare_connection(conn):
conn.enable_load_extension(True)
sqlite_vss.load(conn)
conn.enable_load_extension(False)
2 changes: 2 additions & 0 deletions bindings/sqlite-utils/sqlite_utils_sqlite_vss/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("."))
2 changes: 2 additions & 0 deletions bindings/sqlite-utils/sqlite_utils_sqlite_vss/version.py.tmpl
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 4b840aa

Please sign in to comment.