{"id":17744007,"url":"https://github.com/andreibarsan/python-bindings","last_synced_at":"2025-04-01T01:45:07.664Z","repository":{"id":142990420,"uuid":"242641726","full_name":"AndreiBarsan/python-bindings","owner":"AndreiBarsan","description":"Simple CMake + boost-python + NumPy project sample.","archived":false,"fork":false,"pushed_at":"2020-02-24T04:39:44.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-03-15T23:10:18.964Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AndreiBarsan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-24T03:53:49.000Z","updated_at":"2020-02-24T04:39:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"f411b8fa-c1c2-404d-b6c1-fc98170198da","html_url":"https://github.com/AndreiBarsan/python-bindings","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/AndreiBarsan%2Fpython-bindings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndreiBarsan%2Fpython-bindings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndreiBarsan%2Fpython-bindings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndreiBarsan%2Fpython-bindings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AndreiBarsan","download_url":"https://codeload.github.com/AndreiBarsan/python-bindings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246569006,"owners_count":20798341,"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":[],"created_at":"2024-10-26T06:41:41.538Z","updated_at":"2025-04-01T01:45:07.648Z","avatar_url":"https://github.com/AndreiBarsan.png","language":"C++","readme":"# Mini boost-python CMake project\n\nA simple project skeleton which can build native C++ code using CMake and boost-python and pass NumPy arrays back and forth. I wrote this in Feb 2020 to teach myself the basics of boost-python.\n\nThe most key elements are in `native/CMakeLists.txt` and `native/__init__.py`.\n\nThere are probably better ways of organizing the code (cf. the Pytorch source code, for instance), but this should work OK for smaller projects.\n\n## Minimal Instructions\n\n0. Install `cmake` (\u003e=2.8) and `libbost-python`, `libboost-numpy` as well as a modern Python with NumPy.\n1. Build the native code.\n    (You may need to explicily point to the proper Python installation if you're using, e.g., Anaconda and the build fails or the code crashes (pass `-DPYTHON_EXECUTABLE=... -DPYTHON_INCLUDE_DIR=... -DPYTHON_LIBRARY=...` to `cmake`).)\n    ```bash\n    mkdir build \u0026\u0026 cd $_ \u0026\u0026 cmake .. \n    ```\n2. From the project root, run `main.py` with the same Python you built against. You should see something like:\n```\nCalling native function...\nHello from C++\n13\n--------------------------------------------------------------------------------\nCalling helper function from binding module...\nHello, I'm a Python helper...\nHello from C++\n13\n--------------------------------------------------------------------------------\n(Python) Calling native module with np array of shape: ((5, 5))\n(C++) Old shape: [5, 5]\n(C++) Dtype:     float64\n(C++) New shape: [25, 1]\n(Python) Resulting shape: (25, 1)\n```\nThis means the code is now able to pass arrays back and forth between Python and C++!","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreibarsan%2Fpython-bindings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreibarsan%2Fpython-bindings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreibarsan%2Fpython-bindings/lists"}