Python compiler that translates Python modules into C programs with full language support and CPython compatibility
npx @tessl/cli install tessl/pypi-nuitka@2.7.0Nuitka is a Python compiler that translates Python modules into C programs, providing seamless compatibility with CPython while optimizing performance. It supports all Python constructs and executes both compiled and uncompiled code together, offering acceleration capabilities and standalone distribution for Python applications.
pip install Nuitkaimport nuitkaFor command-line usage:
nuitka --helpFor programmatic usage:
from nuitka import MainControl, Options
from nuitka.Version import getNuitkaVersion, getNuitkaVersionTuple
from nuitka.plugins.Plugins import activatePlugins
from nuitka.utils.Utils import getOS, getArchitecture# Compile a Python script to standalone executable
nuitka --standalone myapp.py
# Compile as extension module
nuitka --module mymodule.py
# Run with Nuitka optimization
nuitka-run script.pyfrom setuptools import setup
setup(
name="mypackage",
build_with_nuitka=True,
# other setup parameters
)from nuitka import MainControl, Options
from nuitka.Version import getNuitkaVersion, getNuitkaVersionTuple
# Get version information
version = getNuitkaVersion()
version_tuple = getNuitkaVersionTuple()
print(f"Nuitka version: {version}")
print(f"Version tuple: {version_tuple}")
# Parse options and compile (advanced usage)
Options.parseArgs()
MainControl.main()Nuitka's architecture consists of several key components:
This design enables Nuitka to handle the complete Python language specification while providing optimization opportunities and maintaining full CPython compatibility.
Primary command-line tools for compiling Python code including the main compiler, run mode, and commercial decryption utilities.
# Console scripts available after installation
nuitka # Main compiler command
nuitka-run # Run Python scripts with compilation
nuitka-decrypt # Commercial plugin decryptionCore compiler functions for orchestrating the Python to C compilation process, including main control flow and tree compilation.
def main():
"""Main compiler entry point and orchestration."""
def compileTree():
"""Compile Python source tree to C code."""
def makeSourceDirectory():
"""Create and prepare source output directory."""Configuration management and command-line option parsing for controlling compilation behavior and output modes.
def parseArgs():
"""Parse and validate command line arguments."""
def isVerbose() -> bool:
"""Check if verbose output mode is enabled."""
def shallMakeModule() -> bool:
"""Check if compiling as extension module."""
def shallMakeExe() -> bool:
"""Check if creating executable output."""Version detection and compatibility checking for the Nuitka compiler and target Python environments.
def getNuitkaVersion() -> str:
"""Get current Nuitka version string."""
def getNuitkaVersionTuple() -> tuple:
"""Get version as tuple (major, minor, patch)."""
def getSupportedPythonVersions() -> list:
"""Get list of supported Python versions."""Setup.py integration for seamless Python package compilation with distutils and setuptools build systems.
def setupNuitkaDistutilsCommands(dist, keyword, value):
"""Configure distutils integration for Nuitka."""
class build:
"""Custom build command with Nuitka support."""
class bdist_nuitka:
"""Binary distribution command class."""Extensible plugin framework for handling third-party packages, data files, and special compilation cases through base classes and lifecycle hooks.
class NuitkaPluginBase:
"""Base class for all Nuitka plugins."""
class NuitkaYamlPluginBase:
"""Base class for YAML-configured plugins."""
class Plugins:
"""Plugin management and coordination system."""Cross-platform utilities for file operations, process execution, and system compatibility during the compilation process.
# File operations utilities
def getFileList(directory: str) -> list:
"""Get list of files in directory."""
# Process execution utilities
def executeCommand(command: list) -> int:
"""Execute external command."""
# Distribution detection
def getDistributionInfo(package: str) -> dict:
"""Get package distribution information."""Nuitka provides comprehensive error handling throughout the compilation process:
All errors maintain Python's standard exception hierarchy and provide detailed diagnostic information for debugging compilation issues.
# Version information types
VersionTuple = tuple[int, int, int]
# Plugin lifecycle types
PluginPhase = str # 'onModuleDiscovered', 'onDataFiles', etc.
# Compilation mode types
CompilationMode = str # 'standalone', 'module', 'package'
# Option configuration types
OptionDict = dict[str, Any]