build command is the modern, recommended way to compile Python programs with Shed Skin. It uses CMake for build configuration and dependency management.
Syntax
Overview
The build command performs these steps:- Parse - Reads and validates your Python source code
- Analyze - Performs type inference and static analysis
- Generate - Creates C++ source files and CMakeLists.txt
- Build - Compiles C++ code to native executable or extension module
Basic Examples
Build a standalone executable
build/example.
Build an extension module
.so (Linux), .dylib (macOS), or .pyd (Windows) file that can be imported from Python:
Build with optimization flags
Output Directory Structure
After runningbuild, your project will have:
Command Options
Basic Options
Python file or module to compile (e.g.,
program.py)Specify output directory for generated C++ files (default: current directory)
Generate a Python extension module instead of a standalone executable
Explicitly generate a standalone executable (this is the default)
Silent mode - only show warnings, suppress informational output
Set debug logging level (1-3). Level 3 enables detailed type inference logging
Type Configuration
Use 32-bit integers (default: platform-dependent)
Use 64-bit integers
Use 128-bit integers (not supported on Windows)
Use 32-bit floating point numbers
Use 64-bit floating point numbers (double precision)
Performance & Safety Options
Disable array bounds checking for better performance
Disable wrap-around checking for negative indices
Disable assert statements in generated code
Disable garbage collection (use with caution)
Print traceback for uncaught exceptions in compiled code
CMake Build Options
Specify CMake build system generator (e.g., “Ninja”, “Unix Makefiles”)
Build in parallel using N jobs (e.g.,
--jobs 4)Set CMake build type:
Debug, Release, RelWithDebInfo, or MinSizeRelReset CMake build directory before building
Run ctest after building
Enable ccache for faster rebuilds
Build only specified CMake targets (e.g.,
--target myprogram)Disable
-Wall compilation warningsDependency Management
Build dependencies from bundled ext/ sources (default if no other option specified)
Install CMake dependencies using SPM package manager
Install CMake dependencies using FetchContent
Advanced Options
Add include directories for C++ compilation (can be specified multiple times)
Add library directories for linking (can be specified multiple times)
Add libraries to link against (can be specified multiple times)
Add an extra builtins library directory
Collect and report compilation statistics
Advanced Examples
Parallel build with release optimization
Build with custom output directory
./generated/, executable goes to build/.
Build extension with 64-bit integers
Debug build with tracebacks
Using Ninja generator for faster builds
Performance-optimized build
Build vs Translate
Choose build when you want:- Modern CMake-based workflow
- Better dependency management
- IDE integration (CMake support)
- Multi-configuration builds (Debug/Release)
- Cross-platform portability
- Simple Makefile-based builds
- Direct control over compilation
- Integration with existing Makefile workflows
Running the Compiled Program
After building, run your executable:Troubleshooting
CMake not found
Shed Skin requires CMake 3.15 or later. Install it using:Build directory issues
If you encounter CMake cache problems, reset the build:Slow builds
Speed up compilation:See Also
- translate command - Traditional Makefile-based workflow
- CLI overview - All available commands
- Command-line options - Complete reference