Skip to content

Commit

Permalink
gh-37319: build/pkgs/meson: Update to 1.3.1, require >= 1.2.3 for P…
Browse files Browse the repository at this point in the history
…ython 3.12 support, reject meson installed in inaccessible user schemes

    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes #1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

As reported in https://groups.google.com/g/sage-
devel/c/9ETciH8efTE/m/UfUO7xmsAQAJ, our `configure` script currently
accepts "system" meson that will not be functional in our venv.
```
$ pip install --user meson
Collecting meson
  Using cached meson-1.3.1-py3-none-any.whl.metadata (1.8 kB)
Using cached meson-1.3.1-py3-none-any.whl (976 kB)
Installing collected packages: meson
Successfully installed meson-1.3.1
$ python3 -c 'import sysconfig; print(sysconfig.get_path("scripts",
"posix_user"))'
/Users/mkoeppe/Library/Python/3.11/bin
$ /Users/mkoeppe/Library/Python/3.11/bin/meson --version
1.3.1
$ ./sage -sh -c '/Users/mkoeppe/Library/Python/3.11/bin/meson --version'
Traceback (most recent call last):
  File "/Users/mkoeppe/Library/Python/3.11/bin/meson", line 5, in
<module>
    from mesonbuild.mesonmain import main
ModuleNotFoundError: No module named 'mesonbuild'
```

