Skip to content

Migrate to meson build system with PPL 1.2 - #38

Merged
dimpase merged 4 commits into
sagemath:masterfrom
cxzhong:meson
Mar 23, 2026
Merged

Migrate to meson build system with PPL 1.2#38
dimpase merged 4 commits into
sagemath:masterfrom
cxzhong:meson

Conversation

@cxzhong

@cxzhong cxzhong commented Feb 7, 2026

Copy link
Copy Markdown
Contributor

Replace the setuptools/distutils build with Meson:

  • Add meson.build for the root project, ppl/ package, and tests/
  • Add pyproject.toml with meson-python backend
  • Remove setup.py, setup.cfg, and tests/setup*.py

Use Meson wrap to fetch PPL 1.2 source on demand instead of bundling:

  • Add subprojects/ppl-1.2.wrap downloading from sagemath/sage releases
  • Add subprojects/packagefiles/ppl-1.2/meson.build as build overlay
  • Add compiler-fixes patch for C++17 compatibility (std::iterator,
    std::auto_ptr, std::mem_fun_ref, memcpy casts, missing includes)
  • Generate ppl-config.h at configure time without template file
  • Prefer system PPL via ppl-config script, fall back to subproject

Update CI workflows:

  • Add wheel builds for ubuntu, macOS ARM, macOS Intel, and linux-arm
  • Build GMP and GLPK from source for manylinux wheel portability
  • Add free-threading (cp314t) and musllinux support
  • Add macOS-15-intel runner to dist.yml matrix
  • Update pyproject.toml license to GPL-3.0-only
  • Pin cibuildwheel to v3.3.1, upgrade CI actions to v6
  • Fixes Use meson-python to build #33

@cxzhong
cxzhong marked this pull request as ready for review February 7, 2026 21:46
@cxzhong
cxzhong requested review from dimpase and tobiasdiez February 7, 2026 21:49
@dimpase

dimpase commented Feb 8, 2026

Copy link
Copy Markdown
Member

This should not bundle ppl unconditionally. ppl is relatively popular library and is available on many systems.

While ppl does not provide pkg-config configuration, it installs a script called ppl-config, which does things like ppl-config --cxxflags, etc

That is, to get the correct CXXFLAGS (important for C++ compatibility), one can just get them by calling ppl-config --cxxflags. Same for linking (call ppl-config --ldflags)

Comment thread .github/workflows/dist.yml Outdated
@cxzhong

cxzhong commented Feb 8, 2026

Copy link
Copy Markdown
Contributor Author

This should not bundle ppl unconditionally. ppl is relatively popular library and is available on many systems.

While ppl does not provide pkg-config configuration, it installs a script called ppl-config, which does things like ppl-config --cxxflags, etc

That is, to get the correct CXXFLAGS (important for C++ compatibility), one can just get them by calling ppl-config --cxxflags. Same for linking (call ppl-config --ldflags)

Since the traditional wheel build also pack ppl and others into wheel.

@dimpase

dimpase commented Feb 8, 2026

Copy link
Copy Markdown
Member

one does not need to build a dylib from source in order to pack it into a wheel.
pplpy is packaged by Arch, Gentoo, and they certainly will object
to this kind of design

@cxzhong

cxzhong commented Feb 8, 2026

Copy link
Copy Markdown
Contributor Author

one does not need to build a dylib from source in order to pack it into a wheel.
pplpy is packaged by Arch, Gentoo, and they certainly will object
to this kind of design

OK, Then I try to find ppl. If do not find then use subproject. but for wheel build. I think it is better to build everything static.

@dimpase

dimpase commented Feb 8, 2026

Copy link
Copy Markdown
Member

I don't see how it's better. If you have a dylib on your system, you want to reuse it
(ppl also has gmp as a dependency, so it's basically bloating
things up for no reason)

@cxzhong

cxzhong commented Feb 8, 2026

Copy link
Copy Markdown
Contributor Author

