Skip to content

Python language bindings #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 130 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
caed20a
Prototype Python bindings (draft)
jzombie May 18, 2025
4050900
Add maturin
jzombie May 18, 2025
c7d1573
Prototype directory layout
jzombie May 18, 2025
e2e87b9
Prototype directory structure
jzombie May 18, 2025
dd14e24
Prototype Rust bindings
jzombie May 19, 2025
a19a641
Add Python workflow
jzombie May 19, 2025
fb4ccce
Update Actions file
jzombie May 19, 2025
33a1e19
Prototype Actions
jzombie May 19, 2025
5098ad6
Prototype Actions
jzombie May 19, 2025
ec3077e
Prototype
jzombie May 19, 2025
a589cdd
Debug Actions
jzombie May 19, 2025
a80cde9
Install pre-requisite package
jzombie May 19, 2025
5dd0f8f
Update build-system dep
jzombie May 19, 2025
eb97f6d
Skip old Python versions
jzombie May 19, 2025
3108127
Update build system
jzombie May 19, 2025
a313e52
Install maturin
jzombie May 19, 2025
2b304b3
Remove incorrect manifest path
jzombie May 19, 2025
b05a10a
Skip pp38
jzombie May 19, 2025
3098d4e
Omit project section entirely
jzombie May 19, 2025
07de4df
Skip cp36
jzombie May 19, 2025
a7696d2
Skip *-manylinux_i686
jzombie May 19, 2025
0d631fb
Skip *-musllinux_*
jzombie May 19, 2025
cac1212
Add comment
jzombie May 19, 2025
8adc0fd
Use version parity
jzombie May 19, 2025
916e77e
Add preliminary Python tests
jzombie May 19, 2025
d3d8e61
Run platform-specific wheel
jzombie May 19, 2025
dc487e8
Use pytest
jzombie May 19, 2025
c14b9bf
Don't force pytest on everyone
jzombie May 19, 2025
786926d
Multi-platform detection
jzombie May 19, 2025
f7c1442
Add requirements-dev.txt
jzombie May 19, 2025
bc87bb5
Fix duplicate file path
jzombie May 19, 2025
33e45b1
Prototype Windows fix
jzombie May 19, 2025
9bd8a16
Debug test command
jzombie May 19, 2025
6a33161
Add additional assertion
jzombie May 19, 2025
124e694
Debug test commands
jzombie May 19, 2025
6851d7b
Debug test commands
jzombie May 19, 2025
eb104f7
Debug test commands
jzombie May 19, 2025
ab26cae
Add close method
jzombie May 19, 2025
41b466c
Use close methods
jzombie May 19, 2025
3e43316
Add comments
jzombie May 19, 2025
97024b6
Remove extra line break
jzombie May 19, 2025
671b136
Use binary keys (for parity with storage engine)
jzombie May 19, 2025
427de15
Rename data store for parity
jzombie May 19, 2025
8fb2638
Use common import names
jzombie May 19, 2025
070aa21
Add `read_entry`
jzombie May 19, 2025
d1827af
Update comment
jzombie May 19, 2025
da1e408
Add workarounds for Windows
jzombie May 19, 2025
4a85b43
Prototype `write_stream` implementation
jzombie May 19, 2025
88717bd
Add streaming support
jzombie May 19, 2025
03057e5
Use Arc Mutex
jzombie May 19, 2025
f5afa52
Workaround for `close`
jzombie May 19, 2025
91c213f
Add missing del call
jzombie May 19, 2025
c9d203e
Add note
jzombie May 19, 2025
754dce3
Slight clean-up
jzombie May 19, 2025
30f37d0
Draft README
jzombie May 19, 2025
749e7ba
Prototype publishing
jzombie May 19, 2025
ffccab5
Add tag-based CI runs
jzombie May 19, 2025
5294f25
Fix tag regex
jzombie May 19, 2025
1ffea59
Fix push conditions
jzombie May 19, 2025
b6b895b
Debug build conditions
jzombie May 19, 2025
987b6e6
Debug build conditions
jzombie May 19, 2025
9017bd1
Debug build conditions
jzombie May 19, 2025
fa12180
Adjust indentation level
jzombie May 19, 2025
ca14ee8
Test the README
jzombie May 19, 2025
5f5db74
Use common working directory
jzombie May 19, 2025
af825cf
Fix incorrect relative directory path
jzombie May 19, 2025
e7e70a9
Revert path change
jzombie May 19, 2025
8529326
Use env variable for `PYTHON_BINDING_DIR`
jzombie May 19, 2025
1371135
Rename `extensions` directory for consistency
jzombie May 19, 2025
18159ad
Use internal link
jzombie May 19, 2025
6eb50fd
Fix env var usage
jzombie May 19, 2025
7c88aea
Fix incorrect directory
jzombie May 19, 2025
23a06f8
Freeze packages
jzombie May 19, 2025
b3183f8
Move `.gitignore` into relevant directory
jzombie May 19, 2025
f33a2ad
Add trailing line break
jzombie May 19, 2025
9807046
Draft README updates
jzombie May 19, 2025
c8933c0
Update main README with experimental Python support
jzombie May 19, 2025
f68b3dc
Update sub-heading
jzombie May 19, 2025
13c8e58
Add payload assertion
jzombie May 19, 2025
463cb25
Use absolute link (issue rendering on `crates.io`)
jzombie May 19, 2025
765fc83
Revert "Use absolute link (issue rendering on `crates.io`)"
jzombie May 19, 2025
468c536
Fix incorrect .gitignore inclusion
jzombie May 19, 2025
5fcb1d7
Put `mmac_arc` behind feature flag
jzombie May 19, 2025
3700fd8
Add additional tests
jzombie May 19, 2025
d540032
Comment-out tests
jzombie May 19, 2025
3ebd586
Add `batch_write` and perf tests
jzombie May 19, 2025
61af628
Prevent perf tests from running by default
jzombie May 19, 2025
5f26654
Remove white-space
jzombie May 19, 2025
dd684fc
Add TODO
jzombie May 20, 2025
2bbf823
Improve formatting
jzombie May 20, 2025
13e292a
Update package info
jzombie May 20, 2025
508b72a
Debug test
jzombie May 20, 2025
a06dee5
Draft README
jzombie May 20, 2025
f429590
Rework README test strategy
jzombie May 20, 2025
9e0df6d
Debug tests
jzombie May 20, 2025
4ebee17
Remove TODOs
jzombie May 20, 2025
711e5e0
Add `EntryHandle` accessors
jzombie May 20, 2025
1b17977
Extract `EntryStream`
jzombie May 20, 2025
8429f91
Revert constants visibility change
jzombie May 20, 2025
f577f41
Use `Base*` prefix
jzombie May 20, 2025
b34c686
Fix incorrect workflow syntax
jzombie May 20, 2025
3e7db2b
Bump package versions
jzombie May 20, 2025
98871e0
Fix incorrect statement
jzombie May 20, 2025
333767d
Update README
jzombie May 20, 2025
1138972
Add section for supported environments
jzombie May 20, 2025
5e5830e
Fix batch write example and add test
jzombie May 20, 2025
221d304
Update streaming example
jzombie May 20, 2025
a582eb6
Use utf-8 encoding for README tests
jzombie May 20, 2025
0ee504f
Add TODO
jzombie May 20, 2025
363fc2d
Debug CI
jzombie May 20, 2025
0a382bb
Debug CI
jzombie May 20, 2025
bd50058
Remove ARM64 target
jzombie May 20, 2025
bb35a29
Force runner to only use x64 on Windows
jzombie May 20, 2025
2f8d0af
Remove duplicate build step
jzombie May 20, 2025
0050566
Update build strategy
jzombie May 20, 2025
2b79f18
Fix incorrect indentation level
jzombie May 20, 2025
4962fd8
Force Python to only build on x64
jzombie May 20, 2025
887704e
Redefine matrix
jzombie May 20, 2025
ed1ffbb
Disable win32
jzombie May 20, 2025
069e1f6
Force 64-bit on Windows
jzombie May 20, 2025
c8c1608
Skip win32 manually
jzombie May 20, 2025
377b612
Debug win32 skip
jzombie May 20, 2025
7514762
Revert previous and comment-out test
jzombie May 20, 2025
db0a371
Remove Windows entirely
jzombie May 20, 2025
c2e45b5
Update READMEs
jzombie May 20, 2025
4d452e5
Update README docs for Windows
jzombie May 20, 2025
de2308a
Add line break
jzombie May 20, 2025
5179791
Update arch list
jzombie May 20, 2025
6fb6826
Fix verbiage
jzombie May 20, 2025
1cd1823
Bump to Python 3.13
jzombie May 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .github/workflows/python-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Build Python Wheels

