Metadata-Version: 2.4
Name: speedupy-native
Version: 0.1.0
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: MacOS
Classifier: Topic :: Software Development :: Libraries
License-File: LICENSE
License-File: NOTICE
Summary: Prebuilt native hash functions for SpeeduPy: a5hash, MeowHash 0.5 and MuseAir BFast
License-Expression: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Documentation, https://github.com/dew-uff/speedupy/blob/main/docs/native-hashes.md
Project-URL: Repository, https://github.com/dew-uff/speedupy-native

# speedupy-native

Prebuilt native hash functions for [SpeeduPy](https://github.com/dew-uff/speedupy):
a5hash, MeowHash 0.5 and MuseAir BFast, as one Python extension with wheels for
Linux (x86_64, aarch64), Windows (x64) and macOS (Intel, Apple Silicon).
`pip install speedupy` brings it in; nothing is compiled on the user's machine.

```python
import speedupy_native as native

native.a5hash_128_64(b"abc")          # lower 64 bits of a5hash-128, seed 0
native.museair_bfast_64(b"abc")       # MuseAir BFast, 64-bit, seed 0
native.meowhash_32(b"abc")            # MeowHash 0.5, lower 32 bits, default seed
native.HAS_MEOWHASH                   # False on arm64 and on x86_64 without AES-NI
native.PLATFORM                       # "linux-x86_64", "macos-aarch64", ...
```

The functions take `bytes` and return the integers the original `ctypes`
wrappers of SpeeduPy returned, computed from the same sources at the same
commits (`NOTICE`). `tests/test_vectors.py` holds reference values produced
from those original shared libraries; every wheel must reproduce them on its
own platform before it is released.

MeowHash exists for x86_64 with AES-NI only; its official implementation has no
ARM port. On other platforms `HAS_MEOWHASH` is false and `meowhash_32` raises
`RuntimeError`; the other hashes work everywhere.

Design and rationale: `docs/native-hashes.md` in the SpeeduPy repository
(decision D3 of the retrofit).

## Layout

```
Cargo.toml, build.rs, src/lib.rs   the extension (Rust, PyO3; build.rs compiles the C/C++ wrappers)
crates/museair/Cargo.toml          bridge manifest that builds vendor/museair as a Rust library
python/speedupy_native/            the Python package
vendor/{a5hash,meow_hash,museair}  git submodules, pinned (see NOTICE)
tests/test_vectors.py              reference values; generated by tools/gen_vectors.py
.github/workflows/release.yml      wheels for every platform, tests, release to PyPI on a tag
```

## Developing

Needs Rust (`rustup`), a C and C++ compiler, Python 3.10 or newer and
[maturin](https://www.maturin.rs) (`uv tool install maturin`). No Docker.

```bash
git clone --recurse-submodules https://github.com/dew-uff/speedupy-native
cd speedupy-native
uv venv && source .venv/bin/activate
maturin develop --release
uv pip install pytest && pytest -q
```

`maturin build --release` writes the wheel of this machine to `target/wheels/`.

The reference values are regenerated only when a vendored commit changes, from
the original `.so` libraries built from that commit on Linux x86_64:
`python tools/gen_vectors.py <dir with liba5hash.so libmeow.so libmuseair.so> > tests/test_vectors.py`.
A change in the values is a new hash to SpeeduPy's users, not a bug fix: it is
at least a minor version and is written in the release notes.

## Releasing

Tags are SemVer without a `v` (`0.1.0`). A pushed tag builds every wheel, runs
the tests on each platform, attests the artifacts and publishes to PyPI with
Trusted Publishing: the PyPI project lists this repository, this workflow file
and the `pypi` environment as its publisher, and no token is stored. SpeeduPy
pins the exact version in its dependencies; bumping it there is a pull request
of its own.

