Skip to content
/ python_example Public template
forked from pybind/python_example

Example pybind11 module built with a Python-based build system

License

Notifications You must be signed in to change notification settings

CreamyLong/python_example

 
 

Repository files navigation

python_example

c++ direct call from python

cuda call from python

compile the cuda code

nvcc -m64 -arch=sm_75 -o  addgpu.dll -Xcompiler "/LD /D_USRDLL /D_WINDLL" add.cu

https://zhuanlan.zhihu.com/p/646734746 https://cloud.tencent.com/developer/article/1944944
https://github.com/PWhiddy/pybind11-cuda

thrid-party library call from python

https://zhuanlan.zhihu.com/p/110465274

torch extension call from python

https://godweiyang.com/2021/03/18/torch-cpp-cuda/

c++ direct call from C++

Gitter

CI status
Linux/macOS Travis Travis-CI
MSVC 2019 AppVeyor
conda.recipe Conda Actions Status
pip builds Pip Actions Status
cibuildwheel Wheels Actions Status

An example project built with pybind11. This requires Python 3.7+; for older versions of Python, check the commit history.

Installation

  • clone this repository
  • pip install ./python_example

CI Examples

There are examples for CI in .github/workflows. A simple way to produces binary "wheels" for all platforms is illustrated in the "wheels.yml" file, using cibuildwheel. You can also see a basic recipe for building and testing in pip.yml, and conda.yml has an example of a conda recipe build.

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 python_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 python_example
python_example.add(1, 2)

About

Example pybind11 module built with a Python-based build system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 62.4%
  • C++ 37.6%