Skip to main content

Compile Go CLI programs into Python wheels

Project description

go-to-wheel

PyPI Changelog Tests License

Compile Go CLI programs into Python wheels.

This tool takes a Go module directory, cross-compiles it for multiple platforms, and produces properly-tagged Python wheels that can be installed via pip or pipx to get the Go binary on your PATH.

Installation

pip install go-to-wheel
# or
pipx install go-to-wheel

Requires Go to be installed and available in your PATH.

Quick start

Build wheels for all platforms from a Go module:

go-to-wheel path/to/go-module

This will create wheels in a ./dist directory for Linux (glibc and musl), macOS (Intel and Apple Silicon), and Windows (amd64 and arm64).

Usage

go-to-wheel path/to/go-folder [options]

Options

Option Description Default
--name NAME Python package name Directory basename
--version VERSION Package version 0.1.0
--output-dir DIR Directory for built wheels ./dist
--entry-point NAME CLI command name Same as package name
--platforms PLATFORMS Comma-separated list of targets All supported platforms
--go-binary PATH Path to Go binary go
--description TEXT Package description "Go binary packaged as Python wheel"
--license LICENSE License identifier None
--author AUTHOR Author name None
--author-email EMAIL Author email None
--url URL Project URL None
--requires-python VERSION Python version requirement >=3.10

Examples

Build wheels with a custom package name:

go-to-wheel ./mytool --name my-python-tool

Build for specific platforms only:

go-to-wheel ./mytool --platforms linux-amd64,darwin-arm64

Build with full metadata for PyPI:

go-to-wheel ./mytool \
  --name mytool-bin \
  --version 2.0.0 \
  --description "My awesome tool" \
  --license MIT \
  --author "Jane Doe" \
  --author-email "jane@example.com" \
  --url "https://github.com/jane/mytool"

Supported platforms

Platform Wheel Tag
linux-amd64 manylinux_2_17_x86_64
linux-arm64 manylinux_2_17_aarch64
linux-amd64-musl musllinux_1_2_x86_64
linux-arm64-musl musllinux_1_2_aarch64
darwin-amd64 macosx_10_9_x86_64
darwin-arm64 macosx_11_0_arm64
windows-amd64 win_amd64
windows-arm64 win_arm64

How it works

  1. Cross-compiles the Go binary using GOOS and GOARCH environment variables with CGO_ENABLED=0 for static binaries
  2. Creates a Python package with a thin wrapper that execs the bundled binary
  3. Packages everything into a wheel with the correct platform tag

The resulting wheel can be installed with pip:

pip install ./dist/mytool-1.0.0-py3-none-manylinux_2_17_x86_64.whl

Or tested directly with uv:

uv run --with ./dist/mytool-1.0.0-py3-none-manylinux_2_17_x86_64.whl mytool --help

Development

Clone the repository:

git clone https://github.com/simonw/go-to-wheel
cd go-to-wheel

Run tests:

uv run pytest

See also

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

go_to_wheel-0.1.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

go_to_wheel-0.1-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file go_to_wheel-0.1.tar.gz.

File metadata

  • Download URL: go_to_wheel-0.1.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for go_to_wheel-0.1.tar.gz
Algorithm Hash digest
SHA256 e26e721f708291aa44edf42b6b6f102ae4e0c335de012db7f5cce712722fe5e6
MD5 ed45054e6ffc4eda31c263b4de528928
BLAKE2b-256 21af8a4a39a832b7d7b05cb3289cf16853f3fd8a502f1655035c4717f1ad4dcc

See more details on using hashes here.

Provenance

The following attestation bundles were made for go_to_wheel-0.1.tar.gz:

Publisher: publish.yml on simonw/go-to-wheel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file go_to_wheel-0.1-py3-none-any.whl.

File metadata

  • Download URL: go_to_wheel-0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for go_to_wheel-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a6e74b8f2d08adb014ed0abd976dbc50b44b5559d05a9c6de279b9b31ce2bf74
MD5 f2a54c3c7faa9e854d3a9a6a38befda0
BLAKE2b-256 c283ee8172698434eb17614c501c336b0b22036da1aa95116e972765e345e2f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for go_to_wheel-0.1-py3-none-any.whl:

Publisher: publish.yml on simonw/go-to-wheel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page