Best Toolchain for Developing a Python Package with C++ Core?
Asked by
cork flooring
I'm trying to set up a streamlined development environment for creating an application that has a C++ core and a Python interface. My focus is on using Python 3.13 and C++23, ideally for high-performance computing (HPC) applications. Here's what I've tried so far:
- **Project environment and dependencies**: Pixi
- **Development environment**: WSL2 with VS Code Remote window
- **Build system**: scikit-build using CMake and Ninja
- **Binding library**: Nanobind
I've set up various configuration files including pixi.toml, pyproject.toml, CMakeLists.txt, and CMakePresets.json.
For my Python toolchain, I'm currently using:
- UV
- Ruff
- Mypy (and I'm trying ty)
- pytest
- pre-commit
What are your thoughts on this setup? Would you recommend a toolchain like this, and could you suggest any learning resources? I'm particularly interested in how to effectively develop Python applications with a C++ core.
Answers
Your stack looks solid for modern C++/Python integration. If build times become an issue, especially with C++23's heavy template usage, consider looking into Incredibuild. It helps speed up CMake/Ninja builds by distributing compilation across multiple CPUs without altering your current setup.
Reply to this answer
You're on the right track! One key point to consider is whether you're using Pybind11 or Nanobind for your bindings, as that can significantly affect your development experience and build complexity. What did you decide on?
Reply to this answer
Honestly, it sounds like a lot of work to maintain both languages. Have you considered sticking to just one unless it's absolutely necessary?
Reply to this answer
If C++ isn't a strict requirement, you might check out Maturin for Rust bindings; it's gaining popularity. But I should mention that Rust is still catching up in certain HPC areas like CUDA, PETSc, BLAS, and LAPACK. Are you familiar with how Rust handles these?
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions