Skip to main content

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 CodeLLDB launch.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.cpp
  • CMakeLists.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.cpp
  • src/pydemo/__init__.py / src/pydemo/demo.pyi
  • pyproject.toml with [tool.pycpp] (python / pybind11 paths, build_type, cxx_standard, cxx_compile, generator)
  • scripts/cmake-config.py (reads toml, passes -D to 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 is py{name}
  • --pybind11: initialize as a pybind11 module
  • --inplace-vscode: overwrite existing .vscode tasks/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: configbuildrun. 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

pycpp_tools-0.4.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

pycpp_tools-0.4.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

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

Hashes for pycpp_tools-0.4.0.tar.gz
Algorithm Hash digest
SHA256 e4361881de84778e8c1c5c69ae46e793df18c0932a004eccf9e6f5b7dbf71c3d
MD5 6d9a4700c40de654f88afcfc4eac2794
BLAKE2b-256 8509a7c7389f15aa2a51977dd9025373366f574fa4a6c41bba47698e1f946349

See more details on using hashes here.

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

Hashes for pycpp_tools-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6864595c8c9ff9811b6772c61e43c0b1a981f8fa400b15d97b98a48d97168893
MD5 cd512725df67a9e6fd4c918203c93fdc
BLAKE2b-256 239cc8bec685360df050436e470a1f27312f8d53c56e335c0ec590ee1c29273a

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