Skip to main content

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.

CI

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

# 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
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 pcons-build.py
ninja -C build

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:

# Using uv
uv add pcons

# Or pip
pip install pcons

For development:

git clone https://github.com/garyo/pcons.git
cd pcons
uv sync

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.4.3.tar.gz (385.9 kB view details)

Uploaded Source

Built Distribution

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

pcons-0.4.3-py3-none-any.whl (205.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pcons-0.4.3.tar.gz
Algorithm Hash digest
SHA256 50c1c490e7138b86cecef7532d3d3640b4c7c5f5e6cb63a90d1da22a58c3978f
MD5 05acf4857e84609fb1917cb9d2b38de0
BLAKE2b-256 d8647ad3b02498c8e253480163c2a7b809b69c30869c9bd5b75503dd1da3b101

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pcons-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 205.5 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.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fb01a04ad808ec573aac654b66778b67c234c4618e3e7fd491f258a033181b69
MD5 ebf88a0d744614c7d9d28b46cfa2e43b
BLAKE2b-256 a91405575e93d94e0b39f8f606a8f16e3dc2c543b6b06ab0dc0a8c6915630035

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