Skip to content

Commit e3c11b6

Browse files
author
Release Manager
committed
gh-35867: pkgs/*/setup.cfg: Reduce boilerplate by m4-include, reduce complexity of m4 use <!-- Please provide a concise, informative and self-explanatory title. --> <!-- Don't put issue numbers in the title. Put it in the Description below. --> <!-- For example, instead of "Fixes #12345", use "Add a new method to multiply two integers" --> ### 📚 Description <!-- Describe your changes here in detail. --> This makes the `pkgs/*/setup.cfg.m4` and `pkgs/*/pyproject.toml.m4` files less scary and less repetitive. <!-- 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". --> Split out from: - #35095 <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x ]`. --> - [x] The title is concise, informative, and self-explanatory. - [x] 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 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: #35867 Reported by: Matthias Köppe Reviewer(s): François Bissey
2 parents 22693a7 + 5ecf106 commit e3c11b6

File tree

14 files changed

+142
-205
lines changed

14 files changed

+142
-205
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
/confdefs.h
2323

2424
/m4/sage_spkg_configures.m4
25+
/m4/sage_spkg_versions*.m4
2526

2627
# no longer generated, but may still be in user worktrees
2728
/src/lib/pkgconfig

bootstrap

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,16 @@ CONFVERSION=$(cat $PKG/package-version.txt)
3535

3636

3737
bootstrap () {
38-
if [ "${BOOTSTRAP_QUIET}" = "no" ]; then
39-
echo "bootstrap:$LINENO: installing 'm4/sage_spkg_configures.m4'"
40-
fi
41-
rm -f m4/sage_spkg_configures.m4
38+
for a in m4/sage_spkg_configures.m4 m4/sage_spkg_versions.m4 m4/sage_spkg_versions_toml.m4; do
39+
if [ "${BOOTSTRAP_QUIET}" = "no" ]; then
40+
echo "bootstrap:$LINENO: installing '"$a"'"
41+
fi
42+
rm -f $a
43+
echo "# Generated by SAGE_ROOT/bootstrap; do not edit" > $a
44+
done
45+
for a in m4/sage_spkg_versions.m4 m4/sage_spkg_versions_toml.m4; do
46+
echo 'changequote(`>>>'"'"', `<<<'"')dnl" >> $a
47+
done
4248
spkg_configures=""
4349
# initialize SAGE_ENABLE... options for standard packages
4450
for pkgname in $(sage-package list :standard: | sort); do
@@ -92,12 +98,17 @@ SAGE_SPKG_CONFIGURE_$(echo ${pkgname} | tr '[a-z]' '[A-Z]')"
9298
if test -f "$DIR/requirements.txt" -o -f "$DIR/install-requires.txt"; then
9399
# A Python package
94100
SPKG_TREE_VAR=SAGE_VENV
101+
echo "define(>>>SPKG_INSTALL_REQUIRES_${pkgname}<<<, >>>$(echo $(sage-get-system-packages install-requires ${pkgname}))<<<)dnl" >> m4/sage_spkg_versions.m4
102+
echo "define(>>>SPKG_INSTALL_REQUIRES_${pkgname}<<<, >>>$(echo $(sage-get-system-packages install-requires-toml ${pkgname}))<<<)dnl" >> m4/sage_spkg_versions_toml.m4
95103
fi
96104
fi
97105
spkg_configures="$spkg_configures
98106
SAGE_SPKG_FINALIZE([$pkgname], [$pkgtype], [$SPKG_SOURCE], [$SPKG_TREE_VAR])"
99107
done
100108
echo "$spkg_configures" >> m4/sage_spkg_configures.m4
109+
for a in m4/sage_spkg_versions.m4 m4/sage_spkg_versions_toml.m4; do
110+
echo 'changequote(>>>`<<<, >>>'"'"'<<<)dnl' >> $a
111+
done
101112

102113
for pkgname in $(sage-package list --has-file bootstrap); do
103114
(cd build/pkgs/$pkgname && ./bootstrap) || exit 1

build/bin/sage-get-system-packages

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ if [ -z "$SAGE_ROOT" ]; then
1212
fi
1313
case "$SYSTEM" in
1414
install-requires)
15-
# Collect install-requires.txt and output it in the format
15+
# Collect install-requires.txt (falling back to requirements.txt) and output it in the format
1616
# needed by setup.cfg [options] install_requires=
17-
SYSTEM_PACKAGES_FILE_NAMES="install-requires.txt"
17+
SYSTEM_PACKAGES_FILE_NAMES="install-requires.txt requirements.txt"
1818
STRIP_COMMENTS="sed s/#.*//;/^[[:space:]]*$/d;"
1919
COLLECT=
2020
;;
2121
install-requires-toml)
22-
# Collect install-requires.txt and output it in the format
22+
# Collect install-requires.txt (falling back to requirements.txt) and output it in the format
2323
# needed by pyproject.toml [build-system] requires=
24-
SYSTEM_PACKAGES_FILE_NAMES="install-requires.txt"
24+
SYSTEM_PACKAGES_FILE_NAMES="install-requires.txt requirements.txt"
2525
STRIP_COMMENTS="sed s/#.*//;/^[[:space:]]*$/d;s/^/'/;s/$/',/;"
2626
COLLECT=
2727
;;

