A Python-based build system that generates Ninja files
Project description
Pcons
A modern Python-based build system that generates Ninja (or Makefile) build files.
Overview
Pcons is inspired by SCons and CMake, taking the best ideas from each:
- From SCons: Environments, Tools, dependency tracking, Python as the configuration language
- From CMake: Generator architecture (configure once, build fast), usage requirements that propagate through dependencies
Key design principles:
- Configuration, not execution: Pcons generates Ninja files; Ninja executes the build
- Python is the language: No custom DSL—build scripts are real Python with full IDE support
- Language-agnostic: Build C++, Rust, LaTeX, protobuf, or anything else
- Explicit over implicit: Dependencies are discoverable and traceable
Status
🚧 Under active development - ready for experimentation and feedback.
Core functionality is working: C/C++ compilation, static and shared libraries, programs, and install targets. See ARCHITECTURE.md for design details.
Quick Example
# build.py
from pcons.core.project import Project
from pcons.toolchains import find_c_toolchain
project = Project("myapp", build_dir="build")
# Find and configure a C/C++ toolchain
toolchain = find_c_toolchain()
env = project.Environment(toolchain=toolchain)
env.cc.flags.extend(["-Wall"])
# Build a static library
lib = project.StaticLibrary("core", env)
lib.sources.append(project.node("src/core.c"))
lib.public.include_dirs.append(Path("include"))
# Build a program
app = project.Program("myapp", env)
app.sources.append(project.node("src/main.c"))
app.link(lib)
project.Default(app)
project.resolve()
project.generate()
uv run build.py
ninja -C build
Installation
# Using uv (recommended)
uv add pcons
# Or pip
pip install pcons
For development:
git clone https://github.com/garyo/pcons.git
cd pcons
uv sync
Development
# Run tests
uv run pytest
# Run linter
make lint
# Format code
make fmt
# Or use uv directly
uv run ruff check pcons/
uv run mypy pcons/
Documentation
- ARCHITECTURE.md - Design document and implementation status
- CONTRIBUTING.md - How to contribute
License
MIT License - see LICENSE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pcons-0.1.2.tar.gz.
File metadata
- Download URL: pcons-0.1.2.tar.gz
- Upload date:
- Size: 241.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b46acbdf52fe9d96e6909acaa6a23aa94244f07f5f8c1ed2087a6fad64b63f59
|
|
| MD5 |
030685d3416353190acaa66c3261ecb7
|
|
| BLAKE2b-256 |
10537f63829e292786653fd124381e17affdd5538587c15016217d727afbfb26
|
File details
Details for the file pcons-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pcons-0.1.2-py3-none-any.whl
- Upload date:
- Size: 129.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2cbc86422d449fdddc3fc80ef23f21b7628ba745b0dac877b1ee73aa4105028
|
|
| MD5 |
068253da378a5ca4a6c71c136395a0d8
|
|
| BLAKE2b-256 |
55de33a1da2fe08d54ef3d20cdec97c4a1c43e15d23c29c9088bae85a455bb41
|