{"id":22254591,"url":"https://github.com/mizux/python-native","last_synced_at":"2025-07-28T07:30:47.202Z","repository":{"id":74261534,"uuid":"329870978","full_name":"Mizux/python-native","owner":"Mizux","description":"Test to build a multi-platforms Native Python 3 package using pip","archived":false,"fork":false,"pushed_at":"2023-10-26T22:39:15.000Z","size":150,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2023-10-27T21:39:05.850Z","etag":null,"topics":["cmake","cpp","mizux","native-library","python","swig"],"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}},"created_at":"2021-01-15T09:47:29.000Z","updated_at":"2023-10-27T21:39:05.851Z","dependencies_parsed_at":null,"dependency_job_id":"4d6ff587-f8c8-40b0-a92b-f0dd2499d25b","html_url":"https://github.com/Mizux/python-native","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mizux%2Fpython-native","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mizux%2Fpython-native/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mizux%2Fpython-native/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mizux%2Fpython-native/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mizux","download_url":"https://codeload.github.com/Mizux/python-native/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227873185,"owners_count":17832896,"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","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","python","swig"],"created_at":"2024-12-03T07:31:56.138Z","updated_at":"2025-07-28T07:30:47.188Z","avatar_url":"https://github.com/Mizux.png","language":"C++","readme":"Github-CI:\u003cbr\u003e\n[![Build Status][github_amd64_linux_status]][github_amd64_linux_link]\n[![Build Status][github_amd64_macos_status]][github_amd64_macos_link]\n[![Build Status][github_arm64_macos_status]][github_arm64_macos_link]\n[![Build Status][github_amd64_windows_status]][github_amd64_windows_link]\u003cbr\u003e\n[![Build Status][github_amd64_docker_status]][github_amd64_docker_link]\n[![Build Status][github_arm64_docker_status]][github_arm64_docker_link]\n[![Build Status][github_riscv64_docker_status]][github_riscv64_docker_link]\n\n[github_amd64_linux_status]: ./../../actions/workflows/amd64_linux.yml/badge.svg\n[github_amd64_linux_link]: ./../../actions/workflows/amd64_linux.yml\n[github_amd64_macos_status]: ./../../actions/workflows/amd64_macos.yml/badge.svg\n[github_amd64_macos_link]: ./../../actions/workflows/amd64_macos.yml\n[github_arm64_macos_status]: ./../../actions/workflows/arm64_macos.yml/badge.svg\n[github_arm64_macos_link]: ./../../actions/workflows/arm64_macos.yml\n[github_amd64_windows_status]: ./../../actions/workflows/amd64_windows.yml/badge.svg\n[github_amd64_windows_link]: ./../../actions/workflows/amd64_windows.yml\n[github_amd64_docker_status]: ./../../actions/workflows/amd64_docker.yml/badge.svg\n[github_amd64_docker_link]: ./../../actions/workflows/amd64_docker.yml\n[github_arm64_docker_status]: ./../../actions/workflows/arm64_docker.yml/badge.svg\n[github_arm64_docker_link]: ./../../actions/workflows/arm64_docker.yml\n[github_riscv64_docker_status]: ./../../actions/workflows/riscv64_docker.yml/badge.svg\n[github_riscv64_docker_link]: ./../../actions/workflows/riscv64_docker.yml\n\n# Introduction\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-process\"\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=\"#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 SWIG.\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.18\".\n* \"Python \u003e= 3.6\" and python module 'pip' (ed \"setuptools\" and \"wheel\" will be\n auto installed on demand).\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    * [foo.i](Foo/python/foo.i) SWIG 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    * [bar.i](Bar/python/bar.i) SWIG 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    * [foobar.i](FooBar/python/foobar.i) SWIG 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 SWIG generated\nPython wrappers e.g. `pyfoo.py` 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 pythonnative\n```\n\nIf everything good the package (located in `\u003cbuildir\u003e/python/dist`) should have\nthis layout:\n```\n{...}/dist/pythonnative-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.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\nProject layout:\n* The Pitchfork Layout Revision 1 (cxx-pflR1)\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## 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","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmizux%2Fpython-native","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmizux%2Fpython-native","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmizux%2Fpython-native/lists"}