Settings

Theme

Show HN: Pcons: new software build tool in Python, inspired by SCons and CMake

github.com

1 points by darkstarsys 6 days ago · 0 comments · 3 min read

Reader

I was one of the original developers of SCons and helped maintain it for years. I love that Python is the configuration language — it makes build descriptions incredibly flexible. But over time, working with CMake on other projects, I came to appreciate things SCons doesn't do as well: the separation between describing a build and executing it, transitive dependency propagation, package manager integration, and modern python semantics. I'd been thinking about a fresh start for years but never had the time. Recently, working collaboratively with Claude Code, it finally became feasible. So, meet pcons.

  What it is: Pcons is a build system where Python scripts describe what to build, and Ninja (or Make) executes it. There's no custom DSL — your build files are real Python with full IDE support, debugging, and testing. The core is completely language-agnostic: it knows nothing about compilers or C++. All tool-specific knowledge lives in pluggable toolchains and tools, so building LaTeX documents or game assets should be as natural as building C++.

  How it's different from SCons: Pcons doesn't execute builds itself. It generates Ninja files, so incremental builds are fast and you get Ninja's parallelism for free. Environments use namespaced tools (env.cc.flags, env.cxx.flags, env.link.libs) instead of flat variables, eliminating the CFLAGS vs CXXFLAGS confusion. Targets have CMake-style usage requirements (target.public.include_dirs, target.public.link_libs) that propagate transitively through the dependency graph. And unlike SCons, unknown variables are errors, not silent empty strings.

  How it's different from CMake: No DSL to learn — it's just Python. Variable substitution is recursive and explicit. The builder/toolchain system is fully extensible, so third-party builders are first-class citizens. And you can use it as `uvx pcons` for true zero-install (great for other open source projects).
Major features as of v0.7: - Toolchains for GCC, LLVM/Clang, MSVC, and clang-cl with auto-detection (including - Generators for Ninja, Makefile, Xcode, compile_commands.json, and Mermaid/DOT dependency diagrams - Package management via pkg-config, Conan 2.x, and a pcons-fetch tool for building dependencies from source - Compiler cache support (ccache/sccache), semantic presets (warnings, sanitizers, LTO, hardening), cross-compilation presets (Android NDK, iOS, WebAssembly) - Platform-specific helpers: macOS bundles/frameworks/.pkg/.dmg, Windows manifests/MSIX, and an msvcup module for installing MSVC without Visual Studio - An extensible module/add-on system for domain-specific tasks - Debug tracing (--debug=resolve,subst) with source-location tracking on every node - Plenty of examples included, unit tests for all features, tested on Mac, Windows and Linux

  It's still under active development — ready for experimentation, not production unless you're brave. I'd love bug reports, feedback on the API design and what you'd want from a modern Python-based software build system. 
Open source, MIT licensed.

GitHub: https://github.com/DarkStarSystems/pcons | Docs: https://pcons.readthedocs.io | PyPI: `uvx pcons` or `pip install pcons`

No comments yet.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection