Projects report - @henryiii
Henry Schreiner - 11-13-2023
https://iscinumpy.dev
Scientific-Python
Development Guide
Built from the Scikit-HEP work at the
2023 Scientific-Python Developer’s
Summit
Merged with cookie & sp-repo-review
from Scikit-HEP (later slides)
Over a dozen in-depth guide page on
topics like producing compiled wheels
in GitHub Actions
Kept up to date with the latest
recommendations (like PyPI Trusted
Publishers and ruff-format tabs)
Recently featured on Python Bytes and
The Real Python Podcast!
Scientific-Python
Development Guide
Built from the Scikit-HEP work at the
2023 Scientific-Python Developer’s
Summit
Merged with cookie & sp-repo-review
from Scikit-HEP (later slides)
Over a dozen in-depth guide page on
topics like producing compiled wheels
in GitHub Actions
Kept up to date with the latest
recommendations (like PyPI Trusted
Publishers and ruff-format tabs)
Recently featured on Python Bytes and
The Real Python Podcast!
Scientific-Python
Development Guide
Built from the Scikit-HEP work at the
2023 Scientific-Python Developer’s
Summit
Merged with cookie & sp-repo-review
from Scikit-HEP (later slides)
Over a dozen in-depth guide page on
topics like producing compiled wheels
in GitHub Actions
Kept up to date with the latest
recommendations (like PyPI Trusted
Publishers and ruff-format tabs)
Recently featured on Python Bytes and
The Real Python Podcast!
Scientific-Python cookie
pipx run cookiecutter gh:scientific-python/cookie
Optional, but learn pipx if you
don’t already use it daily!
Or copier, or cruft
Scientific-Python
cookie
Over 10 build backends, including
compiled C++ or Rust
Selection of license and VCS
versioning (most backends)
In-sync with Development Guide (some
parts actually rendered into the guide)
Generation tested with nox in CI
Pre-commit & GHA updated weekly
repo-review &
sp-repo-review
repo-review: unbiased Python 3.10+
framework for checking repo
configuration (no checks)
sp-repo-review: plugin with checks
based on the dev guide (part of the
same repo, like cookie)
Checks are linked to matching badges
throughout the guide
Runs in WebAssembly too, so
embedded directly in the guide too!
Validate-pyproject also has plugin
I’m working on the
Python & C++
development story
And a lot has and is happening…
Overall Picture
I’m working on each part.
Bindings to
CPython / PyPy
Build system C++ code
Binary
Redistributable
binaries
Build tool(s)
Build
configuration
pybind11
(& nanobind)
The “missing” C++ bindings for
CPython/PyPy
Header-only, zero dependency
Supports NumPy without the headers
Great CMake & Meson support
Three example repos (setuptools,
CMake, scikit-build-core build
systems)
Extensive CI testing & static checks
Used by SciPy, PyTorch, Google, etc.
C++17, CPython 3.8+
Only simple C++ constructs
(design for bindings)
Limited API / Stable ABI 3.12+
#include <pybind11/pybind11.h>
namespace py = pybind11;
int add(int i, int j) {
return i + j;
}
PYBIND11_MODULE(python_example, m) {
m.def("add", &add);
m.def("subtract", [](int i, int j) { return i - j; });
}
BONUS project: I’m not a maintainer, but help out occasionally
scikit-build
CMake - Python bridge for building
extensions
50% of my time for three years (NSF
grant)
Introduced scikit-build-core last year:
modern, static-config backend
Over 200 users now (vs. ~900
scikit-build classic users)
Family of tools: scikit-build (classic),
scikit-build-core, cmake, ninja,
moderncmakedomain, etc.
[build-system]
requires = ["scikit-build-core"]
build-backend = "scikit_build_core.build"
[project]
name = "example"
version = "0.0.1"
cmake_minimum_required(VERSION 3.15...3.27)
project(example LANGUAGES C)
find_package(Python REQUIRED COMPONENTS
Interpreter Development.Module REQUIRED)
Python_add_library(_module MODULE src/module.c WITH_SOABI)
install(TARGETS _module DESTINATION example)
pyproject.toml
CMakeLists.txt
scikit-build-core: features
Powerful config system
Impl: declarative dataclasses + transformer
- Pyproject, config-settings, and env
- Generates JSONSchema
- Generates readme docs
Overrides (like cibuildwheel & mypy)
Automatic cmake/ninja
Only adds the wheels as build dependencies
if required (not on system already)
- Supports WebAssembly, BSD, etc.
- Can set min CMake version required
Features hard with setuptools
Conditional Stable ABI / Limited ABI
macOS compatibility tags
Write to optional wheel dirs (ex: headers)
Experimental editable mode, with auto-rebuild
Extra goodies
Auto inclusion of site-packages in prefix path
Entry points for custom CMake modules
FindPython auto-backport
Dynamic metadata plugin system
build
pipx run build
The official replacement for python setup.py sdist and pip wheel .
Released 1.0!
Supports any backend
cibuildwheel
Builds wheels on CI and locally
CPython 3.6-3.12, PyPy 3.7-3.10
macOS, Windows, manylinux, musllinux
All OS’s: 64-bit Intel, 32-bit Intel, ARM
Linux: ppc64le & s390x too (emulated)
Tested on GHA, Azure, Travis, AppVeyor,
Circle CI, GitLab CI, Cirrus CI
Config via env or pyproject.toml
Can run tests after building wheel
See my blog for recipe to auto-generate
build matrix!
on: [push, pull_request]
jobs:
build_wheels:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: pypa/cibuildwheel@v2.16.2
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
.github/workflows/wheel.yml
pyproject.toml
[tool.cibuildwheel]
test-extras = ["test"]
test-command = "pytest {project}/tests"
My other projects
github.com/henryiii
iscinumpy.dev
scikit-hep.org
Boost-histogram, Hist, UHI, and
uproot-browser (Histograms in Python)
CLI11: C++’s most powerful argument
parser