Also tightening the version requirement. Only needed for Python 3.12
support (https://github.com/mesonbuild/meson-
python/blob/main/pyproject.toml#L36), but we do this unconditionally for
simplicity.

Also updating meson to latest and changing to a wheel package.

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [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 accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- #12345: short description why this is a dependency
- #34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: #37319
Reported by: Matthias Köppe
Reviewer(s):
  • Loading branch information
Release Manager committed Feb 28, 2024
2 parents 9cc87c2 + 3212ffe commit 65a64ea
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 44 deletions.
10 changes: 5 additions & 5 deletions build/pkgs/meson/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tarball=meson-VERSION.tar.gz
sha1=97e766951553ec35315712f0a27d5554a010d4c3
md5=69da4c63ef06c9d3bcc00ce89abb306f
cksum=2424401184
upstream_url=https://pypi.io/packages/source/m/meson/meson-VERSION.tar.gz
tarball=meson-VERSION-py3-none-any.whl
sha1=baf5b9bc9ca97f18c7dc87cfaf0e1dc4d617a4cf
md5=d418e644c04e55872ce3d7b6de007dbe
cksum=559088366
upstream_url=https://pypi.io/packages/py3/m/meson/meson-VERSION-py3-none-any.whl
2 changes: 1 addition & 1 deletion build/pkgs/meson/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.3
1.3.1
28 changes: 17 additions & 11 deletions build/pkgs/meson/spkg-configure.m4
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
SAGE_SPKG_CONFIGURE(
[meson], [
dnl scipy 1.11.2 needs meson >= 1.1.0
dnl contourpy needs meson >= 1.2.0
AC_CACHE_CHECK([for meson >= 1.2.0], [ac_cv_path_MESON], [
AC_PATH_PROGS_FEATURE_CHECK([MESON], [meson], [
meson_version=`$ac_path_MESON --version 2>&1`
AS_IF([test -n "$meson_version"], [
AX_COMPARE_VERSION([$meson_version], [ge], [1.2.0], [
ac_cv_path_MESON="$ac_path_MESON"
ac_path_MESON_found=:
SAGE_SPKG_CONFIGURE([meson], [dnl
dnl scipy 1.11.2 needs meson >= 1.1.0
dnl contourpy needs meson >= 1.2.0
dnl meson_python needs meson >= 1.2.3 for Python >= 3.12
AC_CACHE_CHECK([for meson >= 1.2.3], [ac_cv_path_MESON], [dnl
dnl Do not accept meson installed in the default user scheme;
dnl it will not work in our venv because we set PYTHONUSERBASE
dnl in sage-env.
WITH_SAGE_PYTHONUSERBASE([dnl
AC_PATH_PROGS_FEATURE_CHECK([MESON], [meson], [dnl
AS_IF([meson_version=$($ac_path_MESON --version 2>&1)], [dnl
AS_IF([test -n "$meson_version"], [dnl
AX_COMPARE_VERSION([$meson_version], [ge], [1.2.3], [dnl
ac_cv_path_MESON="$ac_path_MESON"
ac_path_MESON_found=:
])
])
])
])
])
Expand Down
2 changes: 0 additions & 2 deletions build/pkgs/meson/spkg-install.in

This file was deleted.

56 changes: 31 additions & 25 deletions m4/sage_python_package_check.m4
Original file line number Diff line number Diff line change
Expand Up @@ -71,32 +71,19 @@ AC_DEFUN([SAGE_PYTHON_PACKAGE_CHECK], [
)
AC_MSG_CHECKING([for python package $1 ("${SAGE_PKG_VERSPEC}")])
dnl To prevent user-site (pip install --user) packages from being
dnl detected as "system" packages, we poison PYTHONUSERBASE. The
dnl sage-env script also does this at runtime; we mimic that
dnl implementation to ensure that the behaviors at ./configure and
dnl runtime are identical. Beware that (as in sage-env) the poisoning
dnl is skipped if PYTHONUSERBASE is non-empty. In particular, if the
dnl user points PYTHONUSERBASE to any path (even the default), then
dnl his local pip packages will be detected.
PYTHONUSERBASE_SAVED="${PYTHONUSERBASE}"
AS_IF([test -z "${PYTHONUSERBASE}"], [
PYTHONUSERBASE="${HOME}/.sage/local"
WITH_SAGE_PYTHONUSERBASE([dnl
dnl double-quote SAGE_PKG_VERSPEC because platform-specific
dnl dependencies like python_version<'3.11' will have single
dnl quotes in them. (We normalized the quotes earlier with sed.)
AS_IF(
[config.venv/bin/python3 -c dnl
"import pkg_resources; dnl
pkg_resources.require(\"${SAGE_PKG_VERSPEC}\".splitlines())" dnl
2>&AS_MESSAGE_LOG_FD],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no); sage_spkg_install_$1=yes]
)
])
dnl double-quote SAGE_PKG_VERSPEC because platform-specific
dnl dependencies like python_version<'3.11' will have single
dnl quotes in them. (We normalized the quotes earlier with sed.)
AS_IF(
[PYTHONUSERBASE="${PYTHONUSERBASE}" config.venv/bin/python3 -c dnl
"import pkg_resources; dnl
pkg_resources.require(\"${SAGE_PKG_VERSPEC}\".splitlines())" dnl
2>&AS_MESSAGE_LOG_FD],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no); sage_spkg_install_$1=yes]
)
PYTHONUSERBASE="${PYTHONUSERBASE_SAVED}"
], [
dnl failed to create a venv for some reason
AC_MSG_RESULT(no)
Expand Down Expand Up @@ -128,3 +115,22 @@ AC_DEFUN([SAGE_PYTHON_PACKAGE_CHECK], [
AS_IF([test "${sage_use_system_$1}" = "yes"],[sage_use_system_$1=no])
])
])


AC_DEFUN([WITH_SAGE_PYTHONUSERBASE], [dnl
dnl To prevent user-site (pip install --user) packages from being
dnl detected as "system" packages, we poison PYTHONUSERBASE. The
dnl sage-env script also does this at runtime; we mimic that
dnl implementation to ensure that the behaviors at ./configure and
dnl runtime are identical. Beware that (as in sage-env) the poisoning
dnl is skipped if PYTHONUSERBASE is non-empty. In particular, if the
dnl user points PYTHONUSERBASE to any path (even the default), then
dnl his local pip packages will be detected.
PYTHONUSERBASE_SAVED="${PYTHONUSERBASE}"
AS_IF([test -z "${PYTHONUSERBASE}"], [dnl
PYTHONUSERBASE="${HOME}/.sage/local"
export PYTHONUSERBASE
])
$1
PYTHONUSERBASE="${PYTHONUSERBASE_SAVED}"
])

0 comments on commit 65a64ea

Please sign in to comment.