A test project using pybind11 and CMake
Project description
Usage
python3 -m pip install cubao_cmake_example # install from pypi
python3 -c 'import cubao_cmake_example; print(cubao_cmake_example.add(1, 2))'
python3 -m cubao_cmake_example add 1 2
python3 -m cubao_cmake_example subtract 9 4
$ python3 -m cubao_cmake_example pure_python_func --help
INFO: Showing help with the command '__main__.py pure_python_func -- --help'.
NAME
__main__.py pure_python_func
SYNOPSIS
__main__.py pure_python_func <flags>
FLAGS
--arg1=ARG1
Type: int
Default: 42
--arg2=ARG2
Type: float
Default: 3.14
--arg3=ARG3
Type: str
Default: 'you shall not pass'
$ python3 -m cubao_cmake_example pure_python_func --arg1=43234
int: 43234, float: 3.14, str: you shall not pass
See more examples at cubao, e.g.:
- pybind11-rdp: C++ implementation of the Ramer-Douglas-Peucker algorithm (binding to python via pybind11)
- concave_hull: A very fast 2D concave hull algorithm, for python
Make a release
On linux
Install docker then
make python_build_all_in_linux
make upload_wheels
On macOS
Install c++ compiler and cmake.
Install conda and envs:
# conda create -y -n py36 python=3.6
# conda create -y -n py37 python=3.7
conda create -y -n py38 python=3.8
conda create -y -n py39 python=3.9
conda create -y -n py310 python=3.10
conda env list
Then
make python_build_all_in_macos
make upload_wheels
On windows
Install visual studio and cmake, (also git for windows, maybe).
Install conda and envs same as on macOS, then:
make python_build_all_in_windows
make upload_wheels
cmake_example for pybind11
CI | status |
---|---|
MSVC 2015 | |
conda.recipe | |
pip builds | |
cibuildwheel |
An example pybind11 module built with a
CMake-based build system. This is useful for C++ codebases that have an
existing CMake project structure. This is in many cases superseded by
scikit_build_example
, which uses
scikit-build, a tool from the makers of CMake designed to allow Python
packages to be driven from CMake. However, there are still cases where you
might want full control over the CMake run; and both of these approaches have
some trade-offs not present in a pure setuptools build (see
python_example
). Python 3.6+ required;
see the commit history for older versions of Python.
Prerequisites
- A compiler with C++11 support
- Pip 10+ or CMake >= 3.4 (or 3.8+ on Windows, which was the first version to support VS 2015)
- Ninja or Pip 10+
Installation
Just clone this repository and pip install. Note the --recursive
option which is
needed for the pybind11 submodule:
git clone --recursive https://github.com/pybind/cmake_example.git
pip install ./cmake_example
With the setup.py
file included in this example, the pip install
command will
invoke CMake and build the pybind11 module as specified in CMakeLists.txt
.
Building the documentation
Documentation for the example project is generated using Sphinx. Sphinx has the ability to automatically inspect the signatures and documentation strings in the extension module to generate beautiful documentation in a variety formats. The following command generates HTML-based reference documentation; for other formats please refer to the Sphinx manual:
cd cmake_example/docs
make html
License
Pybind11 is provided under a BSD-style license that can be found in the LICENSE file. By using, distributing, or contributing to this project, you agree to the terms and conditions of this license.
Test call
import cubao_cmake_example
cubao_cmake_example.add(1, 2)
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 Distribution
Built Distributions
Hashes for cubao_cmake_example-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a66d90ebc5be0cf27182d638b88197e01a35d75bfe9b89cbbb710ec39bc92fec |
|
MD5 | cf746444b23abfcda9a7712751065896 |
|
BLAKE2b-256 | 7d55d82899595aa79b41b645fb178202337ee5c38ce8fc688956770421eb8e5a |
Hashes for cubao_cmake_example-0.0.3-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85fc6ec92e411b601eba50aef406549e5db01903bc35a1ea69d30d896bd5bca0 |
|
MD5 | 0d76d8987fb1a67bcdb60de1b141ef14 |
|
BLAKE2b-256 | 9ff483167ed71847e66264263b1836d1a209fd31e82c7967474af7fb62491f6e |
Hashes for cubao_cmake_example-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92899725d1ffde4c19b032fb2e45c652fb38a6070a5d8fec2c3f3e3111650f98 |
|
MD5 | 9fb32d6e7d516a34f5712430aa2c066d |
|
BLAKE2b-256 | eb4b0a7f2bd6a2df21f9935abdee99d6bc8442d7d83526bb25b6af7acc1e3622 |
Hashes for cubao_cmake_example-0.0.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9e45b015d56be0bf57ab0c9bca3b8ebc3366ad2fcf35e2f62f6ca6f4f914765 |
|
MD5 | d94030971b2d1ec96d5b3ace6968b70d |
|
BLAKE2b-256 | d3885455476b406a4c5d28dbda157646d6d3e75432794050d19f090b60ed4e2e |
Hashes for cubao_cmake_example-0.0.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c387f7e6e1a9011c6007fe69bf2cb1b26291c12ae55718c0b774acf4160b6eb9 |
|
MD5 | 5a2f170efb029ca3697f2a258b4b71a1 |
|
BLAKE2b-256 | 23c4dba57b5d506264dbd385c565757fdcb0c0160a8a09aad7dc54e73b1cbc1f |
Hashes for cubao_cmake_example-0.0.3-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | abfa7bed8b97e54699b2d9ce900eba722dc9ec62c1a46787a8d660919484ea1c |
|
MD5 | 7ac9aae5cc188c9b9dc84a6373810cd3 |
|
BLAKE2b-256 | beaf95d4d68ac1fdb40ea76e7fa8dba5a678e397b5ec4fc267bfc0dc211dd6c1 |
Hashes for cubao_cmake_example-0.0.3-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 371059a396c73f826154f38f7e2c4c968e524f21cbaf4b0ec5077ae6554fff76 |
|
MD5 | be4581ac4caf1285d576adc241a8266d |
|
BLAKE2b-256 | b8db74d57c8c6be3c629e1a6b538d18c7c233c1811100e1dfbc039ee1ed54b55 |
Hashes for cubao_cmake_example-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0969d68df63fd7b88583dd3de7a7ad0419a73b9198a648dda0558d14df9e7a8f |
|
MD5 | 00521491c798ec730142d2a7ed0cfe42 |
|
BLAKE2b-256 | 9e2d5097e3f08f638bfbc9c505b050f67389b9e2e952bbb1edd6415e969544a7 |
Hashes for cubao_cmake_example-0.0.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 173fe4093fa68799d4d607af9f94f2de0ff5f72954d6fd546bc0b83e0f97311c |
|
MD5 | a81a6946b3a0e942288db1ac95b58fea |
|
BLAKE2b-256 | e2e222a447f943002a0591ac69a738e9e4e33a5eb45af8370506343e68379e3b |
Hashes for cubao_cmake_example-0.0.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a6c66c74aedd56bfc9b2bc1d9f2e400474a3a16b05a43f3f63b34ef1a3a96d2 |
|
MD5 | d48178743a864bf0d9c63c01e017a8a9 |
|
BLAKE2b-256 | 4807af074fff865b21e0824c19ccbbb4026ca1f17ab31f5b878efb1157525ae0 |
Hashes for cubao_cmake_example-0.0.3-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb4e29000ed90ae1545c1ab5944bc085f6140222d2c301c239b94d70320e68e5 |
|
MD5 | 71280c84ad48add434a76895da06d5f0 |
|
BLAKE2b-256 | f76f86c5b27e3e83ed62e9aff5138171e577d5f47706839cd7a8714038977b2c |
Hashes for cubao_cmake_example-0.0.3-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2633de3bf21e62911e9b2e1002ff57e3d1373b1044e27dccbb487ea78ed9892 |
|
MD5 | 2855c40e0643460a62d47a72a2c4a76d |
|
BLAKE2b-256 | 5b2b9d875ebed0c1500e3b61a4d38789072b9a0288275a8fe3da51a668c8aff6 |
Hashes for cubao_cmake_example-0.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe4b373d7418cd68fba781dae5b6c85e440b2881c79b4683abe12f750fb7ab0d |
|
MD5 | ed3be20259f234d956ff0e670a2ddd7e |
|
BLAKE2b-256 | 462c7b25d7a97bcc61295964090d255f12c891d53ddebb887810482488c0d430 |
Hashes for cubao_cmake_example-0.0.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65718d38af21ab1b96ad2826594a107964073e3771cf3cd777185606c30f3107 |
|
MD5 | 732e81376c9a610b15a8349c78d65dff |
|
BLAKE2b-256 | 54e81e93c9304afb16501c552fc39b547787528f02996682074c66662cbe0694 |
Hashes for cubao_cmake_example-0.0.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95e509adc0fbec30de06c8a077a6c6bb5738a9856ddab00430bb599a0060814d |
|
MD5 | 7142c751b9bc13cc17cb39c471768e6a |
|
BLAKE2b-256 | 92be2580336547c68f3b7cc98cab2eee00a9b1c69168cd4082b686fd0ce0696f |
Hashes for cubao_cmake_example-0.0.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7f56835c409e0886eb82a20be8bb33b31085047f15e2c6404c849ec8cbc5a60 |
|
MD5 | 524d8671bb23e38ce82e1748301d0922 |
|
BLAKE2b-256 | 2c869a7cbd46e6e4947befcceb14328be41fecedc788579922f3ff7124ae17a9 |
Hashes for cubao_cmake_example-0.0.3-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78f343bdebd1a595b5419a51ef592f3c37d46b37fcaa05f3fd0fd277c9888c9b |
|
MD5 | 33fe3f2112ad888d459310e16b5da9e9 |
|
BLAKE2b-256 | f2bf61a9e50bf9464a69df1c897a7f013fa94db80850f9ca370f22d08d51d579 |
Hashes for cubao_cmake_example-0.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 933d58d2abcac2dcda3c30babf8e424e0d8ed205de053d2400f349351f3606bb |
|
MD5 | d40c84e26291ed774698f4f740faaac8 |
|
BLAKE2b-256 | 162011043086b3a229d217260a545247fbfcdc3aa2ea71c3a082a4f6c9e4111b |
Hashes for cubao_cmake_example-0.0.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38295ed8d84171e227301bfa4573e08fedec24beb8d44ad13d9285c154b78c94 |
|
MD5 | 2b656492c5165dc0813ab4bc14f1c435 |
|
BLAKE2b-256 | 5daf6e50049c6ae802d3c42c44a598ab38d6492e446a316671f56e42bbbcf121 |
Hashes for cubao_cmake_example-0.0.3-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | efb5afb6b4004cfa92243dfdfa775c3a6c40ecdff7b9d99d3fb46e99bb5932a7 |
|
MD5 | 2e430c418b47b8a35efbedc06b15d65b |
|
BLAKE2b-256 | d9198c98324f1a5fd2353b1015eeb2258cc2ae4e310f7a5033a26d50eb07b49d |
Hashes for cubao_cmake_example-0.0.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a05263959917deb448f7f9fb38dabe0a6cbc40888189a759680fee12c75223a |
|
MD5 | 203f4ea4cd80ee775d22102c8639e281 |
|
BLAKE2b-256 | 4292722054968affdacb5fb9481011b2940b2d25b0465290a0eb11bf273e1ead |
Hashes for cubao_cmake_example-0.0.3-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53930568eaa3d0b7628a3c574948138b710a5ae96725a974ae2421c37159548d |
|
MD5 | 1010764ebb97083f715aaf2d95bd36cb |
|
BLAKE2b-256 | ab46a024b1cf1067a87ca626311c7e48fcf48556267431d9fa25aa31d0cb3d37 |
Hashes for cubao_cmake_example-0.0.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d7db90eb205a09c4848a4c4fce6bdb54d100a8c33aa03598e3fe0372ffa1867 |
|
MD5 | 81c39b16cfd774f13cf698c2f48c9c59 |
|
BLAKE2b-256 | 18bb34da688821c8791e5b8c4296ad64b6ac5cb9a454b984a170523c1dd5bced |
Hashes for cubao_cmake_example-0.0.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cc5edb8f7b5d3acea77ec79299caa20221410389e9ed8982b31b25ac81c91e1 |
|
MD5 | e8acf417b59224bd8fca86ab36f1d452 |
|
BLAKE2b-256 | 2d64a16f52196f0b98c68ac3c4fe5a4fc8c6256064f172a67382c3e26e76b8c2 |
Hashes for cubao_cmake_example-0.0.3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcf1be9078301348f4fa011b36600856acf82c8bf7d90b133aae8a5209f947a3 |
|
MD5 | 87557b058b70d4e20ef4dfb365d65513 |
|
BLAKE2b-256 | 6dbad70994163922d4c9b63bb8ce759a68870e472d0b0ece2e48e276fc1a7447 |
Hashes for cubao_cmake_example-0.0.3-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a246cb50f5b302e4e32de61453fc291cd2d29a852fc6cbdaa0eebd15a7692e1 |
|
MD5 | cc82e0c2afc409150467258e71e2ccf2 |
|
BLAKE2b-256 | 660e0d8dfa95e51a84ce11ed4790c9883a12a48b7196dd3ea07e3a1bc8e96b01 |
Hashes for cubao_cmake_example-0.0.3-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3c4bcc8ad2e2ab3bf34509a429ec1e913b201babe5adb6e77aad5a6fe1f6526 |
|
MD5 | 79336f87a482861d855da93882417385 |
|
BLAKE2b-256 | c7d4e120c9e46eb9cf49ec455a3a9bedfc98b24a8d495e843e1a4e39e590c5a8 |
Hashes for cubao_cmake_example-0.0.3-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16b97996443bee5ba1c1df3d17e6f4530fe03ab6ce8966b95e0f8766111e2c29 |
|
MD5 | 0f3c963c8935466851a0cec683b177af |
|
BLAKE2b-256 | 5167975e4c3c9db736a145a5cfffab29d7ca7c0ad663b4ec1d2983cb3dce32dd |
Hashes for cubao_cmake_example-0.0.3-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f3f523339bcf39e02d1e7a93752283abb29eba3679cf0417df381ed90967cb2 |
|
MD5 | aad1e36350caca9fc91f097b9769a598 |
|
BLAKE2b-256 | 50324d84deb586c196a32e27adec05bba0b4687febd36615f2541c29a4da8c2c |