I don't see how it's better. If you have a dylib on your system, you want to reuse it
(ppl also has gmp as a dependency, so it's basically bloating
things up for no reason)

because it will let user just pip install pplpy, then the user can run this without install some system packages

@cxzhong

cxzhong commented Feb 8, 2026

Copy link
Copy Markdown
Contributor Author

Now, if you install libppl-dev and ppl-dev. it can build from system's ppl. If not, it will run a subproject.

@dimpase

dimpase commented Feb 8, 2026

Copy link
Copy Markdown
Member

I don't see how it's better. If you have a dylib on your system, you want to reuse it
(ppl also has gmp as a dependency, so it's basically bloating
things up for no reason)

because it will let user just pip install pplpy, then the user can run this without install some system packages

there is a number of reasons why it's less preferable: @orlitzky has a good answer I am sure

@tobiasdiez

Copy link
Copy Markdown
Contributor

A good compromise is to try to detect ppl and if not available use it from a subproject. But pls don't include the source files directly, but use a wrap (eg https://github.com/dimpase/primecountpy/blob/master/subprojects/primecount.wrap): https://mesonbuild.com/Wrap-dependency-system-manual.html

@orlitzky

orlitzky commented Feb 8, 2026

Copy link
Copy Markdown

There is a good list at https://wiki.gentoo.org/wiki/Why_not_bundle_dependencies but even that is missing some things like needing to duplicate patches to fix the build with newer compilers, and the ways various licenses change when you are copy/pasting code rather than linking.

And who wants to install pplpy if they don't have PPL first?

@dimpase

dimpase commented Feb 8, 2026

Copy link
Copy Markdown
Member

A good compromise is to try to detect ppl and if not available use it from a subproject. But pls don't include the source files directly, but use a wrap

yeah, vendoring the sources of ppl is totally unnecessary - I haven't looked at the implementation details yet.

@tobiasdiez

Copy link
Copy Markdown
Contributor

And who wants to install pplpy if they don't have PPL first?

Well, from a user's perspective installing a binary wheel of pplpy that includes PPL is definitively more friendly than having to install PPL first manually, and then building pplpy from source.

Comment thread subprojects/ppl-1.2/ppl-config.h.mesondefine Outdated
Comment thread subprojects/ppl-1.2/ppl-config.h.in Outdated
Comment thread subprojects/.wraplock Outdated
Comment thread subprojects/packagefiles/ppl-1.2/meson.build
@cxzhong
cxzhong requested review from dimpase and orlitzky February 9, 2026 09:22
@cxzhong cxzhong changed the title Migrate to meson build system with bundled PPL 1.2 Migrate to meson build system with PPL 1.2 Feb 9, 2026
@cxzhong cxzhong mentioned this pull request Feb 9, 2026

@tobiasdiez tobiasdiez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This looks prettyy good to me. A few smaller suggestions/nit-picks from my side.

Comment thread ppl/bit_arrays.pyx Outdated
Comment thread ppl/meson.build Outdated
Comment thread ppl/meson.build Outdated
Comment thread ppl/meson.build Outdated
Comment thread ppl/meson.build Outdated
Comment thread subprojects/packagefiles/ppl-1.2/meson.build Outdated
Comment thread subprojects/packagefiles/ppl-1.2/meson.build Outdated
Comment thread meson.build Outdated
@cxzhong
cxzhong requested a review from vbraun February 9, 2026 14:53
Comment thread subprojects/packagefiles/ppl-1.2/meson.build
Comment thread ppl/congruence.pyx Outdated
@cxzhong
cxzhong requested a review from tobiasdiez February 11, 2026 02:01
@cxzhong

cxzhong commented Mar 7, 2026

Copy link
Copy Markdown
Contributor Author

@dimpase @tobiasdiez can you review this again?

@tobiasdiez tobiasdiez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor suggestions

Comment thread ppl/congruence.pyx Outdated
Comment thread .github/workflows/dist.yml Outdated
Comment thread .github/workflows/dist.yml Outdated
Comment thread ppl/meson.build
Comment thread pyproject.toml Outdated
@tobiasdiez tobiasdiez mentioned this pull request Mar 12, 2026
Comment thread .github/workflows/test.yml Outdated
@cxzhong