build/pkgs/sagelib/bootstrap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
#! /bin/sh
22
set -e
3+
export M4PATH="$SAGE_ROOT/m4"
4+
MACRO_PATTERN='SPKG_'
35
for infile in src/*.m4; do
46
if [ -f "$infile" ]; then
57
outfile="src/$(basename $infile .m4)"
68
if [ "${BOOTSTRAP_QUIET}" = "no" ]; then
79
echo "$0: installing $(pwd)/$outfile"
810
fi
911
m4 "$infile" > "$outfile"
12+
if sed 's/#.*//' "$outfile" | grep -q -E "$MACRO_PATTERN"; then
13+
echo >&2 "$(pwd)/$infile: error: Unrecognized SPKG_ macro:"
14+
grep -E "$MACRO_PATTERN" "$outfile" >&2
15+
exit 1
16+
fi
1017
fi
1118
done

m4/setup_cfg_metadata.m4

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
dnl Standard metadata of SageMath distribution packages
2+
dnl
3+
license = GNU General Public License (GPL) v2 or later
4+
author = The Sage Developers
5+
author_email = [email protected]
6+
url = https://www.sagemath.org
7+
8+
classifiers =
9+
Development Status :: 6 - Mature
10+
Intended Audience :: Education
11+
Intended Audience :: Science/Research
12+
License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
13+
Operating System :: POSIX
14+
Operating System :: MacOS :: MacOS X
15+
Programming Language :: Python :: 3 :: Only
16+
Programming Language :: Python :: 3.8
17+
Programming Language :: Python :: 3.9
18+
Programming Language :: Python :: 3.10
19+
Programming Language :: Python :: 3.11
20+
Programming Language :: Python :: Implementation :: CPython
21+
Topic :: Scientific/Engineering :: Mathematics
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*-
12
[build-system]
23
# Minimum requirements for the build system to execute.
34
requires = [
4-
esyscmd(`sage-get-system-packages install-requires-toml \
5-
setuptools \
6-
wheel \
7-
sage_setup \
8-
sagemath_environment \
9-
sagemath_objects \
10-
cython \
11-
gmpy2 \
12-
cysignals \
13-
')]
5+
SPKG_INSTALL_REQUIRES_setuptools
6+
SPKG_INSTALL_REQUIRES_wheel
7+
SPKG_INSTALL_REQUIRES_sage_setup
8+
SPKG_INSTALL_REQUIRES_sagemath_environment
9+
SPKG_INSTALL_REQUIRES_sagemath_objects
10+
SPKG_INSTALL_REQUIRES_cython
11+
SPKG_INSTALL_REQUIRES_gmpy2
12+
SPKG_INSTALL_REQUIRES_cysignals
13+
]
1414
build-backend = "setuptools.build_meta"

pkgs/sagemath-categories/setup.cfg.m4

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,16 @@
1-
# -*- conf-unix -*-
1+
include(`sage_spkg_versions.m4')dnl' -*- conf-unix -*-
22
[metadata]
33
name = sagemath-categories
44
version = file: VERSION.txt
55
description = Sage: Open Source Mathematics Software: Sage categories and basic rings
66
long_description = file: README.rst
77
long_description_content_type = text/x-rst
8-
license = GNU General Public License (GPL) v2 or later
9-
author = The Sage Developers
10-
author_email = [email protected]
11-
url = https://www.sagemath.org
12-
13-
classifiers =
14-
Development Status :: 6 - Mature
15-
Intended Audience :: Education
16-
Intended Audience :: Science/Research
17-
License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
18-
Operating System :: POSIX
19-
Operating System :: MacOS :: MacOS X
20-
Programming Language :: Python :: 3 :: Only
21-
Programming Language :: Python :: 3.8
22-
Programming Language :: Python :: 3.9
23-
Programming Language :: Python :: 3.10
24-
Programming Language :: Python :: 3.11
25-
Programming Language :: Python :: Implementation :: CPython
26-
Topic :: Scientific/Engineering :: Mathematics
8+
include(`setup_cfg_metadata.m4')dnl'
279

2810
[options]
2911
python_requires = >=3.8, <3.12
3012
install_requires =
31-
esyscmd(`sage-get-system-packages install-requires \
32-
sagemath_objects \
33-
| sed "2,\$s/^/ /;"')dnl
13+
SPKG_INSTALL_REQUIRES_sagemath_objects
3414

3515
[options.extras_require]
36-
test = sagemath-repl
16+
test = SPKG_INSTALL_REQUIRES_sagemath_repl
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*-
12
[build-system]
23
# Minimum requirements for the build system to execute.
34
requires = [
4-
esyscmd(`sage-get-system-packages install-requires-toml \
5-
setuptools \
6-
wheel \
7-
')]
5+
SPKG_INSTALL_REQUIRES_setuptools
6+
SPKG_INSTALL_REQUIRES_wheel
7+
]
88
build-backend = "setuptools.build_meta"
Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,15 @@
1-
# -*- conf-unix -*-
1+
include(`sage_spkg_versions.m4')dnl' -*- conf-unix -*-
22
[metadata]
33
name = sagemath-environment
44
version = file: VERSION.txt
55
description = Sage: Open Source Mathematics Software: System and software environment
66
long_description = file: README.rst
77
long_description_content_type = text/x-rst
8-
license = GNU General Public License (GPL) v2 or later
9-
author = The Sage Developers
10-
author_email = [email protected]
11-
url = https://www.sagemath.org
12-
13-
classifiers =
14-
Development Status :: 6 - Mature
15-
Intended Audience :: Education
16-
Intended Audience :: Science/Research
17-
License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
18-
Operating System :: POSIX
19-
Operating System :: MacOS :: MacOS X
20-
Programming Language :: Python :: 3 :: Only
21-
Programming Language :: Python :: 3.8
22-
Programming Language :: Python :: 3.9
23-
Programming Language :: Python :: 3.10
24-
Programming Language :: Python :: 3.11
25-
Programming Language :: Python :: Implementation :: CPython
26-
Topic :: Scientific/Engineering :: Mathematics
8+
include(`setup_cfg_metadata.m4')dnl'
279

2810
[options]
2911
python_requires = >=3.8, <3.12
3012
install_requires =
31-
esyscmd(`sage-get-system-packages install-requires \
32-
| sed "2,\$s/^/ /;"')dnl
3313

3414
py_modules =
3515
sage.all__sagemath_environment
@@ -61,16 +41,25 @@ scripts =
6141

6242
[options.extras_require]
6343
# sage.env can optionally use sage_conf
64-
conf = esyscmd(`sage-get-system-packages install-requires sage_conf')
44+
conf = SPKG_INSTALL_REQUIRES_sage_conf
45+
6546
# For "sage --docbuild"
66-
docbuild = esyscmd(`sage-get-system-packages install-requires sage_docbuild')
47+
docbuild = SPKG_INSTALL_REQUIRES_sage_docbuild
48+
6749
# For "sage", "sage -t", ...
68-
sage = esyscmd(`sage-get-system-packages install-requires sagelib')
50+
sage = SPKG_INSTALL_REQUIRES_sagelib
51+
6952
# For "sage --cython"
70-
cython = esyscmd(`sage-get-system-packages install-requires cython')
53+
cython = SPKG_INSTALL_REQUIRES_cython
54+
7155
# For "sage --pytest"
72-
pytest = esyscmd(`sage-get-system-packages install-requires pytest')
56+
pytest = SPKG_INSTALL_REQUIRES_pytest
57+
7358
# For "sage --rst2ipynb"
74-
rst2ipynb = esyscmd(`sage-get-system-packages install-requires rst2ipynb')
59+
rst2ipynb = SPKG_INSTALL_REQUIRES_rst2ipynb
60+
61+
# For "sage --tox"
62+
tox = SPKG_INSTALL_REQUIRES_tox
63+
7564
# For "sage --sws2rst"
76-
sws2rst = esyscmd(`sage-get-system-packages install-requires sage_sws2rst')
65+
sws2rst = SPKG_INSTALL_REQUIRES_sage_sws2rst
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*-
12
[build-system]
23
# Minimum requirements for the build system to execute.
34
requires = [
4-
esyscmd(`sage-get-system-packages install-requires-toml \
5-
setuptools \
6-
wheel \
7-
sage_setup \
8-
sagemath_environment \
9-
cython \
10-
gmpy2 \
11-
cysignals \
12-
')]
5+
SPKG_INSTALL_REQUIRES_setuptools
6+
SPKG_INSTALL_REQUIRES_wheel
7+
SPKG_INSTALL_REQUIRES_sage_setup
8+
SPKG_INSTALL_REQUIRES_sagemath_environment
9+
SPKG_INSTALL_REQUIRES_cython
10+
SPKG_INSTALL_REQUIRES_gmpy2
11+
SPKG_INSTALL_REQUIRES_cysignals
12+
]
1313
build-backend = "setuptools.build_meta"

0 commit comments

Comments
 (0)