GithubHelp home page GithubHelp logo

paperstiger / pybind11_package_example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xflash96/pybind11_package_example

0.0 1.0 0.0 378 KB

Example python package with pybind11 cpp extension

License: MIT License

Python 59.10% Dockerfile 13.97% Shell 6.22% C++ 19.41% C 1.30%

pybind11_package_example's Introduction

Developing C++ extension in Python using pybind11

This is a summary of the commands used in the tutorial. To clone the repository and the submodules, run

git clone --recursive https://github.com/xflash96/pybind11_package_example

Using the Docker developing environment

  • To build the docker image, run cd docker && ./build.sh
  • To run the container, ./run.sh .

See the docker/Dockerfile for the details.

Building the extension and installing the package

  • To build the C++ extension, run python setup.py build_ext -i
  • To install the package, run sudo `which python` setup.py develop

Profiling

line_profiler for the Python code

  • Mark the @profile to the function of interest.
  • Run the profiler via kernprof -l ./bin/example_cmd
  • See the report with python -m line_profiler example_cmd.lprof

Perf for the C++ extension

  • Enable perf in Linux by sudo sh -c 'echo 1 >/proc/sys/kernel/perf_event_paranoid'
  • Profile via perf record bin/example_cmd
  • Show report with perf report

Testing

Use either

  • python setup.py test
  • pytest to run the unit tests.

Releasing the package

  • Pack the source distribution with python setup.py sdist
  • Upload the package with python -m twine upload --repository testpypi dist/*

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.