Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xflash96/pybind11_package_example
Example python package with pybind11 cpp extension
https://github.com/xflash96/pybind11_package_example
Last synced: 3 months ago
JSON representation
Example python package with pybind11 cpp extension
- Host: GitHub
- URL: https://github.com/xflash96/pybind11_package_example
- Owner: xflash96
- License: mit
- Created: 2020-12-13T09:37:41.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2020-12-19T15:28:38.000Z (almost 4 years ago)
- Last Synced: 2024-07-04T02:12:41.937Z (4 months ago)
- Language: Python
- Size: 369 KB
- Stars: 57
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Developing C++ extension in Python using pybind11
This is a summary of the commands used in [the tutorial](tutorial.md).
To clone the repository and the submodules, run
```bash
git clone --recursive https://github.com/xflash96/pybind11_package_example
```## Using the Docker developing environment
* To build the docker image, run `cd docker && ./build.sh`
* To run the container, `./run.sh` .See the `docker/Dockerfile` for the details.
## Building the extension and installing the package
* To build the C++ extension, run `python setup.py build_ext -i`
* To install the package, run ``sudo `which python` setup.py develop``## Profiling
### [line_profiler](https://github.com/pyutils/line_profiler) for the Python code
* Mark the `@profile` to the function of interest.
* Run the profiler via `kernprof -l ./bin/example_cmd`
* See the report with `python -m line_profiler example_cmd.lprof`### Perf for the C++ extension
* Enable perf in Linux by `sudo sh -c 'echo 1 >/proc/sys/kernel/perf_event_paranoid'`
* Profile via `perf record bin/example_cmd`
* Show report with `perf report`## Testing
Use either
* `python setup.py test`
* `pytest`
to run the unit tests.## Releasing the package
* Pack the source distribution with `python setup.py sdist`
* Upload the package with `python -m twine upload --repository testpypi dist/*`