Skip to content

Commit a36e994

Browse files
author
Release Manager
committed
sagemathgh-36776: Skip backport packages for newer python Three of our SPKGs are backports that provide python-3.11 features: * importlib_metadata * importlib_resources * typing_extensions As a result, they are not needed when sage's python is v3.11 or newer. We un-require them in `spkg-configure.m4` URL: sagemath#36776 Reported by: Michael Orlitzky Reviewer(s): Matthias Köppe, Michael Orlitzky
2 parents d229401 + 0b08052 commit a36e994

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# According to https://pypi.org/project/importlib-metadata/,
22
# 4.13 provides the features of Python 3.11 importlib.metadata
3-
importlib_metadata >=4.13
3+
importlib_metadata >=4.13; python_version<"3.11"
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# According to https://pypi.org/project/importlib-resources/,
22
# version 5.7 provides the features of Python 3.11 importlib.resources
3-
importlib_resources >= 5.7
3+
importlib_resources >= 5.7; python_version<"3.11"
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# According to https://github.com/python/typing_extensions/blob/main/CHANGELOG.md,
22
# version 4.4.0 adds another Python 3.11 typing backport
3-
typing_extensions >= 4.4.0
3+
typing_extensions >= 4.4.0; python_version<"3.11"

m4/sage_python_package_check.m4

+17-5
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,17 @@ AC_DEFUN([SAGE_PYTHON_PACKAGE_CHECK], [
5858
AC_MSG_RESULT(yes)
5959
dnl strip all comments from install-requires.txt; this should leave
6060
dnl only a single line containing the version specification for this
61-
dnl package.
62-
SAGE_PKG_VERSPEC=$(sed '/^#/d' "./build/pkgs/$1/install-requires.txt")
61+
dnl package. Afterwards, convert all double-quotes to single quotes.
62+
dnl Both work, but only single quotes are documented. However, at the
63+
dnl time of writing, double quotes are more compatible with our toml
64+
dnl generation in ./bootstrap. Converting them from double- to single-
65+
dnl quotes on-the-fly here lets us support both (in this macro, at
66+
dnl least).
67+
SAGE_PKG_VERSPEC=$(sed \
68+
-e '/^#/d' \
69+
-e "s/\"/'/g" \
70+
"./build/pkgs/$1/install-requires.txt"
71+
)
6372
AC_MSG_CHECKING([for python package $1 ("${SAGE_PKG_VERSPEC}")])
6473
6574
dnl To prevent user-site (pip install --user) packages from being
@@ -75,10 +84,13 @@ AC_DEFUN([SAGE_PYTHON_PACKAGE_CHECK], [
7584
PYTHONUSERBASE="${HOME}/.sage/local"
7685
])
7786
87+
dnl double-quote SAGE_PKG_VERSPEC because platform-specific
88+
dnl dependencies like python_version<'3.11' will have single
89+
dnl quotes in them. (We normalized the quotes earlier with sed.)
7890
AS_IF(
79-
[PYTHONUSERBASE="${PYTHONUSERBASE}" config.venv/bin/python3 -c dnl
80-
"import pkg_resources; dnl
81-
pkg_resources.require('${SAGE_PKG_VERSPEC}'.splitlines())" dnl
91+
[PYTHONUSERBASE="${PYTHONUSERBASE}" config.venv/bin/python3 -c dnl
92+
"import pkg_resources; dnl
93+
pkg_resources.require(\"${SAGE_PKG_VERSPEC}\".splitlines())" dnl
8294
2>&AS_MESSAGE_LOG_FD],
8395
[AC_MSG_RESULT(yes)],
8496
[AC_MSG_RESULT(no); sage_spkg_install_$1=yes]

0 commit comments

Comments
 (0)