Skip to content

Decouple Core lib and Python#131

Draft
woodtp wants to merge 6 commits into
PyORBIT-Collaboration:mainfrom
woodtp:decouple-python
Draft

Decouple Core lib and Python#131
woodtp wants to merge 6 commits into
PyORBIT-Collaboration:mainfrom
woodtp:decouple-python

Conversation

@woodtp

@woodtp woodtp commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

The goal of this PR is to decouple the PyORBIT core and the Python wrapper logic to facilitate development of extensions, enable us to migrate to a different binding solution, e.g., nanobind, or potentially develop bindings for other languages.

meson.build has been configured to produce metadata for pkgconfig that will be installed under your chosen prefix: <prefix>/lib/pkgconfig/pyorbit3.pc. This can be discovered by pkgconfig for external projects to properly find development headers and link against libpyorbit3.

To install pyorbit in a conda environment:

meson setup build --prefix=$CONDA_PREFIX
meson compile -C build
meson install -C build

To uninstall

cd build
ninja uninstall

After installation, headers can be found under <prefix>/include/pyorbit3.

TODO

  • Example external project skeleton

woodtp added 6 commits June 15, 2026 17:17
- tabs -> 2 spaces per style guide
- foreach loop for the extension modules
- clean up cpp_args
  - migrate c++ standard specification to project()
  - global project argument for `-DUSE_MPI`
  - Removed `-fPIC`. Meson handles this for us.
- set default buildtype to 'release' in project()
  - can be overridden with `meson setup ... -Dbuildtype=debug`
- Add `-march=native` global project argument, conditionally.
  - Since we don't distribute binaries and expect users to compile pyo3 for themselves, I don't see a reason not to include this flag as it can only help performance. At worst, it does nothing.
Overall restructuring so we don't ship more than necessary.
…er implementation.

Previously, we were compiling one, monolithic shared library. In the
revised meson.build, I've separated out compilation of the core from
python extension modules and removed unnecessary interdependence.

Bunch and Grid<N>D were reliant on the pyORBIT_MPI_Comm wrapper over MPI_Comm, which
coupled C++ core behavior and python wrapper handling thereby preventing separation.

Factored out common utility functions to ascertain Python types of
pyorbit objects at runtime under src/core/type_accessors.cc.

Renamed all instances of "Python.h" -> <Python.h>. This is probably better
for Python.h, because the header typically exists at system lib paths, not in
the project dir.
Switch to #include <...> in parity with Python.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant