SlideShare a Scribd company logo
SciPy 2021 - Virtual Maintainers Track
July 16, 2021
Eric Cousineau

Toyota Research Institute

Ralf Grosse-Kunstleve

Google

Axel Huebl

Lawrence Berkeley National Laboratory

Yannick Jadoul

Vrije Universiteit Brussel

Max Planck Institute for Psycholinguistics

Wenzel Jakob

Ecole Polytechnique Fédérale de Lausanne

Henry Schreiner

Princeton University

Boris Staletic

University of Novi Sad
Outline
2
What is pybind11?
Advancements in 2020/2021
Plans for 2021/2022
Related projects we ♥
What is pybind11?
3
Header-only pure C++11 CPython/PyPy interface
Trivial to add to a project
No special build requirements
No dependencies
No precompile phase
Not a new language
(Boost.Python + BJam) (Cython, SWIG) ← Counter examples
Think of it like the missing C++ API for CPython
Designed for one purpose!
Example of usage (simple)
4
#include <pybind11/pybind11.h>


int add(int i, int j) {


return i + j;


}


PYBIND11_MODULE(example, m) {


m.def("add", &add);


}


Standard include
Normal C++ to bind
Create a Python module
Signature statically inferred
Docs and parameter names optional
g++ -shared -fPIC example.cpp $(pipx run pybind11 --includes) -o example$(python3-config --extension-suffix)
Complete, working, no-install example (linux version)!
Example of usage (class)
5
#include <pybind11/pybind11.h>


#include <pybind11/operators.h>


namespace py = pybind11;


using namespace pybind11::literals;


PYBIND11_MODULE(example, m) {


py::class_<Pet>(m, "Pet")


.def(py::init<const std::string &>())


.def("setName", &Pet::setName, "value"_a = "", "docs")


.def("getName", [](const Pet& self){return self.getName();})


.def_property("name", &Pet::getName, &Pet::setName)


.def(py::self *= float());


}
Easy operators
Properties
Names, defaults, docs
Any number of constructors
Lambdas
Unique design
6
Simple enough for tiny projects
491K code mentions of pybind11 on GitHub
Powerful enough for huge projects
SciPy, PyTorch, dozens of Google projects
Small binaries prioritized
Small overload pointer check per call
Powerful object lifetime controls
py::keep_alive, std::shared_ptr, and more
NumPy support without NumPy headers
No need to lock minimum NumPy at build
Supports interop in both directions
Can even be used to embed Python in C++
Most STL containers and features supported
Including C++17 additions, like std::variant (or boost)
Vectorize methods or functions
py::vectorize, even on a lambda function
Trampoline classes and multiple inheritance
Complex C++ is supported
Complete control of the Python representation
Special methods, inheritance, pickling, and more
Bu
ff
er protocol and array classes
Includes Eigen support too
Cross-extension ABI
One extension can return a type wrapped in another one
New maintainer team
7
Wenzel Jakob is the original author
Original team:
Wenzel Jakob

Dean Moldovan

Jason Rhinelander

Ivan Smirnov

Sylvain Corley
New team (starting mid 2020):
Wenzel Jakob (BDFL)

Eric Cousineau

Ralf Grosse-Kunstleve

Axel Huebl

Yannick Jadoul

Henry Schreiner

Boris Staletic (uno
ffi
cial)
Changes this year:
Aaron Gokaslan: new member 👋

Boris Staletic: (mostly) stepped away for now 😢

Wenzel Jakob: moved from BDFL to co-maintainer
New in 2.6: CI
8
Massive rewrite of the CI in GHA, with 60+ jobs covering far more than ever before
Special thanks to Google for funding extra parallel jobs!
Jobs:
Windows, macOS and Linux, Python 2.7-3.9 (3.10 now) & PyPI

GCC (4.8 and several newer), Clang (8 versions), MSVC 2015-2019

ICC, NVCC (CUDA 11), and NVHPC (PGI) 20.9 

CentOS 7 and 8

C++: 11, 14, 17, and 20

Debug build

Valgrind build

Clang-tidy build