on:
push:
tags:
- "python-v*"
paths:
- "bindings/python/**"
pull_request:
paths:
- "bindings/python/**"

jobs:
build:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
# This was opted for instead of using `working-directory`, which breaks
# tools like `maturin` and `cibuildwheel` that expect the workspace root.
PYTHON_BINDING_DIR: bindings/python
strategy:
matrix:
include:
- os: ubuntu-latest
- os: macos-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install build tooling from requirements.txt
working-directory: ${{ env.PYTHON_BINDING_DIR }}
run: |
pip install -r "requirements.txt"
pip install -r "requirements-dev.txt"

# Note: Using `working-directory` here is problematic due to relative path linking
- name: Build wheels
env:
CIBW_SKIP: "cp36-* cp37-* cp38-* cp39-* pp* *-manylinux_i686 *-musllinux_*"
run: cibuildwheel "${{ env.PYTHON_BINDING_DIR }}" --output-dir "${{ env.PYTHON_BINDING_DIR }}/dist"

- name: Install built wheel and run tests
working-directory: ${{ env.PYTHON_BINDING_DIR }}
run: |

python -m pip install --find-links="dist" --prefer-binary simd_r_drive_py
python -m site
python extract_readme_tests.py
pytest --import-mode=importlib

- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: simd_r_drive_py-wheels-${{ matrix.os }}
path: ${{ env.PYTHON_BINDING_DIR }}/dist/*.whl

publish:
name: Upload wheels to PyPI
needs: build
runs-on: ubuntu-latest

# Accept tags like: python-v0.3.0-test or python-v0.3.0
# Example test tagging:
# git tag python-v0.3.0-test (or `*-test2`, etc)
# git push origin python-v0.3.0-test (or `*-test2`, etc)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/python-v')

steps:
- uses: actions/checkout@v4

- name: Download built wheels from all platforms
uses: actions/download-artifact@v4
with:
pattern: simd_r_drive_py-wheels-*
merge-multiple: true
path: dist

- name: Determine PyPI repository and token
id: pypi
run: |
if [[ "${GITHUB_REF}" == *-test* ]]; then
echo "url=https://test.pypi.org/legacy/" >> $GITHUB_OUTPUT
echo "token=${{ secrets.PYPI_TEST_API_TOKEN }}" >> $GITHUB_OUTPUT
else
echo "url=https://upload.pypi.org/legacy/" >> $GITHUB_OUTPUT
echo "token=${{ secrets.PYPI_API_TOKEN }}" >> $GITHUB_OUTPUT
fi

- name: Upload to PyPI (or Test PyPI)
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: ${{ steps.pypi.outputs.url }}
user: __token__
password: ${{ steps.pypi.outputs.token }}
7 changes: 2 additions & 5 deletions .github/workflows/rust-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ jobs:
- name: Build binary
run: cargo build --release

- name: Build binary
run: cargo build --release

- name: Rename binary for OS
shell: bash
run: |
Expand All @@ -42,15 +39,15 @@ jobs:
- name: Upload Artifact (Preview Binaries)
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.os }} # OS-specific artifact name
name: binaries-${{ matrix.os }} # OS-specific artifact name
path: dist/*

release:
name: Release Binaries
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@

# Used for debugging and experimentation
/data

out.txt
112 changes: 102 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "simd-r-drive"
authors = ["Jeremy Harris <jeremy.harris@zenosmosis.com>"]
version = "0.3.0-alpha.1"
version = "0.4.0-alpha"
edition = "2021"
description = "SIMD-optimized append-only schema-less storage engine. Key-based binary storage in a single-file storage container."
repository = "https://github.com/jzombie/rust-simd-r-drive"
Expand Down Expand Up @@ -43,9 +43,14 @@ features = ["rt-multi-thread", "macros", "time", "sync"]
name = "storage_benchmark"
harness = false

[features]
default = []
expose-internal-api = []

[workspace]
members = [
".",
"simd-r-drive-extensions"
"extensions",
"bindings/python"
]
resolver = "2"
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Can be used as a command line interface (CLI) app, or as a library in another ap
- [Streaming](#streaming)
- [SIMD Write & Query Acceleration](#simd-write--query-acceleration)
- [Extensions](#extensions)
- [Python Language Bindings](#python-language-bindings)
- [License](#license)


Expand Down Expand Up @@ -127,9 +128,9 @@ Because metadata is appended after each payload, there is no unnecessary seeking

Content retrieval is optimized using hashed keys, managed internally by a `HashMap` powered by the `xxh3_64` hashing algorithm. This algorithm takes advantage of hardware acceleration where available:

- SSE2 – Universally supported on x86_64, enabled by default.
- AVX2 – Offers additional performance gains on capable CPUs.
- Neon – Default on aarch64 targets, providing SIMD acceleration.
- `SSE2` – Universally supported on x86_64, enabled by default.
- `AVX2` – Offers additional performance gains on capable CPUs.
- `Neon` – Default on aarch64 targets, providing SIMD acceleration.

This indexing system works seamlessly with memory-mapped (`mmap`) pages, enabling high-speed random access. Benchmarks show that 1 million random seeks, retrieving 8-byte entries, typically complete in well under 1 second, demonstrating reasonable query performance.

Expand Down Expand Up @@ -220,7 +221,25 @@ By using SIMD for these performance-critical tasks, `SIMD R Drive` minimizes CPU

## Extensions

[SIMD R Drive Extensions](./simd-r-drive-extensions/) provide additional functionality.
[SIMD R Drive Extensions](./extensions/) provide additional functionality.

Here’s the updated **Python Language Bindings** section with an added sentence about platform support, consistent with your earlier README wording — professionally stated but firm:

---

## Python Language Bindings

[Experimental Python bindings](./bindings/python) are available for integrating with Python applications.

These bindings expose high-performance, zero-copy access to `SIMD R Drive` from Python using `PyO3` and `maturin`.

> ❌ **Python bindings for Windows is not supported** due to inconsistent file and memory-mapping semantics (though the bindings *can* build in Windows). These bindings target UNIX-like systems where `mmap` and thread behavior are reliable and consistent.
✅ The Rust library itself fully supports Windows, and is continuously tested on Windows targets.

Bindings are tested on:

* **Linux (x86\_64, aarch64)**
* **macOS (x86\_64, arm64/M1/M2)**

## License

Expand Down
Loading