Scaffold and build Python C extensions with CMake and just-buildit.
Project description
Python C extensions the easy way.
just-makeit new generates a complete, working C99 extension project in one
command: core C library, thin Python binding, CMake build system, and full test
coverage — all passing before you write a single line of code.
Installation
pip install just-makeit
Quickstart
Standalone object — each type gets its own .so:
just-makeit new my_project --object engine --state gain:double:1.0
cd my_project && make && make test
What you get:
my_project/
├── native/
│ ├── benchmarks/
│ │ └── bench_engine_core.c # C-level benchmark
│ ├── inc/
│ │ ├── clib_common.h # common C99 types
│ │ ├── pyex_common.h # Python extension includes
│ │ ├── my_project.h # umbrella header
│ │ └── engine/
│ │ └── engine_core.h # object API ← implement step() here
│ ├── src/
│ │ ├── my_project_lib.c # combined C library stub (version symbol)
│ │ └── engine/
│ │ ├── CMakeLists.txt
│ │ ├── engine_core.c # block processor + lifecycle
│ │ └── engine_ext.c # thin Python binding
│ └── tests/
│ └── test_engine_core.c # CTest
├── cmake/
│ └── my-project.pc.in # pkg-config template
├── src/
│ └── my_project/ # Python package — import my_project
│ ├── __init__.py
│ ├── engine.pyi # type stub
│ ├── benchmarks/
│ │ ├── __init__.py
│ │ └── bench_engine.py # Python benchmark
│ └── tests/
│ ├── __init__.py
│ └── test_engine.py # pytest / unittest
├── CMakeLists.txt
├── Makefile
├── pyproject.toml
└── just-makeit.toml
Module subpackage — multiple types share one .so:
just-makeit new my_filters --module filter
cd my_filters
just-makeit object fir --module filter \
--state "coeffs:float[16]" --state "delay:float _Complex[16]" --state "gain:float:1.0"
just-makeit object biquad --module filter \
--arg-type float --return-type float \
--state "b0:double:1.0" --state "b1:double:0.0" --state "a1:double:0.0"
make && make test
from my_filters.filter import Fir, Biquad # one .so, one import
Commands
just-makeit provides a CLI with several commands run with
just-makeit COMMAND
| Command | Description |
|---|---|
new <project> |
Create a new project scaffold |
new <project> --module name [--module name ...] |
Project + one or more empty modules |
module <name> |
Scaffold an empty extension module (subpackage .so) |
object <name> --module name [--state ...] [--arg-type T] [--return-type T] |
Add a Python type to a module subpackage |
new <project> --object name [--state ...] [--arg-type T] [--return-type T] |
Project + first standalone object |
object <name> [--state ...] [--arg-type T] [--return-type T] |
Add a standalone object (its own .so) |
add --state name:type[:default] [--object name] [...] |
Add state variables to a standalone object |
perf |
Upgrade an existing project with performance annotations |
config [key value] |
Show or edit project configuration |
build [dir] |
Configure + build C, and package dist |
test |
Build and run CTest + pytest |
dry-run |
Preview what would be compiled |
See State Variable Types for supported types, defaults, and C/Python mappings.
C conventions
Generated code follows a consistent lifecycle pattern:
// Constructor — parameters match your --state declarations
engine_state_t *engine_create(double gain);
// Destructor
void engine_destroy(engine_state_t *state);
// Reset — restores every variable to its declared default
void engine_reset(engine_state_t *state);
// Single sample (inlined, pass-through stub — implement your algorithm here)
static inline float complex
engine_step(const engine_state_t *state, float complex x);
// Block processor
void engine_steps(
engine_state_t *state,
const float complex *input,
float complex *output,
size_t n);
// Getter / setter for each --state variable
double engine_get_gain(const engine_state_t *state);
void engine_set_gain(engine_state_t *state, double gain);
Python API
Standalone object (just-makeit object):
from my_project import Engine
import numpy as np
obj = Engine(gain=1.0) # explicit
obj = Engine() # uses declared defaults
# single sample
y: complex = obj.step(1.0 + 0.5j)
# block processing
x = np.ones(1024, dtype=np.complex64)
y = obj.steps(x) # returns complex64 ndarray
# getters / setters
obj.get_gain()
obj.set_gain(2.0)
# reset restores declared defaults
obj.reset()
# context manager
with Engine() as e:
y = e.steps(x)
Module subpackage (just-makeit module + just-makeit object):
from my_filters.filter import Fir, Biquad # one .so, clean subpackage import
fir = Fir(gain=1.0)
bq = Biquad(b0=1.0)
Types within a module are fully independent — separate lifecycles, each with
its own step, steps, reset, getters/setters, and context manager.
Multiple state variables
just-makeit new my_project \
--object engine \
--state center_freq:double:1000.0 \
--state bandwidth:double:200.0 \
--state order:int:4
Each --state name:type:default becomes a struct field, a constructor parameter
(optional in Python, required in C), getter/setter pair, and reset target — in
both C and Python.
Integrations
- CMake —
Python3_add_librarywithWITH_SOABI;.solands insrc/for zero-install dev workflow - GNU Make — convenience wrapper with
build,test, andjust-buildtargets - NumPy buffer protocol —
steps()accepts and returns typed ndarrays matching your declared state types - pytest — tests generated covering create, step, steps, getters/setters, reset, context manager, and destroy
- CTest — C-level test for the core lifecycle
- just-buildit — PEP 517 backend;
pip install .andpip install -e .work out of the box
Packaging
The generated project uses just-buildit as its PEP 517 build backend.
# Build and install
pip install .
# Development install (no rebuild needed after editing Python files)
pip install -e .
# Build a wheel manually
just-makeit build
Examples
The examples/ directory contains step-by-step walkthroughs:
running_stats/— Welford's online mean & variance (introductory walkthrough)fir_filter/— 16-tap FIR filter processing complex I/Q signals, with perf annotationssliding_correlator/— sliding window cross-correlation against a fixed reference sequencesliding_power/— sliding window instantaneous signal power estimatordsp_toolkit/— two-object library (Gain + Ema); demonstrates multi-object workflow and__init__.pyauto-splicefilter_module/—Fir+Biquadin a singlefiltersubpackage.sousingmodule+object
Design principles
Separation of concerns. Core C logic goes in *_core.c / *_core.h.
The Python extension in *_ext.c is a thin adapter — argument parsing, array
wrapping, and nothing more. This keeps the C library independently testable
and usable from Rust, C++, or any other language.
Full test coverage by default. Every generated project has C tests (CTest) and Python tests (pytest) from day one.
just-buildit for packaging. The generated pyproject.toml uses
just-buildit as the PEP 517
build backend, so pip install . just works.
Requirements
- Python 3.11+
- CMake ≥ 3.16
- A C99 compiler (GCC, Clang, MSVC/MinGW)
- NumPy (runtime, for generated projects)
Authors
Matthew T. Hunter, Ph.D. and Claude Code
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 Distributions
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 just_makeit-0.9.1-py3-none-any.whl.
File metadata
- Download URL: just_makeit-0.9.1-py3-none-any.whl
- Upload date:
- Size: 48.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e907db76eb6dc50afaa27d09f1accbaae6ec7c8bf78153d3094d73dc906f700
|
|
| MD5 |
92f1e208cc2072b06a24f3d098c5a687
|
|
| BLAKE2b-256 |
81dfbdc3ed1b2d8ce2c18b023c2123d3738fc18ad08bd6940f7e536f2e24f445
|
Provenance
The following attestation bundles were made for just_makeit-0.9.1-py3-none-any.whl:
Publisher:
release.yml on just-buildit/just-makeit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
just_makeit-0.9.1-py3-none-any.whl -
Subject digest:
3e907db76eb6dc50afaa27d09f1accbaae6ec7c8bf78153d3094d73dc906f700 - Sigstore transparency entry: 1493361727
- Sigstore integration time:
-
Permalink:
just-buildit/just-makeit@65fbd75f85bda6ad28f442a1b98ee83e33ef322f -
Branch / Tag:
refs/tags/v0.9.1 - Owner: https://github.com/just-buildit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@65fbd75f85bda6ad28f442a1b98ee83e33ef322f -
Trigger Event:
push
-
Statement type: