Skip to content

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.

  1. Stage shared code
    Before packaging, we copy the glide-shared/glide_shared package directory into the glide-async/python/ folder. This ensures the shared code is included in the final wheel.

  2. Make it discoverable
    In glide-async/pyproject.toml, we add the appropriate include rule under [tool.maturin] to make sure the copied files are bundled with the wheel. For example:

    include = ["python/glide_shared/**/*.py"]
  3. Build the wheel We use maturin build from the glide-async directory to create a Python wheel that includes the compiled Rust extension and all Python code.

  4. Multiplatform packaging for PyPI To publish wheels to PyPI, we use the PyO3/maturin-action GitHub 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.

  5. Local testing You can test building a wheel and installing it locally using:

    Terminal window
    python3 dev.py build --client async --wheel
  1. 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 the glide-sync directory. 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.

  2. Build steps

    • The necessary dependencies are vendored into the glide-sync directory before the build starts.
    • We run cargo build in the glide-sync/ffi/ folder to compile the Rust FFI library.
    • The resulting shared object file (e.g. libglide_ffi.so) is copied into the glide-sync/glide_sync/ directory.
    • We then build the Python package, either as a wheel or as an sdist.
  3. Multiplatform packaging for PyPI
    To support building wheels for multiple platforms (Linux, macOS, and different Python versions), we use the cibuildwheel tool.
    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 run cibuildwheel from the project root and specify python/glide-sync as the build target.
    This allows the tool to copy the full project context into the container.

  4. Local testing
    You can building a wheel and install it locally using:

    Terminal window
    python3 dev.py build --client sync --wheel