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

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.1
File Size Uploaded Provenance Actions
smelt-0.8.1.tar.gz 382.7 kB Without provenance Details for smelt-0.8.1.tar.gz

Built distribution (wheel)

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

Total release size: 684.3 kB

Release files / smelt-0.8.1.tar.gz

Download URL smelt-0.8.1.tar.gz
Size 382.7 kB
Tags Source
SHA-256 checksum
How to use checksums
67242ed051469e22351072ff8fe81e17f534df9248c06500ee2247a37f34a4e4
BLAKE2b-256 checksum
How to use checksums
0244772545247130293581de4931c9a3ccb01dcdea12d83273e2005add58284d
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.1-py3-none-any.whl

Download URL smelt-0.8.1-py3-none-any.whl
Size 301.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a78d3445ada1b00f4c8a1ceafa4e98ddbad366c04ae778a20c202e247f66a79a
BLAKE2b-256 checksum
How to use checksums
6029ce9fa1067ce945f52c2205b3cd20816278b6ce81efc205cb6cf7cf5d9f5c
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.1

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