Skip to content
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

pkgs/*/setup.cfg: Reduce boilerplate by m4-include, reduce complexity of m4 use #35867

Merged
merged 8 commits into from
Jul 9, 2023
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/confdefs.h

/m4/sage_spkg_configures.m4
/m4/sage_spkg_versions*.m4

# no longer generated, but may still be in user worktrees
/src/lib/pkgconfig
Expand Down
19 changes: 15 additions & 4 deletions bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ CONFVERSION=$(cat $PKG/package-version.txt)


bootstrap () {
if [ "${BOOTSTRAP_QUIET}" = "no" ]; then
echo "bootstrap:$LINENO: installing 'm4/sage_spkg_configures.m4'"
fi
rm -f m4/sage_spkg_configures.m4
for a in m4/sage_spkg_configures.m4 m4/sage_spkg_versions.m4 m4/sage_spkg_versions_toml.m4; do
if [ "${BOOTSTRAP_QUIET}" = "no" ]; then
echo "bootstrap:$LINENO: installing '"$a"'"
fi
rm -f $a
echo "# Generated by SAGE_ROOT/bootstrap; do not edit" > $a
done
for a in m4/sage_spkg_versions.m4 m4/sage_spkg_versions_toml.m4; do
echo 'changequote(`>>>'"'"', `<<<'"')dnl" >> $a
done
spkg_configures=""
# initialize SAGE_ENABLE... options for standard packages
for pkgname in $(sage-package list :standard: | sort); do
Expand Down Expand Up @@ -92,12 +98,17 @@ SAGE_SPKG_CONFIGURE_$(echo ${pkgname} | tr '[a-z]' '[A-Z]')"
if test -f "$DIR/requirements.txt" -o -f "$DIR/install-requires.txt"; then
# A Python package
SPKG_TREE_VAR=SAGE_VENV
echo "define(>>>SPKG_INSTALL_REQUIRES_${pkgname}<<<, >>>$(echo $(sage-get-system-packages install-requires ${pkgname}))<<<)dnl" >> m4/sage_spkg_versions.m4
echo "define(>>>SPKG_INSTALL_REQUIRES_${pkgname}<<<, >>>$(echo $(sage-get-system-packages install-requires-toml ${pkgname}))<<<)dnl" >> m4/sage_spkg_versions_toml.m4
fi
fi
spkg_configures="$spkg_configures
SAGE_SPKG_FINALIZE([$pkgname], [$pkgtype], [$SPKG_SOURCE], [$SPKG_TREE_VAR])"
done
echo "$spkg_configures" >> m4/sage_spkg_configures.m4
for a in m4/sage_spkg_versions.m4 m4/sage_spkg_versions_toml.m4; do
echo 'changequote(>>>`<<<, >>>'"'"'<<<)dnl' >> $a
done

for pkgname in $(sage-package list --has-file bootstrap); do
(cd build/pkgs/$pkgname && ./bootstrap) || exit 1
Expand Down
8 changes: 4 additions & 4 deletions build/bin/sage-get-system-packages
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ if [ -z "$SAGE_ROOT" ]; then
fi
case "$SYSTEM" in
install-requires)
# Collect install-requires.txt and output it in the format
# Collect install-requires.txt (falling back to requirements.txt) and output it in the format
# needed by setup.cfg [options] install_requires=
SYSTEM_PACKAGES_FILE_NAMES="install-requires.txt"
SYSTEM_PACKAGES_FILE_NAMES="install-requires.txt requirements.txt"
STRIP_COMMENTS="sed s/#.*//;/^[[:space:]]*$/d;"
COLLECT=
;;
install-requires-toml)
# Collect install-requires.txt and output it in the format
# Collect install-requires.txt (falling back to requirements.txt) and output it in the format
# needed by pyproject.toml [build-system] requires=
SYSTEM_PACKAGES_FILE_NAMES="install-requires.txt"
SYSTEM_PACKAGES_FILE_NAMES="install-requires.txt requirements.txt"
STRIP_COMMENTS="sed s/#.*//;/^[[:space:]]*$/d;s/^/'/;s/$/',/;"
COLLECT=
;;
Expand Down
7 changes: 7 additions & 0 deletions build/pkgs/sagelib/bootstrap
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#! /bin/sh
set -e
export M4PATH="$SAGE_ROOT/m4"
MACRO_PATTERN='SPKG_'
for infile in src/*.m4; do
if [ -f "$infile" ]; then
outfile="src/$(basename $infile .m4)"
if [ "${BOOTSTRAP_QUIET}" = "no" ]; then
echo "$0: installing $(pwd)/$outfile"
fi
m4 "$infile" > "$outfile"
if sed 's/#.*//' "$outfile" | grep -q -E "$MACRO_PATTERN"; then
echo >&2 "$(pwd)/$infile: error: Unrecognized SPKG_ macro:"
grep -E "$MACRO_PATTERN" "$outfile" >&2
exit 1
fi
fi
done
21 changes: 21 additions & 0 deletions m4/setup_cfg_metadata.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
dnl Standard metadata of SageMath distribution packages
dnl
license = GNU General Public License (GPL) v2 or later
author = The Sage Developers
author_email = sage-support@googlegroups.com
url = https://www.sagemath.org

