Skip to main content

Smelt

Shipping a Python project as native code is hard in two ways. Native extensions (C, Zig, mypyc, Cython, Nuitka) need a C toolchain on every machine that builds them, and each tool has its own build pipeline. Shipping an application to a machine without Python means bundling an interpreter, which tools like PyInstaller do by copying a whole, generic one.

Smelt addresses both, using Zig (installed from PyPI with ziglang) as a fully standalone compiler, so nothing needs to be installed on the system:

  • A build backend: compiles native extensions declared in pyproject.toml (mypyc, Cython, Nuitka, handwritten C or Zig) during a regular build, with no system compiler. Backends can be mixed per module, and swapped without touching the code. Cross-compilation for other platforms is experimental.
  • A bundler: smelt bundle turns an entrypoint into a standalone distribution, as a folder or a single file. It ships the application's compiled extensions plus bytecode for the rest, and can build and ship its own CPython interpreter. That interpreter is tailored to the standard-library modules and native libraries the application actually uses, so the target machine needs no Python at all.

Documentation: https://hedwyn.github.io/smelt

Build backend

[build-system]
requires = ["hatchling", "smelt[mypyc]"]
build-backend = "hatchling.build"

[project]
name = "fib-demo"
version = "0.1.0"

[tool.hatch.build.hooks.smelt]   # enables the hook

[tool.smelt]
package-dirs = { fib_demo = "src/fib_demo" }

[tool.smelt.extensions]
mypyc = ["fib_demo.fib"]

pip install . (or python -m build) compiles fib.py with mypyc and places the native module next to it, shadowing the pure-Python source.

Other backends are declared the same way: cython, nuitka, [[tool.smelt.extensions.c]], [[tool.smelt.extensions.zig]]. See Build Hook.

Bundler

Every [project.scripts] entry can be bundled:

[project.scripts]
greet = "greet_demo.cli:main"
$ uv pip install "smelt[cli,byp]"   # `byp` is only needed for --python own
$ smelt bundle                 # dist/greet.dist/, runs on a matching installed CPython
$ smelt bundle --python own    # also builds and ships a tailored CPython interpreter
$ smelt bundle --python own --onefile   # packs it into a single self-extracting file

Settings live in [tool.smelt.bundle] (with per-entrypoint overrides), and every setting has a matching command-line flag. See Bundler: Get Started and the Reference.

Command line

Command Purpose
smelt build Build the declared extensions in place
smelt bundle Bundle an entrypoint (folder or single file, with or without its own interpreter)
smelt nuitka-binary Compile an entrypoint into one executable with Nuitka's whole-program mode
smelt compile MODULE Compile a single module with a chosen backend, optionally for another platform
smelt clean Delete built extensions, un-shadowing the pure-Python sources
smelt config Show the resolved configuration and where each setting comes from

See CLI.

Status

Smelt targets Python 3.12+. The bundler, the own interpreter and the build backend are tested on Linux x86_64 (glibc). Cross-compilation, fully static interpreters (--static, musl only), static linking of extensions into the interpreter (--inittab), the isolated dependency pipeline, and Windows single-file bundles are experimental.

Upgrading from 0.7: see the changelog. Configuration keys and command names from 0.7 still work in 0.8 with a deprecation warning.

Metadata

Release files for smelt 0.8.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smelt 0.8.2
File Size Uploaded Provenance Actions
smelt-0.8.2.tar.gz 382.7 kB Without provenance Details for smelt-0.8.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for smelt 0.8.2
File Interpreter ABI Platform Actions
smelt-0.8.2-py3-none-any.whl Python 3 none any Details for smelt-0.8.2-py3-none-any.whl

Total release size: 684.3 kB

Release files / smelt-0.8.2.tar.gz

Download URL smelt-0.8.2.tar.gz
Size 382.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4a4c20becae38b832be8f0ad7d579ed52041b3c633db4ea8a36f2ef40d06d422
BLAKE2b-256 checksum
How to use checksums
cb77b91a1fab769a6ff18061cd660e39dcf48ebc1a9630acedb3eec43f44de9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / smelt-0.8.2-py3-none-any.whl

Download URL smelt-0.8.2-py3-none-any.whl
Size 301.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c06315e8e327e33a82075f268fe58d3596858e5d05f6debcaa33a05ba34f34b1
BLAKE2b-256 checksum
How to use checksums
29d890d41eb8ffd4cf96ad319e93842781ff85c8a2e292ac5e5aaab5ef74ed9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for smelt 0.8.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page