cxzhong commented Mar 12, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, I will try to apply this.

@cxzhong
cxzhong force-pushed the meson branch 2 times, most recently from c65430c to 150a1df Compare March 12, 2026 18:27
@cxzhong

cxzhong commented Mar 13, 2026

Copy link
Copy Markdown
Contributor Author

It is very hard to debug here

@cxzhong

cxzhong commented Mar 13, 2026

Copy link
Copy Markdown
Contributor Author

It is very hard to debug here

I can not let cibuildwheel linux subproject ppl to find subproject gmp. but macos is ok. it seems a bug in meson build system

@tobiasdiez

Copy link
Copy Markdown
Contributor

I think you just forgot to specify them as dependencies of the subproject: https://github.com/sagemath/sage/blob/e37154cba140e8fc6ba3220c558cd3e8ada228ad/subprojects/packagefiles/maxima/meson.build#L31

@cxzhong

cxzhong commented Mar 13, 2026

Copy link
Copy Markdown
Contributor Author

I think you just forgot to specify them as dependencies of the subproject: https://github.com/sagemath/sage/blob/e37154cba140e8fc6ba3220c558cd3e8ada228ad/subprojects/packagefiles/maxima/meson.build#L31

still can not find gmp in cibuildwheel. I ran locally in Ubuntu. But in macos, it can be built.

Replace the legacy distutils/setuptools build with Meson and meson-python:

- Add top-level meson.build, ppl/meson.build, and tests/meson.build
- Add PPL 1.2 wrap subproject with compiler-fixes patch
- Move build config to pyproject.toml (meson-python backend, cibuildwheel settings)
- Update CI workflows (dist, test, doc) for Meson-based builds
- Remove setup.py, tests/setup.py, and tests/setup2.py
- Remove distutils directives from Cython .pyx files
- Update license identifier to GPL-3.0-or-later
- Update environment.yml and environment.test.yml dependencies
@cxzhong

cxzhong commented Mar 13, 2026

Copy link
Copy Markdown
Contributor Author

Then we need to bump the version to 0.9.0

cxzhong and others added 3 commits March 13, 2026 23:08
* Initial plan

* Remove debug symbols from Linux wheels to reduce size from ~30MB

Co-authored-by: cxzhong <14092175+cxzhong@users.noreply.github.com>

* Remove --buildtype=release from meson setup args per review feedback

Co-authored-by: cxzhong <14092175+cxzhong@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: cxzhong <14092175+cxzhong@users.noreply.github.com>

@tobiasdiez tobiasdiez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks again!

Follow-ups would be:

  • Migrate to uv (instead of pip install)
  • Figure out how to include gmp etc as subprojects instead of manually installing them from source

@cxzhong

cxzhong commented Mar 16, 2026

Copy link
Copy Markdown
Contributor Author

LGTM. Thanks again!

Follow-ups would be:

  • Migrate to uv (instead of pip install)
  • Figure out how to include gmp etc as subprojects instead of manually installing them from source

We may do this in follow-up pr

@cxzhong

cxzhong commented Mar 23, 2026

Copy link
Copy Markdown
Contributor Author

This is ready to merge now @dimpase

@dimpase
dimpase merged commit 20be766 into sagemath:master Mar 23, 2026
14 checks passed
@cxzhong
cxzhong deleted the meson branch March 23, 2026 21:04
@dimpase dimpase mentioned this pull request Mar 30, 2026
5 tasks
vbraun pushed a commit to vbraun/sage that referenced this pull request Apr 6, 2026
Release Manager
sagemathgh-41922: bump pplpy to 0.9.0
    
the latest pplpy on pypi now, switched biuld system to meson
sagemath/pplpy#38


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#41922
Reported by: Dima Pasechnik
Reviewer(s): Chenxin Zhong
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.

Use meson-python to build

5 participants