CMake con
fi
gure check, 3.4, 3.7, 3.8, and 3.18

Packaging tests verifying every
fi
le in the wheel/SDist
Newly
supported
compilers!
Discovered and
fi
xed
bug in CPython 3.9.0
setup.py
New in 2.6: build systems
9
CMake Setuptools
Integration with standard CMake features
CMake 3.4+ required

Support for newer features (3.18.2+ best)

FindPython optionally supported

CUDA as a language supported and tested

Python discovery can be deactivated

Portable con
fi
g
fi
le (now included in PyPI package)
Helper functions added
Check importable libraries easily

New modular target design
Follows best practices given in

https://cliutils.gitlab.io/modern-cmake
New helpers can be used for easy setuptools support
Proper C++
fl
ags & pybind11 headers
from pybind11.setup_helpers import Pybind11Extension, build_ext


module = Pybind11Extension(


"python_example",


["src/main.cpp"],


cxx_std=11,


)


setup(


...,


ext_modules=ext_modules,


cmdclass={"build_ext": build_ext}, # Optional!


)


Optional parallel compiler utility included
New in 2.6: other
10
py::kw_only and py::pos_only
Support Python 3 keyword only arguments

Support Python 3.8 position only arguments

All from any version of Python (C API)
More correctness checking
Throw errors sooner if a mistake is made
py::final support
Makes a class uninheritable (CPython only)
py::prepend


Add to the beginning of the overload chain
py::type


Access and manipulate the type
More compilers supported
Thanks to broadly expand checking
Many
fi
xes
And docs updates!
py::module → py::module_
Avoid soft keyword in C++20

(old name should always work)
https://iscinumpy.gitlab.io/post/pybind11-2-6-0/
New in 2.7
11
Large clang-tidy cleanups
Readability, better performance, modernization
Optional C++17
fi
lesystem / pathlib caster
3.6+ only feature
In-tree extensions
Not ideal for all users, but mimics Cython’s tool
py::bytearray


Similar to py::bytes
py::str change
Always unicode
Extra GIL safety when C++ calls back into Python
3.6+ only feature
Checks can be run from nox
Easier for new developers to contribute
Fixes
Many rare and edge cases
fi
xed
Development focus: stability, reliability, support for the latest C++/Python changes
New in 2.7
11
Large clang-tidy cleanups
Readability, better performance, modernization
Optional C++17
fi
lesystem / pathlib caster
3.6+ only feature
In-tree extensions
Not ideal for all users, but mimics Cython’s tool
py::bytearray


Similar to py::bytes
py::str change
Always unicode
Extra GIL safety when C++ calls back into Python
3.6+ only feature
Checks can be run from nox
Easier for new developers to contribute
Fixes
Many rare and edge cases
fi
xed
Development focus: stability, reliability, support for the latest C++/Python changes
Released today!
Plans
12
Refactors
Decoupling unit tests

Breaking into smaller, IWUY headers
https://github.com/pybind/pybind11/wiki/Roadmap
Optional Precompilation
Would dramatically speed up compile

Huge change, so being held back by other work
Drop Python 2.7 & 3.5
Either 3.0 or Jan 1, 2022, whichever is
fi
rst
Merge the smart holder branch
Full interoperability with std::unique_ptr and std::shared_ptr

Opt-in with <pybind11/smart_holder.h>

Safe passing to C++, including trampolines
Further ideas (not promised yet)
Better MyPy integration

Better Scikit-build integration

Overhauls for inheritance and type casting
Our other projects
13
pybind/python_example:
A setuptools project using setuptools helpers

and binary wheel builds, conda recipe, and more.
pybind/scikit_build_example:
A CMake project using scikit-build (new for 2.6).
pybind/cmake_example:
A CMake project using manual setuptools integration.

Major cleanup for 2.6, now includes Apple Silicon

