Skip to content

Update build system to use Meson #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 62 commits into from
Nov 17, 2024
Merged

Conversation

tobiasdiez
Copy link
Contributor

@tobiasdiez tobiasdiez commented Oct 29, 2024

Following the example of Scipy/Numpy and sagemath/sage#36524, the build system is migrated to Meson.

I tried to stay as close as possible to the original autoconf implementation. A few differences are:

  • No longer need to auto-generate signals.pxd, but have it at as a normal source file.
  • Changed the authors to Sage Developers to align with the main sage repo. I'm unsure about this one and happy to revert it.
  • Drop Python < 3.9 in alignment with https://scientific-python.org/specs/spec-0000/
  • Remove the special handling when MINSIGSTKSZ_IS_CONSTANT (I had trouble making it compile and it's not constant for recent versions of glibc anyway)
  • Remove the "ci-with-sage" jobs in the github action, which are non-working on the main branch and I've also no idea how to make them compatible with meson; I also think the current ci runs should give a pretty good coverage.
  • Include the code of implementation_cygwin.c directly in implementation.c since I was not able to make it compile (it's also a bit hard for me to work on the cygwin code since I only have the ci to test it.)

Closes #179 (obsolete now)

@tobiasdiez
Copy link
Contributor Author

Uff, tests are finally green.

@fchapoton
Copy link
Contributor

Would you agree to engage yourself to maintain this for the years to come ?

@dimpase
Copy link
Member

dimpase commented Nov 17, 2024

meson is a widely used and documented, unlike our present system to build this. besides, currently used distutils is deprecated, and needs a replacement anyway.

@fchapoton
Copy link
Contributor

So we both agree that it's a good idea to merge, right ?

@tobiasdiez
Copy link
Contributor Author

Would you agree to engage yourself to maintain this for the years to come ?

That's hard to promise but yes I'm willing to (help) maintaining it. The meson build info is also pretty straightforward, so it shouldn't be too hard for someone else to modify it.

Please merge #209 before this one here, and squash this PR to have a cleaner git history. Thanks!

Copy link
Member

@dimpase dimpase left a comment

Choose a reason for hiding this comment

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

lgtm

@fchapoton fchapoton merged commit fa6d45d into sagemath:main Nov 17, 2024
20 checks passed
@tobiasdiez tobiasdiez deleted the convert-to-meson branch November 17, 2024 15:52
@tobiasdiez
Copy link
Contributor Author

Thanks @dimpase and @fchapoton!

vbraun pushed a commit to vbraun/sage that referenced this pull request May 17, 2025
sagemathgh-38872: Native Windows build
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

The goal of this PR is to provide a native Windows build of Sage using
MSVC (using the new Meson build system).

Instructions on how to test are under the `Windows` tab at https://doc-
pr-38872--sagemath.netlify.app/html/en/installation/meson.
Afterwards, you should be able to import some sage modules in a normal
`python` install (but most modules actually don't properly import due to
various errors that will be fixed peu a peu in follow-up PRs)

## State of Windows support of dependencies

- m4rie: upstream (https://github.com/malb/m4rie) doesn't provide win
build
- ec: not sure if upstream (https://github.com/JohnCremona/eclib)
provide win build
- ecm: upstream (https://gitlab.inria.fr/zimmerma/ecm) doesn't provide
native win build (only Cygwin)
- ntl: upstream provides win build (kind of), but it's not yet available
on conda (conda-forge/ntl-feedstock#16)
- maxima/ecl: upstream provides win build, but it's not yet available on
conda (conda-forge/maxima-feedstock#38)
- GAP: only cygiwn build exists https://github.com/gap-
system/gap/issues/4157
- [pari](http://pari.math.u-bordeaux.fr/pub/pari): now available on
conda (conda-forge/pari-feedstock#45)
- cypari2: no windows support yet
sagemath/cypari2#19
- lrcalc
- pplpy
- primecountpy
- fpylll
- rw
- cliquer
- lcalc
- ecl
- braiding
- gc
- homfly
- iml
- brial_groebner

## Conda Issues:
- Meson cannot find libraries without pkg-config files.
     - Workaround: Check that `set LIB` includes the conda env (e.g.
`...\.conda\envs\sage-dev\Library\lib`). If not, run `conda deactivate`
followed by `conda activate sage-dev` and then check again.
     - Alternatively, `set LIB=%CONDA_PREFIX%\Library\lib;%LIB%`
     - Possible upstream improvement: the compilers conda package should
set `LIB`
- If you don't have the debug version of Python installed, you may get
"LINK : fatal error LNK1104: cannot open file 'python311_d.lib'"
     - Workaround: `meson setup builddir -Dbuildtype=release`
     - Alternatively, in `<path to conda>\sage-dev\include\pyconfig.h`
uncomment: `//#       define Py_DEBUG` and change `python311_d.lib` to
`python311.lib`
     - Possible upstream improvement: conda should either ship a debug
version of python or a correct `pyconfig.h`
- conda-forge/gsl-feedstock#63
     - Workaround: Fallback to find_library in meson and/or change the
`gsl.pc` to match:
       ```
       prefix=C:/Users/Tobia/.conda/envs/sage-dev/Library
       exec_prefix=C:/Users/Tobia/.conda/envs/sage-dev/Library
       libdir=C:/Users/Tobia/.conda/envs/sage-dev/Library/lib
       sharedlibdir=C:/Users/Tobia/.conda/envs/sage-dev/Library/lib
       includedir=C:/Users/Tobia/.conda/envs/sage-dev/Library/include
       GSL_CBLAS_LIB=-lgslcblas

       Name: GSL
       Description: GNU Scientific Library
       Version: 2.7
       Libs: -L${libdir} -lgsl ${GSL_CBLAS_LIB}
       Cflags: -I${includedir}
       ```
- conda-forge/compilers-feedstock#66
     - Workaround: Run everything in "VS x64 Native Tools Command
Prompt" (for 64bit) or "Developer Command Prompt for VS2022 (or 2019)"
(for 32bit)
- conda-forge/libgd-feedstock#55
     - Workaround: Fallback to find_library in meson
- conda-forge/m4ri-feedstock#15
    - Workaround: Don't try to use m4ri on windows
- conda-forge/libflint-feedstock#38
    - Workaround: Don't try to use flint on windows

## Upstream issues
Singular
- Singular/Singular#1245
- Singular/Singular#1246
- Singular/Singular#1247

Flint:
- flintlib/flint#2100
- mingw-w64/mingw-w64#65 (indirectly since
pthread is flint dependency). Would be fixed by
conda-forge/libflint-feedstock#38.
   -> Workaround: Change `typedef __int64 pid_t;` to `typedef int
pid_t;` in `.conda\envs\sage-dev\Library\include\pthread_compat.h`
- flintlib/flint#2101:
   -> Workaround: disable compilation of fraction_field_FpT for now

Cysignals:
- sagemath/cysignals#207
- sagemath/cysignals#206


### 📝 Checklist

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

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] 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#38872
Reported by: Tobias Diez
Reviewer(s): Dima Pasechnik
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.

configure tests the wrong compiler
3 participants