diff --git a/.github/workflows/pypi_release.yml b/.github/workflows/pypi_release.yml new file mode 100644 index 0000000..d46e02b --- /dev/null +++ b/.github/workflows/pypi_release.yml @@ -0,0 +1,80 @@ +name: Publish to PyPI + +on: + push: + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-20.04, windows-2019, macos-11] + env: + CIBW_BEFORE_ALL_LINUX: "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y" + CIBW_BUILD_VERBOSITY: "1" + CIBW_SKIP: cp39-musllinux_i686 cp310-musllinux_i686 cp311-musllinux_i686 cp312-musllinux_i686 # Can't install Rust on musl based Linux systems + CIBW_ENVIRONMENT: 'PATH="$PATH:$HOME/.cargo/bin"' + + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + if: runner.os == 'Linux' + uses: docker/setup-qemu-action@v1 + with: + platforms: all + + - name: Build wheels + uses: pypa/cibuildwheel@v2.16.2 + with: + package-dir: ./python + output-dir: ./python/wheelhouse + + - uses: actions/upload-artifact@v3 + with: + name: wheel-${{ runner.os }} + path: ./python/wheelhouse/*.whl + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Install rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + + - uses: actions/setup-python@v2 + name: Install Python + with: + python-version: "3.9" + + - name: Build sdist + run: | + python -m pip install setuptools-rust setuptools wheel + cd python/ + python setup.py sdist + + - uses: actions/upload-artifact@v2 + with: + name: sdist-${{ runner.os }} + path: python/dist/*.tar.gz + +# release: +# needs: [build_wheels, build_sdist] +# runs-on: ubuntu-latest +# steps: +# - uses: actions/download-artifact@v2 +# with: +# name: artifact +# path: python/dist + +# - uses: pypa/gh-action-pypi-publish@release/v1 +# with: +# packages-dir: python/dist/ +# user: __token__ +# password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/python/README.md b/python/README.md new file mode 100644 index 0000000..ac796f2 --- /dev/null +++ b/python/README.md @@ -0,0 +1,22 @@ +# sqlite-zstd +Extension for sqlite that provides transparent dictionary-based row-level compression for sqlite. This basically allows you to compress entries in a sqlite database almost as well as if you were compressing the whole DB file, but while retaining random access. + +See also the announcement blog post for some motivation, benchmarks and ramblings: https://phiresky.github.io/blog/2022/sqlite-zstd + +Depending on the data, this can reduce the size of the database by 80% while keeping performance mostly the same (or even improving it, since the data to be read from disk is smaller). + +Note that a compression VFS such as https://github.com/mlin/sqlite_zstd_vfs might be suited better depending on the use case. That has very different tradeoffs and capabilities, but the end result is similar. + +## Install +```bash +pip install sqlite-zstd +``` + +## Usage +```python +import sqlite3 +import sqlite_zstd + +conn = sqlite3.connect(':memory:') +sqlite_zstd.load(conn) +``` diff --git a/python/pyproject.toml b/python/pyproject.toml index 2bf7023..ff915b9 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -7,6 +7,10 @@ name = "sqlite-zstd" requires-python = ">=3.9" dynamic = ["version"] +[project.readme] +file = "README.md" +content-type = "text/markdown" + [project.entry-points.datasette] sqlite_zstd = "sqlite_zstd.datasette"