Metadata-Version: 2.3
Name: pycpp_tools
Version: 0.4.0
Summary: A utility to initialize basic CMake C++ / pybind11 projects.
Author: R.E.
Author-email: R.E. <redelephant@foxmail.com>
License: MIT
Requires-Dist: pybind11
Requires-Python: >=3.13
Description-Content-Type: text/markdown

# 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

```bash
pip install .
```

Or install in development mode:

```bash
pip install -e .
```

After installation, the `pycpp` command will be available in your terminal.

## Usage

### CMake C++ Project

```bash
pycpp init --name myproject
```

Generates:
- `src/main.cpp`
- `CMakeLists.txt`
- `.vscode/tasks.json` (`config` / `build` / `run`)
- `.vscode/launch.json` (CodeLLDB)

### Pybind11 Project

```bash
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:

```bash
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](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb) (for debugging)

## License

MIT License

## Author

R.E. (redelephant@foxmail.com)
