Example python package with pybind11 cpp extension

Overview

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/*
You might also like...
That is a example of a Book app on Python, made with support of all JS libraries on React framework
That is a example of a Book app on Python, made with support of all JS libraries on React framework

React+Python Books App You can use this repository whenever you want Used for a video Create the database: python -m dbutils Start the web server: pyt

This is a survey of python's async concurrency features by example.

Survey of Python's Async Features This is a survey of python's async concurrency features by example. The purpose of this survey is to demonstrate tha

A Python3 script to decode an encoded VBScript file, often seen with a .vbe file extension

vbe-decoder.py Decode one or multiple encoded VBScript files, often seen with a .vbe file extension. Usage usage: vbe-decoder.py [-h] [-o output] file

The purpose of this script is to bypass disablefund, provide some useful information, and dig the hook function of PHP extension.
The purpose of this script is to bypass disablefund, provide some useful information, and dig the hook function of PHP extension.

The purpose of this script is to bypass disablefund, provide some useful information, and dig the hook function of PHP extension.

This is a vscode extension with a Virtual Assistant that you can play with when you are bored or you need help..

VS Code Virtual Assistant This is a vscode extension with a Virtual Assistant that you can play with when you are bored or you need help. Its currentl

Broken Link Finder is a Burp Extension to detect broken links for a passive scanning domains and links.
Broken Link Finder is a Burp Extension to detect broken links for a passive scanning domains and links.

Broken Link Finder Broken Link Finder is a Burp Extension to detect broken links for a passive scanning domains and links. Inspired by InitRoot's link

A git extension for seeing your Cloud Build deployment

A git extension for seeing your Cloud Build deployment

This is a Fava extension to display a grouped portfolio view in Fava for a set of Beancount accounts.
This is a Fava extension to display a grouped portfolio view in Fava for a set of Beancount accounts.

Fava Portfolio Summary This is a Fava extension to display a grouped portfolio view in Fava for a set of Beancount accounts. It can also calculate MWR

Keyboard Layout Change - Extension for Ulauncher

Keyboard Layout Change - Extension for Ulauncher

Owner
null
This is a library which aiming to save all my code about cpp. It will help me to code conveniently.

This is a library which aiming to save all my code about cpp. It will help me to code conveniently.

Paul Leo 21 Dec 6, 2021
An example of python package

An example of python package Why use packages? It is a good practice to not code the same function twice, and to reuse common code from one python scr

null 10 Oct 18, 2022
This is an example manipulation package of for a robot manipulator based on Drake with ROS2.

This is an example manipulation package of for a robot manipulator based on Drake with ROS2.

Sotaro Katayama 1 Oct 21, 2021
A test repository to build a python package and publish the package to Artifact Registry using GCB

A test repository to build a python package and publish the package to Artifact Registry using GCB. Then have the package be a dependency in a GCF function.

null 1 Feb 9, 2022
An extension for Arma 3 that lets you write extensions in Python 3

An Arma 3 extension that lets you to write python extensions for Arma 3. And it's really simple and straightforward to use!

Lukasz Taczuk 48 Dec 18, 2022
Functional collections extension functions for Python

pyfuncol pyfuncol Installation Usage API Documentation Compatibility Contributing License A Python functional collections library. It extends collecti

Andrea Veneziano 32 Nov 16, 2022
Python Example Project Structure

Python Example Project Structure Example of statuses that can be in readme: Visit my docs for the full documentation, examples and guides. With this p

null 1 Oct 31, 2021
An example of Connecting a MySQL Database with Python Code

An example of Connecting a MySQL Database with Python Code And How to install Table of contents General info Technologies Setup General info In this p

Mohammad Hosseinzadeh 1 Nov 23, 2021
An example of Connecting a MySQL Database with Python Code

An example of Connecting And Query Data a MySQL Database with Python Code And How to install Table of contents General info Technologies Setup General

Mohammad Hosseinzadeh 1 Nov 23, 2021
Buffer overflow example for python

Buffer overflow example for python

Mehmet 1 Jan 4, 2022