Packaging
This section explains how the valkey-glide (async client) and valkey-glide-sync (sync client) packages are built into Python wheels for local use and PyPI publishing.
Async Client (valkey-glide)
Section titled “Async Client (valkey-glide)”-
Stage shared code
Before packaging, we copy theglide-shared/glide_sharedpackage directory into theglide-async/python/folder. This ensures the shared code is included in the final wheel. -
Make it discoverable
Inglide-async/pyproject.toml, we add the appropriateincluderule under[tool.maturin]to make sure the copied files are bundled with the wheel. For example:include = ["python/glide_shared/**/*.py"] -
Build the wheel We use
maturin buildfrom theglide-asyncdirectory to create a Python wheel that includes the compiled Rust extension and all Python code. -
Multiplatform packaging for PyPI To publish wheels to PyPI, we use the
PyO3/maturin-actionGitHub Action, which builds manylinux and macOS wheels for different Python versions (both CPython and PyPy). This action runs in CI and uses prebuilt Docker containers for compatibility. -
Local testing You can test building a wheel and installing it locally using:
Terminal window python3 dev.py build --client async --wheel
Sync Client (valkey-glide-sync)
Section titled “Sync Client (valkey-glide-sync)”-
Vendoring dependencies (for both sdist and wheel)
During the build process (for both source distributions and wheels), we vendor (copy) all required Rust crates and Python modules into theglide-syncdirectory. This includes:- ffi
- glide-core
- logger_core
- glide_shared (Python module)
Vendoring ensures that all dependencies are self-contained within the package at build time, which is required for reproducible builds and compatibility with tools like cibuildwheel.
-
Build steps
- The necessary dependencies are vendored into the
glide-syncdirectory before the build starts. - We run
cargo buildin theglide-sync/ffi/folder to compile the Rust FFI library. - The resulting shared object file (e.g.
libglide_ffi.so) is copied into theglide-sync/glide_sync/directory. - We then build the Python package, either as a wheel or as an sdist.
- The necessary dependencies are vendored into the
-
Multiplatform packaging for PyPI
To support building wheels for multiple platforms (Linux, macOS, and different Python versions), we use thecibuildwheeltool.
This tool installs all required Python versions and runs the build inside isolated Docker containers (e.g., manylinux2014).
Because the sync client depends on external Rust code (glide-core,ffi,logger_core), we runcibuildwheelfrom the project root and specifypython/glide-syncas the build target.
This allows the tool to copy the full project context into the container. -
Local testing
You can building a wheel and install it locally using:Terminal window python3 dev.py build --client sync --wheel