Princeton RSE Peer network first meeting

  • 1.
    Projects report -@henryiii Henry Schreiner - 11-13-2023 https://iscinumpy.dev
  • 2.
    Scientific-Python Development Guide Built fromthe Scikit-HEP work at the 2023 Scientific-Python Developer’s Summit Merged with cookie & sp-repo-review from Scikit-HEP (later slides) Over a dozen in-depth guide page on topics like producing compiled wheels in GitHub Actions Kept up to date with the latest recommendations (like PyPI Trusted Publishers and ruff-format tabs) Recently featured on Python Bytes and The Real Python Podcast!
  • 3.
    Scientific-Python Development Guide Built fromthe Scikit-HEP work at the 2023 Scientific-Python Developer’s Summit Merged with cookie & sp-repo-review from Scikit-HEP (later slides) Over a dozen in-depth guide page on topics like producing compiled wheels in GitHub Actions Kept up to date with the latest recommendations (like PyPI Trusted Publishers and ruff-format tabs) Recently featured on Python Bytes and The Real Python Podcast!
  • 4.
    Scientific-Python Development Guide Built fromthe Scikit-HEP work at the 2023 Scientific-Python Developer’s Summit Merged with cookie & sp-repo-review from Scikit-HEP (later slides) Over a dozen in-depth guide page on topics like producing compiled wheels in GitHub Actions Kept up to date with the latest recommendations (like PyPI Trusted Publishers and ruff-format tabs) Recently featured on Python Bytes and The Real Python Podcast!
  • 5.
    Scientific-Python cookie pipx runcookiecutter gh:scientific-python/cookie Optional, but learn pipx if you don’t already use it daily! Or copier, or cruft
  • 6.
    Scientific-Python cookie Over 10 buildbackends, including compiled C++ or Rust Selection of license and VCS versioning (most backends) In-sync with Development Guide (some parts actually rendered into the guide) Generation tested with nox in CI Pre-commit & GHA updated weekly
  • 7.
    repo-review & sp-repo-review repo-review: unbiasedPython 3.10+ framework for checking repo configuration (no checks) sp-repo-review: plugin with checks based on the dev guide (part of the same repo, like cookie) Checks are linked to matching badges throughout the guide Runs in WebAssembly too, so embedded directly in the guide too! Validate-pyproject also has plugin
  • 8.
    I’m working onthe Python & C++ development story And a lot has and is happening…
  • 9.
    Overall Picture I’m workingon each part. Bindings to CPython / PyPy Build system C++ code Binary Redistributable binaries Build tool(s) Build configuration
  • 10.
    pybind11 (& nanobind) The “missing”C++ bindings for CPython/PyPy Header-only, zero dependency Supports NumPy without the headers Great CMake & Meson support Three example repos (setuptools, CMake, scikit-build-core build systems) Extensive CI testing & static checks Used by SciPy, PyTorch, Google, etc. C++17, CPython 3.8+ Only simple C++ constructs (design for bindings) Limited API / Stable ABI 3.12+ #include <pybind11/pybind11.h> namespace py = pybind11; int add(int i, int j) { return i + j; } PYBIND11_MODULE(python_example, m) { m.def("add", &add); m.def("subtract", [](int i, int j) { return i - j; }); } BONUS project: I’m not a maintainer, but help out occasionally
  • 11.
    scikit-build CMake - Pythonbridge for building extensions 50% of my time for three years (NSF grant) Introduced scikit-build-core last year: modern, static-config backend Over 200 users now (vs. ~900 scikit-build classic users) Family of tools: scikit-build (classic), scikit-build-core, cmake, ninja, moderncmakedomain, etc. [build-system] requires = ["scikit-build-core"] build-backend = "scikit_build_core.build" [project] name = "example" version = "0.0.1" cmake_minimum_required(VERSION 3.15...3.27) project(example LANGUAGES C) find_package(Python REQUIRED COMPONENTS Interpreter Development.Module REQUIRED) Python_add_library(_module MODULE src/module.c WITH_SOABI) install(TARGETS _module DESTINATION example) pyproject.toml CMakeLists.txt
  • 12.
    scikit-build-core: features Powerful configsystem Impl: declarative dataclasses + transformer - Pyproject, config-settings, and env - Generates JSONSchema - Generates readme docs Overrides (like cibuildwheel & mypy) Automatic cmake/ninja Only adds the wheels as build dependencies if required (not on system already) - Supports WebAssembly, BSD, etc. - Can set min CMake version required Features hard with setuptools Conditional Stable ABI / Limited ABI macOS compatibility tags Write to optional wheel dirs (ex: headers) Experimental editable mode, with auto-rebuild Extra goodies Auto inclusion of site-packages in prefix path Entry points for custom CMake modules FindPython auto-backport Dynamic metadata plugin system
  • 13.
    build pipx run build Theofficial replacement for python setup.py sdist and pip wheel . Released 1.0! Supports any backend
  • 14.
    cibuildwheel Builds wheels onCI and locally CPython 3.6-3.12, PyPy 3.7-3.10 macOS, Windows, manylinux, musllinux All OS’s: 64-bit Intel, 32-bit Intel, ARM Linux: ppc64le & s390x too (emulated) Tested on GHA, Azure, Travis, AppVeyor, Circle CI, GitLab CI, Cirrus CI Config via env or pyproject.toml Can run tests after building wheel See my blog for recipe to auto-generate build matrix! on: [push, pull_request] jobs: build_wheels: runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v4 - uses: pypa/cibuildwheel@v2.16.2 - uses: actions/upload-artifact@v3 with: path: ./wheelhouse/*.whl .github/workflows/wheel.yml pyproject.toml [tool.cibuildwheel] test-extras = ["test"] test-command = "pytest {project}/tests"
  • 15.
    My other projects github.com/henryiii iscinumpy.dev scikit-hep.org Boost-histogram,Hist, UHI, and uproot-browser (Histograms in Python) CLI11: C++’s most powerful argument parser