{"id":22254587,"url":"https://github.com/mizux/cmake-pybind11","last_synced_at":"2025-10-13T12:30:58.650Z","repository":{"id":74261416,"uuid":"461799556","full_name":"Mizux/cmake-pybind11","owner":"Mizux","description":"Test to build a Native Python 3 package using pybind11","archived":false,"fork":false,"pushed_at":"2025-10-06T16:18:06.000Z","size":110,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-06T18:28:21.725Z","etag":null,"topics":["cmake","cpp","mizux","native-library","pybind11","python"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mizux.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-02-21T09:56:19.000Z","updated_at":"2025-10-06T16:18:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"77cd9d06-4d5f-4236-809e-313d6563c4ac","html_url":"https://github.com/Mizux/cmake-pybind11","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":"Mizux/python-native","purl":"pkg:github/Mizux/cmake-pybind11","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mizux%2Fcmake-pybind11","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mizux%2Fcmake-pybind11/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mizux%2Fcmake-pybind11/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mizux%2Fcmake-pybind11/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mizux","download_url":"https://codeload.github.com/Mizux/cmake-pybind11/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mizux%2Fcmake-pybind11/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279015059,"owners_count":26085643,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cmake","cpp","mizux","native-library","pybind11","python"],"created_at":"2024-12-03T07:31:54.354Z","updated_at":"2025-10-13T12:30:58.630Z","avatar_url":"https://github.com/Mizux.png","language":"C++","readme":"Github-CI:\u003cbr\u003e\n[![Build Status][amd64_linux_status]][amd64_linux_link]\n[![Build Status][amd64_macos_status]][amd64_macos_link]\n[![Build Status][arm64_macos_status]][arm64_macos_link]\n[![Build Status][amd64_windows_status]][amd64_windows_link]\u003cbr\u003e\n\n[![Build Status][amd64_docker_status]][amd64_docker_link]\n[![Build Status][arm64_docker_status]][arm64_docker_link]\n[![Build Status][riscv64_docker_status]][riscv64_docker_link]\u003cbr\u003e\n\n[amd64_linux_status]: ./../../actions/workflows/amd64_linux_cmake.yml/badge.svg\n[amd64_linux_link]: ./../../actions/workflows/amd64_linux_cmake.yml\n[amd64_macos_status]: ./../../actions/workflows/amd64_macos_cmake.yml/badge.svg\n[amd64_macos_link]: ./../../actions/workflows/amd64_macos_cmake.yml\n[arm64_macos_status]: ./../../actions/workflows/arm64_macos_cmake.yml/badge.svg\n[arm64_macos_link]: ./../../actions/workflows/arm64_macos_cmake.yml\n[amd64_windows_status]: ./../../actions/workflows/amd64_windows_cmake.yml/badge.svg\n[amd64_windows_link]: ./../../actions/workflows/amd64_windows_cmake.yml\n\n[amd64_docker_status]: ./../../actions/workflows/amd64_docker_cmake.yml/badge.svg\n[amd64_docker_link]: ./../../actions/workflows/amd64_docker_cmake.yml\n[arm64_docker_status]: ./../../actions/workflows/arm64_docker_cmake.yml/badge.svg\n[arm64_docker_link]: ./../../actions/workflows/arm64_docker_cmake.yml\n[riscv64_docker_status]: ./../../actions/workflows/riscv64_docker_cmake.yml/badge.svg\n[riscv64_docker_link]: ./../../actions/workflows/riscv64_docker_cmake.yml\n\n# Introduction\n\n\u003cnav for=\"project\"\u003e |\n\u003ca href=\"#requirement\"\u003eRequirement\u003c/a\u003e |\n\u003ca href=\"#codemap\"\u003eCodemap\u003c/a\u003e |\n\u003ca href=\"#dependencies\"\u003eDependencies\u003c/a\u003e |\n\u003ca href=\"#build\"\u003eBuild\u003c/a\u003e |\n\u003ca href=\"ci/README.md\"\u003eCI\u003c/a\u003e |\n\u003ca href=\"#appendices\"\u003eAppendices\u003c/a\u003e |\n\u003ca href=\"#contributing\"\u003eContributing\u003c/a\u003e |\n\u003ca href=\"#license\"\u003eLicense\u003c/a\u003e |\n\u003c/nav\u003e\n\nThis is an example of how to create a Modern [CMake](https://cmake.org/) C++/Python Project.\n\nThis project aim to explain how you build a Python 3.6+ native wheel package using\n [`Python3`](https://www.python.org/doc/) and a [setup.py](https://setuptools.readthedocs.io/en/latest/userguide/quickstart.html).\u003cbr\u003e\ne.g. You have a cross platform C++ library (using a CMake based build) and a\nPython wrapper on it thanks to [`Pybind11`](https://github.com/pybind/pybind11).\u003cbr\u003e\nThen you want to provide a cross-platform Python packages to consume it in a\nPython project...\n\nThis project should run on GNU/Linux, MacOS and Windows.\n\n## Requirement\n\nYou'll need:\n\n* \"CMake \u003e= 3.34\".\n* \"Python \u003e= 3.9\" and python module 'pip' (ed \"setuptools\" and \"wheel\" will be\n auto installed on demand).\n* \"Pybind11 \u003e= 2.13\".\n\n## Codemap\n\nThe project layout is as follow:\n\n* [CMakeLists.txt](CMakeLists.txt) Top-level for [CMake](https://cmake.org/cmake/help/latest/) based build.\n* [cmake](cmake) Subsidiary CMake files.\n  * [python.cmake](cmake/python.cmake) All internall Python CMake stuff.\n\n* [ci](ci) Root directory for continuous integration.\n\n* [Foo](Foo) Root directory for `Foo` library.\n  * [CMakeLists.txt](Foo/CMakeLists.txt) for `Foo`.\n  * [include](Foo/include) public folder.\n    * [foo](Foo/include/foo)\n      * [Foo.hpp](Foo/include/foo/Foo.hpp)\n  * [src](Foo/src) private folder.\n    * [src/Foo.cpp](Foo/src/Foo.cpp)\n  * [python](Foo/python)\n    * [CMakeLists.txt](Foo/python/CMakeLists.txt) for `Foo` Python.\n    * [pyFoo.cpp](Foo/python/pyFoo.cpp) Pybind Python wrapper.\n* [Bar](Bar) Root directory for `Bar` library.\n  * [CMakeLists.txt](Bar/CMakeLists.txt) for `Bar`.\n  * [include](Bar/include) public folder.\n    * [bar](Bar/include/bar)\n      * [Bar.hpp](Bar/include/bar/Bar.hpp)\n  * [src](Bar/src) private folder.\n    * [src/Bar.cpp](Bar/src/Bar.cpp)\n  * [python](Bar/python)\n    * [CMakeLists.txt](Bar/python/CMakeLists.txt) for `Bar` Python.\n    * [pyBar.cpp](Bar/python/pyBar.cpp) Pybind Python wrapper.\n* [FooBar](FooBar) Root directory for `FooBar` library.\n  * [CMakeLists.txt](FooBar/CMakeLists.txt) for `FooBar`.\n  * [include](FooBar/include) public folder.\n    * [foobar](FooBar/include/foobar)\n      * [FooBar.hpp](FooBar/include/foobar/FooBar.hpp)\n  * [src](FooBar/src) private folder.\n    * [src/FooBar.cpp](FooBar/src/FooBar.cpp)\n  * [python](FooBar/python)\n    * [CMakeLists.txt](FooBar/python/CMakeLists.txt) for `FooBar` Python.\n    * [pyFooBar.cpp](FooBar/python/pyFooBar.cpp) Pybind Python wrapper.\n\n* [python](python) Root directory for Python template files\n  * [`setup.py.in`](python/setup.py.in) setup.py template for the Python native package.\n\n## Dependencies\nTo complexify a little, the CMake project is composed of three libraries (Foo, Bar and FooBar)\nwith the following dependencies:  \n```sh\nFoo:\nBar:\nFooBar: PUBLIC Foo PRIVATE Bar\n```\n\n## Build Process\n\nTo Create a native dependent package which will contains two parts:\n\n* A bunch of native libraries for the supported platform targeted.\n* The Python code depending on it.\n\nnote: Since [Pypi.org](pypi.org) support multiple packages, we will simply upload one package per supported platform.\n\n### Local Package\nThe pipeline for `linux-x86-64` should be as follow:\u003cbr\u003e\n![Local Pipeline](docs/pipeline.svg)\n![Legend](docs/legend.svg)\n\n#### Building local native Package\nThus we have the C++ shared library `libFoo.so` and the pybind11\nPython shared library e.g. `pyFoo.so` in the same package.\n\nHere some dev-note concerning this `setup.py`.\n* This package is a native package containing native libraries.\n\nThen you can generate the package and install it locally using:\n```bash\npython3 setup.py bdist_wheel\npython3 -m pip install --user --find-links=dist cmakepybind11\n```\n\nIf everything good the package (located in `\u003cbuildir\u003e/python/dist`) should have\nthis layout:\n```\n{...}/dist/cmakepybind11-X.Y.9999-cp3Z-cp3Z-\u003cplatform\u003e.whl:\n\\- pythonnative\n   \\- __init__.py\n   \\- .libs\n      \\- libFoo.so\n      \\- ...\n   \\- foo\n      \\- __init__.py\n      \\- pyFoo.so\n...\n```\nnote: `\u003cplatform\u003e` could be `manylinux2014_x86_64`, `macosx_10_9_x86_64` or `win-amd64`.\n\ntips: since wheel package are just zip archive you can use `unzip -l \u003cpackage\u003e.whl`\nto study their layout.\n\n## Appendices\n\nFew links on the subject...\n\n### Resources\n\nProject layout:\n* [The Pitchfork Layout Revision 1 (cxx-pflR1)](https://github.com/vector-of-bool/pitchfork)\n\nCMake:\n* https://llvm.org/docs/CMakePrimer.html\n* https://cliutils.gitlab.io/modern-cmake/\n* https://cgold.readthedocs.io/en/latest/\n\nPython:\n* [Packaging Python Project](https://packaging.python.org/tutorials/packaging-projects/)\n* [PEP 600  Future 'manylinux' Platform Tags](https://www.python.org/dev/peps/pep-0600/)\n\n### Misc\nImage has been generated using [plantuml](http://plantuml.com/):\n```bash\nplantuml -Tsvg docs/{file}.dot\n```\nSo you can find the dot source files in [docs](docs).\n\n# Contributing\n\nThe [CONTRIBUTING.md](./CONTRIBUTING.md) file contains instructions on how to\nfile the Contributor License Agreement before sending any pull requests (PRs).\nOf course, if you're new to the project, it's usually best to discuss any\nproposals and reach consensus before sending your first PR.\n\n## License\n\nApache 2. See the LICENSE file for details.\n\n## Disclaimer\n\nThis is not an official Google product, it is just code that happens to be\nowned by Google.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmizux%2Fcmake-pybind11","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmizux%2Fcmake-pybind11","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmizux%2Fcmake-pybind11/lists"}