Skip to main content

A Python-based build system that generates Ninja files

Project description

Pcons

A modern Python-based build system. Builds anything that requires a repeatable workflow using a dependency graph. Works with Ninja (or Makefile) to do the builds.

CI PyPI Python

Overview

Pcons is inspired by SCons and CMake, taking a few of 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
  • Extensible: Add-on modules for domain-specific tasks (plugin bundles, SDK configuration, etc.)

Why another software build tool?

I was one of the original developers of SCons, and helped maintain it for many years. I love that python is the config language; that makes build descriptions incredibly flexible and powerful. Recently I've been using CMake for more projects, and despite the deeply painful configuration language, I've come to appreciate its power: conan integration, the separation between describing the build and running it, and dependency propagation, among other things. I feel that SCons hasn't kept up with modern python; like any very widely used mature project, it has a lot of accumulated wisdom but also a bit ossified ways of doing things.

I've been thinking for years now about rearchitecting SCons onto a modern python stack with Path and decorators and all the other wonderful stuff python has been doing, and fixing some of the pain points at the same time (substitution/quoting, extensibility, tracing, separation between description and building, and more), but I've never had the time to dig into it. But recently as I've been using a lot more of Claude Code as a programming assistant, and it has gotten significantly better, it seemed like the right time to try this as a collaborative project. So, meet pcons!

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

# pcons-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
env = project.Environment(toolchain=find_c_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 using it
app = project.Program("myapp", env)
app.sources.append(project.node("src/main.c"))
app.link(lib)

# Generate the ninja.build script
project.generate()
uvx pcons # generate ninja.build and run it, producing build/myapp (or build/myapp.exe)

Installation

No installation needed, if you have uv; just use uvx pcons to configure and build. uvx pcons --help for more info. If you want to install it, though:

# Install as a CLI tool (recommended)
uv tool install pcons
pcons ...

# Or add to a project's dependencies
uv add pcons

# Or with pip
pip install pcons

Documentation

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/

License

MIT License - see LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pcons-0.8.2.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pcons-0.8.2-py3-none-any.whl (265.8 kB view details)

Uploaded Python 3

File details

Details for the file pcons-0.8.2.tar.gz.

File metadata

  • Download URL: pcons-0.8.2.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pcons-0.8.2.tar.gz
Algorithm Hash digest
SHA256 f3bb980b81720b7cfd43a4a7ff22b2c579c114704b7968d5afe5e623ff0ae5f2
MD5 6c7c0f96c30a014d355626215ff0f871
BLAKE2b-256 5e9d6129a1f1ad4a584ee421a7aa543a9d3c97d11ab5ddba28119db0f0610bca

See more details on using hashes here.

File details

Details for the file pcons-0.8.2-py3-none-any.whl.

File metadata

  • Download URL: pcons-0.8.2-py3-none-any.whl
  • Upload date:
  • Size: 265.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pcons-0.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5c54a057f55e98d0f6a9d8b6e7bce4fd312183c5f4af050a95dc19397f786120
MD5 1399d80dcf860d2a8cf0913574481005
BLAKE2b-256 67bac3224ad3017296bc5842c8dcd45529baa1f5356de9ef361d6e01e9534e30

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page