Skip to content

More meson.build adjustments#122

Open
woodtp wants to merge 2 commits into
PyORBIT-Collaboration:mainfrom
woodtp:meson-cleanup
Open

More meson.build adjustments#122
woodtp wants to merge 2 commits into
PyORBIT-Collaboration:mainfrom
woodtp:meson-cleanup

Conversation

@woodtp

@woodtp woodtp commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Migrating some modfications I've been carrying around locally:

  • Indentation: tabs -> 2 spaces per style guide
  • foreach loop for the extension modules
  • Removes cpp_args
    • Migrate c++ standard specification to project(). Can now be overridden from the CLI with:
      • meson setup ... -Dcpp_std=<version>
    • Global project argument for -DUSE_MPI
    • Removed -fPIC. Meson handles this for us.
  • Set default buildtype to 'release' in project()
    • It 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.

- 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.
@woodtp woodtp self-assigned this Jun 15, 2026
@woodtp woodtp closed this Jun 16, 2026
@woodtp
woodtp deleted the meson-cleanup branch June 16, 2026 18:34
@woodtp
woodtp restored the meson-cleanup branch June 18, 2026 18:05
@woodtp

woodtp commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Accidentally closed somehow

@woodtp woodtp reopened this Jun 18, 2026
@woodtp
woodtp marked this pull request as draft June 18, 2026 18:05
@woodtp

woodtp commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Working to extend this PR to add support for 1st-party extensions, e.g., https://github.com/PyORBIT-Collaboration/laser-stripping for @tvgorlov.

@woodtp
woodtp requested a review from azukov June 18, 2026 18:07
@woodtp woodtp closed this Jun 18, 2026
@woodtp
woodtp deleted the meson-cleanup branch June 18, 2026 18:36
@woodtp
woodtp restored the meson-cleanup branch June 18, 2026 18:54
@woodtp woodtp reopened this Jun 18, 2026
@woodtp woodtp changed the title More meson.build adjustments More meson.build adjustments; decouple C++ and python wrapper code Jun 19, 2026
@woodtp

woodtp commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Fixed. All CI checks are passing.

So, it looks like I'm touching lots of files, but majority of the file diffs are just renaming instances of "Python.h" to <Python.h> and same for <structmember.h>.

There are some actual changes to core, though. My goal was to create separation between C++ backend and python wrapper logic in the meson.build. When I tried to do that haphazardly, I realized that, for example, Bunch actually requires some of the wrapper code for handling the MPI comm. Personally, I think that anything Python-related should be completely separated from the core, and the wrap_*.cc implementation should solely handle translating things for the python interpreter.

Creating that separation opens up the possibility to create bindings for other languages if desired (Julia?), or use another library like pybind/nanobind. In the end, we now have a shared library for the pyorbit core, which does not link against libpython at all:

❯ otool -L build/src/libpyorbit3.dylib                          (pyo3)
build/src/libpyorbit3.dylib:
	@rpath/libpyorbit3.dylib (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libfftw3.3.dylib (compatibility version 11.0.0, current version 11.11.0)
	@rpath/libmpi.40.dylib (compatibility version 81.0.0, current version 81.7.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 2100.43.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1356.0.0)

@woodtp
woodtp marked this pull request as ready for review June 19, 2026 15:29
@woodtp

woodtp commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

I split this PR into two. See #131.

@woodtp woodtp changed the title More meson.build adjustments; decouple C++ and python wrapper code More meson.build adjustments Jul 17, 2026
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