From db53e856ff3d6a3a8791f62484299ebe775d2c90 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 24 Dec 2023 20:37:05 -0500 Subject: [PATCH 1/6] m4/sage_python_package_check.m4: double-quote the version spec Some version specifiers in install-requires.txt will contain single quotes; for example, python_version<'3.11'. (This is according to the setuptools "Platform Specific Dependencies" documentation.) To support that, we double-quote the spec string rather than single quote it. --- m4/sage_python_package_check.m4 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/m4/sage_python_package_check.m4 b/m4/sage_python_package_check.m4 index e0713512ea0..fbc3914bff2 100644 --- a/m4/sage_python_package_check.m4 +++ b/m4/sage_python_package_check.m4 @@ -75,10 +75,13 @@ AC_DEFUN([SAGE_PYTHON_PACKAGE_CHECK], [ PYTHONUSERBASE="${HOME}/.sage/local" ]) + dnl double-quote SAGE_PKG_VERSPEC because platform-specific + dnl dependencies like python_version<'3.11' will have single + dnl quotes in them. AS_IF( [PYTHONUSERBASE="${PYTHONUSERBASE}" config.venv/bin/python3 -c dnl "import pkg_resources; dnl - pkg_resources.require('${SAGE_PKG_VERSPEC}'.splitlines())" 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] From 6181dec691d950f835f877d12c927ae4c3935a77 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 26 Nov 2023 00:06:18 -0500 Subject: [PATCH 2/6] build/pkgs/importlib_metadata/install-requires.txt: skip if python >= 3.11 --- build/pkgs/importlib_metadata/install-requires.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pkgs/importlib_metadata/install-requires.txt b/build/pkgs/importlib_metadata/install-requires.txt index 7a0ebd24888..e09fe706732 100644 --- a/build/pkgs/importlib_metadata/install-requires.txt +++ b/build/pkgs/importlib_metadata/install-requires.txt @@ -1,3 +1,3 @@ # According to https://pypi.org/project/importlib-metadata/, # 4.13 provides the features of Python 3.11 importlib.metadata -importlib_metadata >=4.13 +importlib_metadata >=4.13; python_version<'3.11' From 9e5df3cedf5da3cf991d030e40c7264a80ce207d Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 26 Nov 2023 00:07:28 -0500 Subject: [PATCH 3/6] build/pkgs/importlib_resources/install-requires.txt: skip if python >= 3.11 --- build/pkgs/importlib_resources/install-requires.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pkgs/importlib_resources/install-requires.txt b/build/pkgs/importlib_resources/install-requires.txt index 632e716f5a0..aef80842362 100644 --- a/build/pkgs/importlib_resources/install-requires.txt +++ b/build/pkgs/importlib_resources/install-requires.txt @@ -1,3 +1,3 @@ # According to https://pypi.org/project/importlib-resources/, # version 5.7 provides the features of Python 3.11 importlib.resources -importlib_resources >= 5.7 +importlib_resources >= 5.7; python_version<'3.11' From c192fb5ce4537268990e9c5d7da0207bd77a3297 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 26 Nov 2023 00:07:40 -0500 Subject: [PATCH 4/6] build/pkgs/typing_extensions/install-requires.txt: skip if python >= 3.11 --- build/pkgs/typing_extensions/install-requires.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pkgs/typing_extensions/install-requires.txt b/build/pkgs/typing_extensions/install-requires.txt index 22c3dd116b6..e1a912109ed 100644 --- a/build/pkgs/typing_extensions/install-requires.txt +++ b/build/pkgs/typing_extensions/install-requires.txt @@ -1,3 +1,3 @@ # According to https://github.com/python/typing_extensions/blob/main/CHANGELOG.md, # version 4.4.0 adds another Python 3.11 typing backport -typing_extensions >= 4.4.0 +typing_extensions >= 4.4.0; python_version<'3.11' From 4c3f7acf5915f55811218cc80b9277df93a88eb5 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 26 Dec 2023 06:55:03 -0500 Subject: [PATCH 5/6] build/pkgs: double-quote platform dependencies in install-requires.txt For the moment, this is an easy fix for the ./bootstrap generation of sage_spkg_versions_toml.m4, which single-quotes the contents of install-requires. --- build/pkgs/importlib_metadata/install-requires.txt | 2 +- build/pkgs/importlib_resources/install-requires.txt | 2 +- build/pkgs/typing_extensions/install-requires.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/pkgs/importlib_metadata/install-requires.txt b/build/pkgs/importlib_metadata/install-requires.txt index e09fe706732..a093079f483 100644 --- a/build/pkgs/importlib_metadata/install-requires.txt +++ b/build/pkgs/importlib_metadata/install-requires.txt @@ -1,3 +1,3 @@ # According to https://pypi.org/project/importlib-metadata/, # 4.13 provides the features of Python 3.11 importlib.metadata -importlib_metadata >=4.13; python_version<'3.11' +importlib_metadata >=4.13; python_version<"3.11" diff --git a/build/pkgs/importlib_resources/install-requires.txt b/build/pkgs/importlib_resources/install-requires.txt index aef80842362..be3b17269df 100644 --- a/build/pkgs/importlib_resources/install-requires.txt +++ b/build/pkgs/importlib_resources/install-requires.txt @@ -1,3 +1,3 @@ # According to https://pypi.org/project/importlib-resources/, # version 5.7 provides the features of Python 3.11 importlib.resources -importlib_resources >= 5.7; python_version<'3.11' +importlib_resources >= 5.7; python_version<"3.11" diff --git a/build/pkgs/typing_extensions/install-requires.txt b/build/pkgs/typing_extensions/install-requires.txt index e1a912109ed..d10f4dffbd3 100644 --- a/build/pkgs/typing_extensions/install-requires.txt +++ b/build/pkgs/typing_extensions/install-requires.txt @@ -1,3 +1,3 @@ # According to https://github.com/python/typing_extensions/blob/main/CHANGELOG.md, # version 4.4.0 adds another Python 3.11 typing backport -typing_extensions >= 4.4.0; python_version<'3.11' +typing_extensions >= 4.4.0; python_version<"3.11" From 0b08052705ce7a12ab5834346d125c784b6ffabd Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 26 Dec 2023 06:57:12 -0500 Subject: [PATCH 6/6] m4/sage_python_package_check.m4: normalize constraint quotes Platform version constraints in install-requires can be either single- or double-quoted. To keep things simple, we'd like to assume in the macro that they are single-quoted, following the examples in the documentation. We now use sed to normalize them. --- m4/sage_python_package_check.m4 | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/m4/sage_python_package_check.m4 b/m4/sage_python_package_check.m4 index fbc3914bff2..e3854a44fe6 100644 --- a/m4/sage_python_package_check.m4 +++ b/m4/sage_python_package_check.m4 @@ -58,8 +58,17 @@ AC_DEFUN([SAGE_PYTHON_PACKAGE_CHECK], [ AC_MSG_RESULT(yes) dnl strip all comments from install-requires.txt; this should leave dnl only a single line containing the version specification for this - dnl package. - SAGE_PKG_VERSPEC=$(sed '/^#/d' "./build/pkgs/$1/install-requires.txt") + dnl package. Afterwards, convert all double-quotes to single quotes. + dnl Both work, but only single quotes are documented. However, at the + dnl time of writing, double quotes are more compatible with our toml + dnl generation in ./bootstrap. Converting them from double- to single- + dnl quotes on-the-fly here lets us support both (in this macro, at + dnl least). + SAGE_PKG_VERSPEC=$(sed \ + -e '/^#/d' \ + -e "s/\"/'/g" \ + "./build/pkgs/$1/install-requires.txt" + ) AC_MSG_CHECKING([for python package $1 ("${SAGE_PKG_VERSPEC}")]) dnl To prevent user-site (pip install --user) packages from being @@ -77,10 +86,10 @@ AC_DEFUN([SAGE_PYTHON_PACKAGE_CHECK], [ dnl double-quote SAGE_PKG_VERSPEC because platform-specific dnl dependencies like python_version<'3.11' will have single - dnl quotes in them. + 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 + [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)],