support and more.
pybind/pybind11_bazel:
Support for Google’s bazel build system.
pybind/pybind11_mkdoc:
A documentation parser using LLVM.
pybind/pybind11_json:
A nlohmann::json adaptor for pybind11.
pybind/pybind11_abseil:
Adaptor for Google’s abseil project.
pybind/pybind11_protobuf:
Adaptor for Google’s protobuf project.
Support for conda, pip, and
cibuildwheel work
fl
ows on GitHub Actions
Support for Apple Silicon cross-compile
Support for PyPy wheels
Dependabot GHA updates
Template repositories now
pybind11 also was added as an option to

https://github.com/scikit-hep/cookie,

make a new package in <60 seconds based on

https://scikit-hep.org/developer guidelines
Projects we ♥: 🎡 cibuildwheel
.github/work
fl
ows/wheels.yml
pyproject.toml
14
on: [push, pull_request]


jobs:


build_wheels:


runs-on: ${{ matrix.os }}


strategy:


matrix:


os:


- ubuntu-20.04


- windows-2019


- macos-10.15


steps:


- uses: actions/checkout@v2


- name: Build wheels


uses: pypa/cibuildwheel@v2.0.0


- uses: actions/upload-artifact@v2


with:


path: ./wheelhouse/*.whl
[tool.cibuildwheel.macos]


archs: ["x86_64", "universal2"]


test-skip: ["*_universal2:arm64"]
Binary distribution is really important for pybind11 projects.
Maybe then it’s no surprise we share two maintainers with cibuildwheel!
Supports all major CI providers
GitHub Action provided too!

Can run locally on Linux or Windows
A
ffi
liated (shared maintainer) with manylinux
Close collaboration with PyPy devs
Recently accepted into the PyPA!
Used by matplotlib, mypy, scikit-learn, and more
Supports:
Targeting macOS 10.9+

Apple Silicon cross-compiling

All variants of manylinux

Repairing and testing wheels

Sensible, pinned defaults (can unpin)
New in 2.0, release today!
Python 2 & 3.5 removed
Python 3.10 as pre-release
PyPy 7.3.5 (manylinux uni
fi
cation!)

Auditwheel 4
pyproject.toml support
Optional pypa/build support
All pybind examples
include cibuildwheel!
Projects we ♥: scikit-build
15
Scikit-build is a CMake-setuptools adaptor from KitWare, the makers of CMake
First introduced as PyCMake at SciPy 2014 and renamed in 2016

Includes CMake for Python and ninja for Python
We now have a scikit-build example!
Our pybind/cmake_example is one of the most popular
examples of combining CMake and Python on GitHub
Updated now with lots of
fi
xes!
But this duplicates the code for everyone
Adding Apple Silicon support will now have to be

done on every project that copied the example, etc.
Two new maintainers have now joined the project
One from pybind11, one from cibuildwheel/manylinux!
What’s new in scikit-build 0.12 (out soon!)
CI refactor, using GHA, nox, pre-commit

Several
fi
xes (often for Cython)

Apple Silicon support

MSVC 2019 support
What’s planned:
Better integration with pybind11

Better support for PEP 517

Support testing against development versions of Python

Removal of Python 2.7 and 3.5 before or on Jan 1, 2022

See https://github.com/scikit-build/scikit-build/wiki
Same day release of CMake for Python for CMake 3.21.0!
All manylinux archs • Apple Silicon • cibuildwheel • nox
Revamped ninja for Python too
All manylinux archs • cibuildwheel • nox
Acknowledgements
16
Special thank you to Google for sponsoring our expanded CI, and for Ralf Grosse-Kunstleve’s time.

Henry Schreiner supported by IRIS-HEP and the NSF under Cooperative Agreement OAC-1836650

Axel Huebl is with LBNL and supported by the U.S. DOE/NNSA Exascale Computing Project (17-SC-20-SC)

More Related Content

PPTX
Mixing C++ & Python II: Pybind11
PDF
2015年度GPGPU実践基礎工学 第2回 GPGPUの歴史と応用例
PDF
Yahoo! JAPANのコンテンツプラットフォームを支えるSpring Cloud Streamによるマイクロサービスアーキテクチャ #jsug #sf_52
PDF
How A Compiler Works: GNU Toolchain
PDF
続・PFN のオンプレML基盤の取り組み / オンプレML基盤 on Kubernetes 〜PFN、ヤフー〜 #2
PDF
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
PDF
PHP、おまえだったのか。 いつもHTTPメッセージを 運んでくれたのは。
PPTX
Hands on OpenCL
Mixing C++ & Python II: Pybind11
2015年度GPGPU実践基礎工学 第2回 GPGPUの歴史と応用例
Yahoo! JAPANのコンテンツプラットフォームを支えるSpring Cloud Streamによるマイクロサービスアーキテクチャ #jsug #sf_52
How A Compiler Works: GNU Toolchain
続・PFN のオンプレML基盤の取り組み / オンプレML基盤 on Kubernetes 〜PFN、ヤフー〜 #2
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
PHP、おまえだったのか。 いつもHTTPメッセージを 運んでくれたのは。
Hands on OpenCL

What's hot (20)

PDF
Applied Computer Science Concepts in Android
PDF
Hopper アーキテクチャで、変わること、変わらないこと
PDF
Responsableを使ったadr実装
PDF
GDB Rocks!
PDF
分散学習のあれこれ~データパラレルからモデルパラレルまで~
PDF
いまさら聞けない!CUDA高速化入門
PPTX
とあるセキュリティ会社のIoTセキュリティチームの日常(ErrataはDescription参照)
PDF
名は体を表していますか
PDF
使用 Keras, Tensorflow 進行分散式訓練初探 (Distributed Training in Keras and Tensorflow)
PDF
ネットワーク自動化、なに使う? ~自動化ツール紹介~ (2017/07/21開催)
PDF
Threads and Callbacks for Embedded Python
PDF
NVIDIA HPC ソフトウエア斜め読み
PDF
FPGAアクセラレータの作り方
PDF
パフォーマンス ボトルネック 国内あるある事例
PDF
ゼロから始めるQ#
PDF
CUDAのアセンブリ言語基礎のまとめ PTXとSASSの概説
PPTX
root権限無しでKubernetesを動かす
PDF
C#×LLVM=アセンブラ!? 〜詳説・Burstコンパイラー〜
PDF
C++の話(本当にあった怖い話)
PPTX
Understand more about C
Applied Computer Science Concepts in Android
Hopper アーキテクチャで、変わること、変わらないこと
Responsableを使ったadr実装
GDB Rocks!
分散学習のあれこれ~データパラレルからモデルパラレルまで~
いまさら聞けない!CUDA高速化入門
とあるセキュリティ会社のIoTセキュリティチームの日常(ErrataはDescription参照)
名は体を表していますか
使用 Keras, Tensorflow 進行分散式訓練初探 (Distributed Training in Keras and Tensorflow)
ネットワーク自動化、なに使う? ~自動化ツール紹介~ (2017/07/21開催)
Threads and Callbacks for Embedded Python
NVIDIA HPC ソフトウエア斜め読み
FPGAアクセラレータの作り方
パフォーマンス ボトルネック 国内あるある事例
ゼロから始めるQ#
CUDAのアセンブリ言語基礎のまとめ PTXとSASSの概説
root権限無しでKubernetesを動かす
C#×LLVM=アセンブラ!? 〜詳説・Burstコンパイラー〜
C++の話(本当にあった怖い話)
Understand more about C
Ad

Similar to Pybind11 - SciPy 2021 (20)

PDF
SciPy22 - Building binary extensions with pybind11, scikit build, and cibuild...
PDF
PyCon2022 - Building Python Extensions
PPTX
Kostiantyn Grygoriev "Wrapping C++ for Python"
PDF
PyHEP 2018: Tools to bind to Python
PDF
Modern binary build systems - PyCon 2024
PDF
Development_C_Extension_with_Pybind11.pdf
PDF
Kyrylo Cherneha "C++ & Python Interaction in Automotive Industry"
PDF
Princeton RSE Peer network first meeting
PDF
Notes about moving from python to c++ py contw 2020
PPTX
Python with a SWIG of c++
PDF
SciPy 2022 Scikit-HEP
PDF
Interfacing C++ with Python to boost your legacy apps with Python interfaces
PDF
Start Wrap Episode 11: A New Rope
PDF
Cluj.py Meetup: Extending Python in C
PDF
PySide
PDF
Interactive C++ code development using C++Explorer and GitHub Classroom for e...
PDF
Extending Python - EuroPython 2014
PDF
Pigaios: A Tool for Diffing Source Codes against Binaries (Hacktivity 2018)
PPTX
Python Bindings Overview
PDF
Take advantage of C++ from Python
SciPy22 - Building binary extensions with pybind11, scikit build, and cibuild...
PyCon2022 - Building Python Extensions
Kostiantyn Grygoriev "Wrapping C++ for Python"
PyHEP 2018: Tools to bind to Python
Modern binary build systems - PyCon 2024
Development_C_Extension_with_Pybind11.pdf
Kyrylo Cherneha "C++ & Python Interaction in Automotive Industry"
Princeton RSE Peer network first meeting
Notes about moving from python to c++ py contw 2020
Python with a SWIG of c++
SciPy 2022 Scikit-HEP
Interfacing C++ with Python to boost your legacy apps with Python interfaces
Start Wrap Episode 11: A New Rope
Cluj.py Meetup: Extending Python in C
PySide
Interactive C++ code development using C++Explorer and GitHub Classroom for e...
Extending Python - EuroPython 2014
Pigaios: A Tool for Diffing Source Codes against Binaries (Hacktivity 2018)
Python Bindings Overview
Take advantage of C++ from Python
Ad

More from Henry Schreiner (20)

PDF
SciPy 2025 - Packaging a Scientific Python Project
PDF
Tools That Help You Write Better Code - 2025 Princeton Software Engineering S...
PDF
Princeton RSE: Building Python Packages (+binary)
PDF
Tools to help you write better code - Princeton Wintersession
PDF
Learning Rust with Advent of Code 2023 - Princeton
PDF
The two flavors of Python 3.13 - PyHEP 2024
PDF
Software Quality Assurance Tooling - Wintersession 2024
PDF
Software Quality Assurance Tooling 2023
PDF
Princeton Wintersession: Software Quality Assurance Tooling
PDF
What's new in Python 3.11
PDF
Everything you didn't know you needed
PDF
PyCon 2022 -Scikit-HEP Developer Pages: Guidelines for modern packaging
PDF
boost-histogram / Hist: PyHEP Topical meeting
PDF
Digital RSE: automated code quality checks - RSE group meeting
PDF
CMake best practices
PDF
RDM 2020: Python, Numpy, and Pandas
PDF
HOW 2019: Machine Learning for the Primary Vertex Reconstruction
PDF
HOW 2019: A complete reproducible ROOT environment in under 5 minutes
PDF
ACAT 2019: A hybrid deep learning approach to vertexing
PDF
2019 CtD: A hybrid deep learning approach to vertexing
SciPy 2025 - Packaging a Scientific Python Project
Tools That Help You Write Better Code - 2025 Princeton Software Engineering S...
Princeton RSE: Building Python Packages (+binary)
Tools to help you write better code - Princeton Wintersession
Learning Rust with Advent of Code 2023 - Princeton
The two flavors of Python 3.13 - PyHEP 2024
Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling 2023
Princeton Wintersession: Software Quality Assurance Tooling
What's new in Python 3.11
Everything you didn't know you needed
PyCon 2022 -Scikit-HEP Developer Pages: Guidelines for modern packaging
boost-histogram / Hist: PyHEP Topical meeting
Digital RSE: automated code quality checks - RSE group meeting
CMake best practices
RDM 2020: Python, Numpy, and Pandas
HOW 2019: Machine Learning for the Primary Vertex Reconstruction
HOW 2019: A complete reproducible ROOT environment in under 5 minutes
ACAT 2019: A hybrid deep learning approach to vertexing
2019 CtD: A hybrid deep learning approach to vertexing

Recently uploaded (20)

PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
AI in Product Development-omnex systems
PPTX
Online Work Permit System for Fast Permit Processing
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
top salesforce developer skills in 2025.pdf
PPTX
Introduction to Artificial Intelligence
PDF
Digital Strategies for Manufacturing Companies
PDF
medical staffing services at VALiNTRY
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPT
Introduction Database Management System for Course Database
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
history of c programming in notes for students .pptx
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Nekopoi APK 2025 free lastest update
PPTX
L1 - Introduction to python Backend.pptx
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
ManageIQ - Sprint 268 Review - Slide Deck
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
AI in Product Development-omnex systems
Online Work Permit System for Fast Permit Processing
How to Choose the Right IT Partner for Your Business in Malaysia
top salesforce developer skills in 2025.pdf
Introduction to Artificial Intelligence
Digital Strategies for Manufacturing Companies
medical staffing services at VALiNTRY
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Softaken Excel to vCard Converter Software.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Design an Analysis of Algorithms II-SECS-1021-03
Introduction Database Management System for Course Database
VVF-Customer-Presentation2025-Ver1.9.pptx
history of c programming in notes for students .pptx
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Nekopoi APK 2025 free lastest update
L1 - Introduction to python Backend.pptx
Upgrade and Innovation Strategies for SAP ERP Customers

Pybind11 - SciPy 2021

  • 1. SciPy 2021 - Virtual Maintainers Track July 16, 2021 Eric Cousineau Toyota Research Institute Ralf Grosse-Kunstleve Google Axel Huebl Lawrence Berkeley National Laboratory Yannick Jadoul Vrije Universiteit Brussel
 Max Planck Institute for Psycholinguistics Wenzel Jakob Ecole Polytechnique Fédérale de Lausanne Henry Schreiner Princeton University Boris Staletic University of Novi Sad
  • 2. Outline 2 What is pybind11? Advancements in 2020/2021 Plans for 2021/2022 Related projects we ♥
  • 3. What is pybind11? 3 Header-only pure C++11 CPython/PyPy interface Trivial to add to a project No special build requirements No dependencies No precompile phase Not a new language (Boost.Python + BJam) (Cython, SWIG) ← Counter examples Think of it like the missing C++ API for CPython Designed for one purpose!
  • 4. Example of usage (simple) 4 #include <pybind11/pybind11.h> int add(int i, int j) { return i + j; } PYBIND11_MODULE(example, m) { m.def("add", &add); } Standard include Normal C++ to bind Create a Python module Signature statically inferred Docs and parameter names optional g++ -shared -fPIC example.cpp $(pipx run pybind11 --includes) -o example$(python3-config --extension-suffix) Complete, working, no-install example (linux version)!
  • 5. Example of usage (class) 5 #include <pybind11/pybind11.h> #include <pybind11/operators.h> namespace py = pybind11; using namespace pybind11::literals; PYBIND11_MODULE(example, m) { py::class_<Pet>(m, "Pet") .def(py::init<const std::string &>()) .def("setName", &Pet::setName, "value"_a = "", "docs") .def("getName", [](const Pet& self){return self.getName();}) .def_property("name", &Pet::getName, &Pet::setName) .def(py::self *= float()); } Easy operators Properties Names, defaults, docs Any number of constructors Lambdas
  • 6. Unique design 6 Simple enough for tiny projects 491K code mentions of pybind11 on GitHub Powerful enough for huge projects SciPy, PyTorch, dozens of Google projects Small binaries prioritized Small overload pointer check per call Powerful object lifetime controls py::keep_alive, std::shared_ptr, and more NumPy support without NumPy headers No need to lock minimum NumPy at build Supports interop in both directions Can even be used to embed Python in C++ Most STL containers and features supported Including C++17 additions, like std::variant (or boost) Vectorize methods or functions py::vectorize, even on a lambda function Trampoline classes and multiple inheritance Complex C++ is supported Complete control of the Python representation Special methods, inheritance, pickling, and more Bu ff er protocol and array classes Includes Eigen support too Cross-extension ABI One extension can return a type wrapped in another one
  • 7. New maintainer team 7 Wenzel Jakob is the original author Original team: Wenzel Jakob Dean Moldovan Jason Rhinelander Ivan Smirnov Sylvain Corley New team (starting mid 2020): Wenzel Jakob (BDFL) Eric Cousineau Ralf Grosse-Kunstleve Axel Huebl
 Yannick Jadoul
 Henry Schreiner Boris Staletic (uno ffi cial) Changes this year: Aaron Gokaslan: new member 👋 Boris Staletic: (mostly) stepped away for now 😢 Wenzel Jakob: moved from BDFL to co-maintainer
  • 8. New in 2.6: CI 8 Massive rewrite of the CI in GHA, with 60+ jobs covering far more than ever before Special thanks to Google for funding extra parallel jobs! Jobs: Windows, macOS and Linux, Python 2.7-3.9 (3.10 now) & PyPI GCC (4.8 and several newer), Clang (8 versions), MSVC 2015-2019 ICC, NVCC (CUDA 11), and NVHPC (PGI) 20.9 CentOS 7 and 8 C++: 11, 14, 17, and 20 Debug build Valgrind build Clang-tidy build CMake con fi gure check, 3.4, 3.7, 3.8, and 3.18 Packaging tests verifying every fi le in the wheel/SDist Newly supported compilers! Discovered and fi xed bug in CPython 3.9.0
  • 9. setup.py New in 2.6: build systems 9 CMake Setuptools Integration with standard CMake features CMake 3.4+ required Support for newer features (3.18.2+ best) FindPython optionally supported CUDA as a language supported and tested Python discovery can be deactivated Portable con fi g fi le (now included in PyPI package) Helper functions added Check importable libraries easily New modular target design Follows best practices given in https://cliutils.gitlab.io/modern-cmake New helpers can be used for easy setuptools support Proper C++ fl ags & pybind11 headers from pybind11.setup_helpers import Pybind11Extension, build_ext module = Pybind11Extension( "python_example", ["src/main.cpp"], cxx_std=11, ) setup( ..., ext_modules=ext_modules, cmdclass={"build_ext": build_ext}, # Optional! ) Optional parallel compiler utility included
  • 10. New in 2.6: other 10 py::kw_only and py::pos_only Support Python 3 keyword only arguments Support Python 3.8 position only arguments All from any version of Python (C API) More correctness checking Throw errors sooner if a mistake is made py::final support Makes a class uninheritable (CPython only) py::prepend Add to the beginning of the overload chain py::type Access and manipulate the type More compilers supported Thanks to broadly expand checking Many fi xes And docs updates! py::module → py::module_ Avoid soft keyword in C++20 (old name should always work) https://iscinumpy.gitlab.io/post/pybind11-2-6-0/
  • 11. New in 2.7 11 Large clang-tidy cleanups Readability, better performance, modernization Optional C++17 fi lesystem / pathlib caster 3.6+ only feature In-tree extensions Not ideal for all users, but mimics Cython’s tool py::bytearray Similar to py::bytes py::str change Always unicode Extra GIL safety when C++ calls back into Python 3.6+ only feature Checks can be run from nox Easier for new developers to contribute Fixes Many rare and edge cases fi xed Development focus: stability, reliability, support for the latest C++/Python changes
  • 12. New in 2.7 11 Large clang-tidy cleanups Readability, better performance, modernization Optional C++17 fi lesystem / pathlib caster 3.6+ only feature In-tree extensions Not ideal for all users, but mimics Cython’s tool py::bytearray Similar to py::bytes py::str change Always unicode Extra GIL safety when C++ calls back into Python 3.6+ only feature Checks can be run from nox Easier for new developers to contribute Fixes Many rare and edge cases fi xed Development focus: stability, reliability, support for the latest C++/Python changes Released today!
  • 13. Plans 12 Refactors Decoupling unit tests Breaking into smaller, IWUY headers https://github.com/pybind/pybind11/wiki/Roadmap Optional Precompilation Would dramatically speed up compile Huge change, so being held back by other work Drop Python 2.7 & 3.5 Either 3.0 or Jan 1, 2022, whichever is fi rst Merge the smart holder branch Full interoperability with std::unique_ptr and std::shared_ptr Opt-in with <pybind11/smart_holder.h> Safe passing to C++, including trampolines Further ideas (not promised yet) Better MyPy integration Better Scikit-build integration Overhauls for inheritance and type casting
  • 14. Our other projects 13 pybind/python_example: A setuptools project using setuptools helpers and binary wheel builds, conda recipe, and more. pybind/scikit_build_example: A CMake project using scikit-build (new for 2.6). pybind/cmake_example: A CMake project using manual setuptools integration. Major cleanup for 2.6, now includes Apple Silicon support and more. pybind/pybind11_bazel: Support for Google’s bazel build system. pybind/pybind11_mkdoc: A documentation parser using LLVM. pybind/pybind11_json: A nlohmann::json adaptor for pybind11. pybind/pybind11_abseil: Adaptor for Google’s abseil project. pybind/pybind11_protobuf: Adaptor for Google’s protobuf project. Support for conda, pip, and cibuildwheel work fl ows on GitHub Actions Support for Apple Silicon cross-compile Support for PyPy wheels Dependabot GHA updates Template repositories now pybind11 also was added as an option to https://github.com/scikit-hep/cookie, make a new package in <60 seconds based on https://scikit-hep.org/developer guidelines
  • 15. Projects we ♥: 🎡 cibuildwheel .github/work fl ows/wheels.yml pyproject.toml 14 on: [push, pull_request] jobs: build_wheels: runs-on: ${{ matrix.os }} strategy: matrix: os: - ubuntu-20.04 - windows-2019 - macos-10.15 steps: - uses: actions/checkout@v2 - name: Build wheels uses: pypa/cibuildwheel@v2.0.0 - uses: actions/upload-artifact@v2 with: path: ./wheelhouse/*.whl [tool.cibuildwheel.macos] archs: ["x86_64", "universal2"] test-skip: ["*_universal2:arm64"] Binary distribution is really important for pybind11 projects. Maybe then it’s no surprise we share two maintainers with cibuildwheel! Supports all major CI providers GitHub Action provided too! Can run locally on Linux or Windows A ffi liated (shared maintainer) with manylinux Close collaboration with PyPy devs Recently accepted into the PyPA! Used by matplotlib, mypy, scikit-learn, and more Supports: Targeting macOS 10.9+ Apple Silicon cross-compiling All variants of manylinux Repairing and testing wheels Sensible, pinned defaults (can unpin) New in 2.0, release today! Python 2 & 3.5 removed Python 3.10 as pre-release PyPy 7.3.5 (manylinux uni fi cation!) Auditwheel 4 pyproject.toml support Optional pypa/build support All pybind examples include cibuildwheel!
  • 16. Projects we ♥: scikit-build 15 Scikit-build is a CMake-setuptools adaptor from KitWare, the makers of CMake First introduced as PyCMake at SciPy 2014 and renamed in 2016 Includes CMake for Python and ninja for Python We now have a scikit-build example! Our pybind/cmake_example is one of the most popular examples of combining CMake and Python on GitHub Updated now with lots of fi xes! But this duplicates the code for everyone Adding Apple Silicon support will now have to be done on every project that copied the example, etc. Two new maintainers have now joined the project One from pybind11, one from cibuildwheel/manylinux! What’s new in scikit-build 0.12 (out soon!) CI refactor, using GHA, nox, pre-commit Several fi xes (often for Cython) Apple Silicon support MSVC 2019 support What’s planned: Better integration with pybind11 Better support for PEP 517 Support testing against development versions of Python Removal of Python 2.7 and 3.5 before or on Jan 1, 2022 See https://github.com/scikit-build/scikit-build/wiki Same day release of CMake for Python for CMake 3.21.0! All manylinux archs • Apple Silicon • cibuildwheel • nox Revamped ninja for Python too All manylinux archs • cibuildwheel • nox
  • 17. Acknowledgements 16 Special thank you to Google for sponsoring our expanded CI, and for Ralf Grosse-Kunstleve’s time. Henry Schreiner supported by IRIS-HEP and the NSF under Cooperative Agreement OAC-1836650 Axel Huebl is with LBNL and supported by the U.S. DOE/NNSA Exascale Computing Project (17-SC-20-SC)