A utility to initialize basic CMake C++ / pybind11 projects.
Project description
pycpp-tools
A command-line utility to initialize a basic CMake C++ or pybind11 project.
Features
- Initialize a CMake C++ project (CMake 3.30, C++23, Ninja)
- Initialize a pybind11 project with
--pybind11 - Generate VS Code
tasks.json(config / build / run / clear) and CodeLLDBlaunch.json
Installation
pip install .
Or install in development mode:
pip install -e .
After installation, the pycpp command will be available in your terminal.
Usage
CMake C++ Project
pycpp init --name myproject
Generates:
src/main.cppCMakeLists.txt.vscode/tasks.json(config/build/run).vscode/launch.json(CodeLLDB)
Pybind11 Project
pycpp init --name demo --pybind11
--name is the C++ extension module name. The Python package defaults to py + name (e.g. pydemo).
Generates:
cpp-src/pywrapper.cppsrc/pydemo/__init__.py/src/pydemo/demo.pyipyproject.tomlwith[tool.pycpp](python / pybind11 paths, build_type, cxx_standard, cxx_compile, generator)scripts/cmake-config.py(reads toml, passes-Dto cmake)scripts/clear.py(cleans build artifacts)scripts/package.py(clear → cmake config → cmake build →python -m build)setup.py(声明二进制包,wheel 打上cp3xx标签)test.py(from pydemo import demo)CMakeLists.txt(extension output →src/pydemo/).vscode/tasks.json(config/build/run/clear/package).vscode/launch.json
Options:
--name <name>: C++ module name (default:demo); Python package ispy{name}--pybind11: initialize as a pybind11 module--inplace-vscode: overwrite existing.vscodetasks/launch files
Then configure and build:
python scripts/cmake-config.py
cmake --build build
pip install -e .
python test.py
Packaging assumes the extension is already built in the repo (src/pydemo/*.pyd); pyproject.toml includes it via package-data. No on-the-fly cmake during uv build / pip wheel.
Or use the VS Code tasks: config → build → run. Edit [tool.pycpp] or [project].name in pyproject.toml and re-run config to pick up path / package-dir changes.
Requirements
- Python 3.13 or higher
- CMake 3.30 or higher
- C++ compiler supporting C++23
- Ninja
- CodeLLDB (for debugging)
License
MIT License
Author
R.E. (redelephant@foxmail.com)
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
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 pycpp_tools-0.4.0.tar.gz.
File metadata
- Download URL: pycpp_tools-0.4.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4361881de84778e8c1c5c69ae46e793df18c0932a004eccf9e6f5b7dbf71c3d
|
|
| MD5 |
6d9a4700c40de654f88afcfc4eac2794
|
|
| BLAKE2b-256 |
8509a7c7389f15aa2a51977dd9025373366f574fa4a6c41bba47698e1f946349
|
File details
Details for the file pycpp_tools-0.4.0-py3-none-any.whl.
File metadata
- Download URL: pycpp_tools-0.4.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6864595c8c9ff9811b6772c61e43c0b1a981f8fa400b15d97b98a48d97168893
|
|
| MD5 |
cd512725df67a9e6fd4c918203c93fdc
|
|
| BLAKE2b-256 |
239cc8bec685360df050436e470a1f27312f8d53c56e335c0ec590ee1c29273a
|