Wrap Go binaries in Python wheels

· devtools open-source · Source ↗

TLDR

  • go-to-wheel cross-compiles a Go module for 8 platforms and packages each binary as a pip-installable Python wheel with correct platform tags.

Key Takeaways

  • Runs GOOS/GOARCH cross-compilation with CGO_ENABLED=0 for static binaries, then wraps each in a thin Python exec shim.
  • Produces manylinux, musllinux, macOS (Intel + ARM), and Windows (amd64 + arm64) wheels in ./dist from a single command.
  • --set-version-var injects the wheel version into the Go binary at link time via -X ldflag, no hardcoding needed.
  • Install target via pip install, pipx install, or test instantly with uv run --with ./dist/....
  • Inspired by maturin, the Rust equivalent; pip-binary-factory is listed as a related template.

Hacker News Comment Review

  • The core use case is Python-ecosystem tooling distribution: if your users already use pip/pipx, wrapping a Go or Rust CLI lets them pip install without touching Homebrew, Chocolatey, or go install.
  • Skepticism exists around necessity: go install, Homebrew, and Chocolatey already handle binary distribution, so the value is narrowly scoped to teams with a Python-centric user base.

Notable Comments

  • @Philip-J-Fry: Challenges the premise directly, asking why Python tooling should be preferred over go install or existing package managers.

Original | Discuss on HN