or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cli.mdconfiguration.mdcore-compilation.mddistutils.mdindex.mdplugins.mdutilities.mdversion.md
tile.json

tessl/pypi-nuitka

Python compiler that translates Python modules into C programs with full language support and CPython compatibility

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/nuitka@2.7.x

To install, run

npx @tessl/cli install tessl/pypi-nuitka@2.7.0

index.mddocs/

Nuitka

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

Package Information

  • Package Name: Nuitka
  • Language: Python
  • Installation: pip install Nuitka

Core Imports

import nuitka

For command-line usage:

nuitka --help

For 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

Basic Usage

Command Line Compilation

# 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.py

Distutils Integration

from setuptools import setup

setup(
    name="mypackage",
    build_with_nuitka=True,
    # other setup parameters
)

Basic Programmatic Usage

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()

Architecture

Nuitka's architecture consists of several key components:

  • MainControl: Orchestrates the compilation process from Python to C to executable
  • Options: Command-line argument parsing and configuration management
  • Tree Processing: AST transformation and optimization of Python source code
  • Code Generation: Converts optimized Python AST into C source code
  • Build System: SCons integration for compiling generated C code
  • Plugin System: Extensible framework for handling special cases and third-party packages
  • Utilities: File operations, process execution, and cross-platform compatibility

This design enables Nuitka to handle the complete Python language specification while providing optimization opportunities and maintaining full CPython compatibility.

Capabilities

Command Line Interface

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 decryption

Command Line Interface

Core Compilation API

Core 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."""

Core Compilation

Configuration & Options

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

Configuration & Options

Version Information

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

Version Information

Distutils Integration

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

Distutils Integration

Plugin System

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

Plugin System

Utility Functions

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

Utility Functions

Error Handling

Nuitka provides comprehensive error handling throughout the compilation process:

  • Syntax Errors: Python syntax validation before compilation
  • Import Errors: Module resolution and dependency checking
  • Compilation Errors: C compiler integration error reporting
  • Plugin Errors: Plugin loading and execution error handling
  • Runtime Errors: Preserved Python exception semantics in compiled code

All errors maintain Python's standard exception hierarchy and provide detailed diagnostic information for debugging compilation issues.

Types

# 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]