2026-07-20 –, Room 2.41 (First Floor, Turing)
In this talk, I will share some highlights from the development of the PyPartMC package (https://pypi.org/p/PyPartMC; https://pypi.org/project/PyPartMC) in which we have just celebrated our 100-th release!
PyPartMC constitutes Python bindings to the Fortran-implemented internals of the PartMC aerosol dynamics Monte-Carlo simulation package developed at the University of Illinois Urbana-Champaign.
Rather than providing "wrappers" to highest-level PartMC interface, PyPartMC leverages the object-oriented architecture of PartMC and offers bindings to numerous datatypes and routines, as well as examples of how to construct simulation logic with these components in Python.
Applications of PyPartMC concern air-pollution and aerosol-cloud interactions modelling, and range from process studies to HPC applications via coupling with Numerical Weather Prediction models.
The talk will be addressed primarily to Python package developers. I will share the lessons learned, some fun facts, and practical solutions which are applicable to any Fortran-to-Python bindings project.
We will go through the key design goals of the project: maintainability, exposing internals, CI and automation, complete test coverage and single-click operations on Google Colab and within Matlab.
I will cover the encountered technical challenges - both solved and remaining - welcoming new contributors to the project.
Detailed plan of the talk:
Intro
- A short-summary of the PartMC package.
- Outlining the requirements for a usable and maintainable Python interface
- Quick overview of the project architecture in regards to the binding and packaging process
Challenges solved
- Multi-platform packaging process with cibuildwheel, including Fortran dependencies (some errors included too long filenames on Windows, some of the dependencies were never compiled on Windows earlier!)
- Codecov coverage for a 4-language codebase
- Garbage collection of Fortran objects
- Static linkage of 10+ git submodules, including some CMake trickery with undocumented CMake features!
- Exposing C++ interface to Python through nanobind, including writing custom type casters
- Internal JSON usage, which resulted in adopting an unmaintained nanobind_json codebase
Remaining challenges
- Exception handling/propagation from C++ to C++ across Fortran layer (works only on selected platforms)
- Eliminating (and type-checking) boilerplate glue code (Fortran+C), while retaining codecov functionality
- The project is open-source! Contributions are welcome!
Highlights and benefits
- Reducing entry threshold for users from days (cumbersome installation of dependencies, multi-language compilation, needed knowledge of Bash, Fortran & Python to complete a simulation) to seconds (single-click exec of example Jupyter Notebooks on Colab)
- Coupling with other Python-implemented simulation components (e.g. packages simulating light scattering on particle populations)
- Usage of PartMC via PyPartMC as a test-time dependency for other packages
- Enabling access to PartMC from Julia and Matlab via respective Python bridges
Third-year Applied Computer Science student at AGH University of Kraków. Interested in GPUs, HPC and Open-source software. Currently working as a C++ Developer @ digatus.