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.0

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.0
File Size Uploaded Provenance Actions
smelt-0.8.0.tar.gz 381.9 kB Without provenance Details for smelt-0.8.0.tar.gz

Built distribution (wheel)

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

Total release size: 683.2 kB

Release files / smelt-0.8.0.tar.gz

Download URL smelt-0.8.0.tar.gz
Size 381.9 kB
Tags Source
SHA-256 checksum
How to use checksums
99c0451f5f9855b3d44e5a845b4d26c4279bd3402b4d293dfbb463f10ab1d5e4
BLAKE2b-256 checksum
How to use checksums
ac9010221826e17c43a996d38972f1c809f03617c402283af6a6e8bbdf82a513
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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.0-py3-none-any.whl

Download URL smelt-0.8.0-py3-none-any.whl
Size 301.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e97ef6681eefe534a84b4fe5ab545cf7c948e79c6f6ed0dd961f5797d25c85a2
BLAKE2b-256 checksum
How to use checksums
1a31bb1a83de2728d0ce7eca458cbeb5e244ee481f6a8ca2095e13158be92b63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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.0

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