classifiers =
Development Status :: 6 - Mature
Intended Audience :: Education
Intended Audience :: Science/Research
License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
Operating System :: POSIX
Operating System :: MacOS :: MacOS X
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: Implementation :: CPython
Topic :: Scientific/Engineering :: Mathematics
20 changes: 10 additions & 10 deletions pkgs/sagemath-categories/pyproject.toml.m4
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*-
[build-system]
# Minimum requirements for the build system to execute.
requires = [
esyscmd(`sage-get-system-packages install-requires-toml \
setuptools \
wheel \
sage_setup \
sagemath_environment \
sagemath_objects \
cython \
gmpy2 \
cysignals \
')]
SPKG_INSTALL_REQUIRES_setuptools
SPKG_INSTALL_REQUIRES_wheel
SPKG_INSTALL_REQUIRES_sage_setup
SPKG_INSTALL_REQUIRES_sagemath_environment
SPKG_INSTALL_REQUIRES_sagemath_objects
SPKG_INSTALL_REQUIRES_cython
SPKG_INSTALL_REQUIRES_gmpy2
SPKG_INSTALL_REQUIRES_cysignals
]
build-backend = "setuptools.build_meta"
28 changes: 4 additions & 24 deletions pkgs/sagemath-categories/setup.cfg.m4
Original file line number Diff line number Diff line change
@@ -1,36 +1,16 @@
# -*- conf-unix -*-
include(`sage_spkg_versions.m4')dnl' -*- conf-unix -*-
[metadata]
name = sagemath-categories
version = file: VERSION.txt
description = Sage: Open Source Mathematics Software: Sage categories and basic rings
long_description = file: README.rst
long_description_content_type = text/x-rst
license = GNU General Public License (GPL) v2 or later
author = The Sage Developers
author_email = sage-support@googlegroups.com
url = https://www.sagemath.org

classifiers =
Development Status :: 6 - Mature
Intended Audience :: Education
Intended Audience :: Science/Research
License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
Operating System :: POSIX
Operating System :: MacOS :: MacOS X
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: Implementation :: CPython
Topic :: Scientific/Engineering :: Mathematics
include(`setup_cfg_metadata.m4')dnl'

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

[options.extras_require]
test = sagemath-repl
test = SPKG_INSTALL_REQUIRES_sagemath_repl
8 changes: 4 additions & 4 deletions pkgs/sagemath-environment/pyproject.toml.m4
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*-
[build-system]
# Minimum requirements for the build system to execute.
requires = [
esyscmd(`sage-get-system-packages install-requires-toml \
setuptools \
wheel \
')]
SPKG_INSTALL_REQUIRES_setuptools
SPKG_INSTALL_REQUIRES_wheel
]
build-backend = "setuptools.build_meta"
47 changes: 18 additions & 29 deletions pkgs/sagemath-environment/setup.cfg.m4
Original file line number Diff line number Diff line change
@@ -1,35 +1,15 @@
# -*- conf-unix -*-
include(`sage_spkg_versions.m4')dnl' -*- conf-unix -*-
[metadata]
name = sagemath-environment
version = file: VERSION.txt
description = Sage: Open Source Mathematics Software: System and software environment
long_description = file: README.rst
long_description_content_type = text/x-rst
license = GNU General Public License (GPL) v2 or later
author = The Sage Developers
author_email = sage-support@googlegroups.com
url = https://www.sagemath.org

classifiers =
Development Status :: 6 - Mature
Intended Audience :: Education
Intended Audience :: Science/Research
License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
Operating System :: POSIX
Operating System :: MacOS :: MacOS X
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: Implementation :: CPython
Topic :: Scientific/Engineering :: Mathematics
include(`setup_cfg_metadata.m4')dnl'

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

py_modules =
sage.all__sagemath_environment
Expand Down Expand Up @@ -61,16 +41,25 @@ scripts =

[options.extras_require]
# sage.env can optionally use sage_conf
conf = esyscmd(`sage-get-system-packages install-requires sage_conf')
conf = SPKG_INSTALL_REQUIRES_sage_conf

# For "sage --docbuild"
docbuild = esyscmd(`sage-get-system-packages install-requires sage_docbuild')
docbuild = SPKG_INSTALL_REQUIRES_sage_docbuild

# For "sage", "sage -t", ...
sage = esyscmd(`sage-get-system-packages install-requires sagelib')
sage = SPKG_INSTALL_REQUIRES_sagelib

# For "sage --cython"
cython = esyscmd(`sage-get-system-packages install-requires cython')
cython = SPKG_INSTALL_REQUIRES_cython

# For "sage --pytest"
pytest = esyscmd(`sage-get-system-packages install-requires pytest')
pytest = SPKG_INSTALL_REQUIRES_pytest

# For "sage --rst2ipynb"
rst2ipynb = esyscmd(`sage-get-system-packages install-requires rst2ipynb')
rst2ipynb = SPKG_INSTALL_REQUIRES_rst2ipynb

# For "sage --tox"
tox = SPKG_INSTALL_REQUIRES_tox

# For "sage --sws2rst"
sws2rst = esyscmd(`sage-get-system-packages install-requires sage_sws2rst')
sws2rst = SPKG_INSTALL_REQUIRES_sage_sws2rst
18 changes: 9 additions & 9 deletions pkgs/sagemath-objects/pyproject.toml.m4
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*-
[build-system]
# Minimum requirements for the build system to execute.
requires = [
esyscmd(`sage-get-system-packages install-requires-toml \
setuptools \
wheel \
sage_setup \
sagemath_environment \
cython \
gmpy2 \
cysignals \
')]
SPKG_INSTALL_REQUIRES_setuptools
SPKG_INSTALL_REQUIRES_wheel
SPKG_INSTALL_REQUIRES_sage_setup
SPKG_INSTALL_REQUIRES_sagemath_environment
SPKG_INSTALL_REQUIRES_cython
SPKG_INSTALL_REQUIRES_gmpy2
SPKG_INSTALL_REQUIRES_cysignals
]
build-backend = "setuptools.build_meta"
27 changes: 4 additions & 23 deletions pkgs/sagemath-objects/setup.cfg.m4
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,14 @@ version = file: VERSION.txt
description = Sage: Open Source Mathematics Software: Sage objects, elements, parents, categories, coercion, metaclasses
long_description = file: README.rst
long_description_content_type = text/x-rst
license = GNU General Public License (GPL) v2 or later
author = The Sage Developers
author_email = sage-support@googlegroups.com
url = https://www.sagemath.org

classifiers =
Development Status :: 6 - Mature
Intended Audience :: Education
Intended Audience :: Science/Research
License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
Operating System :: POSIX
Operating System :: MacOS :: MacOS X
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: Implementation :: CPython
Topic :: Scientific/Engineering :: Mathematics
include(`setup_cfg_metadata.m4')dnl'

[options]
include(`sage_spkg_versions.m4')dnl'
python_requires = >=3.8, <3.12
install_requires =
esyscmd(`sage-get-system-packages install-requires \
gmpy2 \
cysignals \
| sed "2,\$s/^/ /;"')dnl
SPKG_INSTALL_REQUIRES_gmpy2
SPKG_INSTALL_REQUIRES_cysignals

[options.extras_require]
# Currently we do not use the sage doctester to test sagemath-objects,
Expand Down
8 changes: 4 additions & 4 deletions pkgs/sagemath-repl/pyproject.toml.m4
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*-
[build-system]
# Minimum requirements for the build system to execute.
requires = [
esyscmd(`sage-get-system-packages install-requires-toml \
setuptools \
wheel \
')]
SPKG_INSTALL_REQUIRES_setuptools
SPKG_INSTALL_REQUIRES_wheel
]
build-backend = "setuptools.build_meta"
32 changes: 6 additions & 26 deletions pkgs/sagemath-repl/setup.cfg.m4
Original file line number Diff line number Diff line change
@@ -1,39 +1,19 @@
# -*- conf-unix -*-
include(`sage_spkg_versions.m4')dnl' -*- conf-unix -*-
[metadata]
name = sagemath-repl
version = file: VERSION.txt
description = Sage: Open Source Mathematics Software: System and software environment
long_description = file: README.rst
long_description_content_type = text/x-rst
license = GNU General Public License (GPL) v2 or later
author = The Sage Developers
author_email = sage-support@googlegroups.com
url = https://www.sagemath.org

classifiers =
Development Status :: 6 - Mature
Intended Audience :: Education
Intended Audience :: Science/Research
License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
Operating System :: POSIX
Operating System :: MacOS :: MacOS X
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: Implementation :: CPython
Topic :: Scientific/Engineering :: Mathematics
include(`setup_cfg_metadata.m4')dnl'

[options]
python_requires = >=3.8, <3.12
install_requires =
esyscmd(`sage-get-system-packages install-requires \
sagemath_objects \
sagemath_environment \
ipython \
ipywidgets \
| sed "2,\$s/^/ /;"')dnl
SPKG_INSTALL_REQUIRES_sagemath_objects
SPKG_INSTALL_REQUIRES_sagemath_environment
SPKG_INSTALL_REQUIRES_ipython
SPKG_INSTALL_REQUIRES_ipywidgets

py_modules =
sage.all__sagemath_repl
Expand Down
Loading