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/sagemath-standard: Move metadata from setup.cfg to pyproject.toml #37902

Closed
wants to merge 9 commits into from
Closed
2 changes: 1 addition & 1 deletion .ci/write-dockerfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ $ADD Makefile VERSION.txt COPYING.txt condarc.yml README.md bootstrap bootstrap-
$ADD config/config.rpath /new/config/config.rpath
$ADD src/doc/bootstrap /new/src/doc/bootstrap
$ADD src/bin /new/src/bin
$ADD src/Pipfile.m4 src/pyproject.toml src/requirements.txt.m4 src/setup.cfg.m4 src/VERSION.txt /new/src/
$ADD src/Pipfile.m4 src/pyproject.toml src/requirements.txt.m4 src/VERSION.txt /new/src/
$ADD m4 /new/m4
$ADD pkgs /new/pkgs
$ADD build /new/build
Expand Down
13 changes: 0 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,6 @@ __pycache__/
build/temp.*/
build/bin/sage-build-env-config

# Generated files in build
build/pkgs/cypari/version_requirements.txt
build/pkgs/cysignals/version_requirements.txt
build/pkgs/cython/version_requirements.txt
build/pkgs/gmpy2/version_requirements.txt
build/pkgs/jupyter_core/version_requirements.txt
build/pkgs/memory_allocator/version_requirements.txt
build/pkgs/numpy/version_requirements.txt
build/pkgs/pkgconfig/version_requirements.txt
build/pkgs/pplpy/version_requirements.txt
build/pkgs/setuptools/version_requirements.txt
build/pkgs/wheel/version_requirements.txt

# Generated files in the top-level source trees
/pkgs/*/build
/pkgs/*/dist
Expand Down
11 changes: 0 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,6 @@ bootstrap-clean:
rm -f src/Pipfile
rm -f src/requirements.txt
rm -f src/setup.cfg
rm -f build/pkgs/cypari/version_requirements.txt
rm -f build/pkgs/cysignals/version_requirements.txt
rm -f build/pkgs/cython/version_requirements.txt
rm -f build/pkgs/gmpy2/version_requirements.txt
rm -f build/pkgs/jupyter_core/version_requirements.txt
rm -f build/pkgs/memory_allocator/version_requirements.txt
rm -f build/pkgs/numpy/version_requirements.txt
rm -f build/pkgs/pkgconfig/version_requirements.txt
rm -f build/pkgs/pplpy/version_requirements.txt
rm -f build/pkgs/setuptools/version_requirements.txt
rm -f build/pkgs/wheel/version_requirements.txt

# Remove absolutely everything which isn't part of the git repo
maintainer-clean: distclean bootstrap-clean
Expand Down
23 changes: 1 addition & 22 deletions bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ MAKE="${MAKE:-make}"


bootstrap () {
for pkgname in cypari cysignals cython gmpy2 jupyter_core memory_allocator numpy pkgconfig pplpy setuptools wheel; do
# Write the version_requirements.txt files for dependencies declared in pyproject.toml
target=build/pkgs/${pkgname}/version_requirements.txt
if [ "${BOOTSTRAP_QUIET}" = "no" ]; then
echo "bootstrap:$LINENO: installing '"$target"'"
fi
echo "# Generated by SAGE_ROOT/bootstrap based on src/pyproject.toml; do not edit directly" > $target
sage-get-system-packages install-requires ${pkgname} >> $target
done
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"'"
Expand Down Expand Up @@ -232,19 +223,7 @@ save () {
src/environment-optional-3.[89].yml src/environment-optional-3.1[0-9].yml \
src/Pipfile \
src/pyproject.toml \
src/requirements.txt \
src/setup.cfg \
build/pkgs/cypari/version_requirements.txt \
build/pkgs/cysignals/version_requirements.txt \
build/pkgs/cython/version_requirements.txt \
build/pkgs/gmpy2/version_requirements.txt \
build/pkgs/jupyter_core/version_requirements.txt \
build/pkgs/memory_allocator/version_requirements.txt \
build/pkgs/numpy/version_requirements.txt \
build/pkgs/pkgconfig/version_requirements.txt \
build/pkgs/pplpy/version_requirements.txt \
build/pkgs/setuptools/version_requirements.txt \
build/pkgs/wheel/version_requirements.txt
src/requirements.txt

# Update version; this re-computes the checksum
sage-package update configure "$NEWCONFVERSION"
Expand Down
9 changes: 7 additions & 2 deletions build/bin/sage-get-system-packages
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,14 @@ for PKG_BASE in $SPKGS; do
*pyproject.toml)
SYSTEM_PACKAGES_FILE="$SAGE_ROOT"/$NAME
if [ -f "$SYSTEM_PACKAGES_FILE" ]; then
# Extract from the "requires" block in src/pyproject.toml
# Extract from src/pyproject.toml:
# - from the "[build-system] requires" value
# - from "[project] dependencies",
# - from "[project.optional-dependencies]"
# Packages are in the format "'sage-conf ~= 10.3b3',"
PACKAGE_INFO=$(sed -n '/requires *= *\[/,/^\]/s/^ *'\''\('$PKG_BASE'.*\)'\'',/\1/p' "$SAGE_ROOT/src/pyproject.toml")
# Accept dashes and underscores in package names as equivalent:
PKG_REGEX=$(echo $PKG_BASE | sed 's/[-_]/[-_]/g')
PACKAGE_INFO=$(sed -En '/(requires|dependencies|R) *= *\[/,/^\]/s/^ *'\''('$PKG_REGEX'.*)'\'',/\1/p' "$SAGE_ROOT/src/pyproject.toml" | sort -u)
if [ -n "$PACKAGE_INFO" ]; then
echo "$PACKAGE_INFO" | ${STRIP_COMMENTS}
[ $SYSTEM = versions ] || break
Expand Down
2 changes: 1 addition & 1 deletion build/pkgs/conway_polynomials/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
conway-polynomials >=0.8
conway-polynomials
1 change: 1 addition & 0 deletions build/pkgs/cypari/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cypari2
1 change: 1 addition & 0 deletions build/pkgs/cysignals/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cysignals
1 change: 1 addition & 0 deletions build/pkgs/cython/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cython
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reintroduction of these version requirement files containing no actual requirements (which however are present in the pyproject.toml file) seems pretty pointless. This also reverts the design of #36982 - which already went through the "disputed" process.

Just add all packages whose version is now specified in the pyproject toml in the list in bootstrap.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems pretty pointless.

No. This defines the map between SPKG names and Python distribution names.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add all packages whose version is now specified in the pyproject toml in the list in bootstrap.

No.

Copy link
Collaborator

@kwankyu kwankyu Aug 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... This also reverts the design of #36982 - which already went through the "disputed" process.

As I understand it, by the design of #36982:

src/pyproject.toml specifies version constraints of the dependencies of the distribution package sagemath-standard, independently from the sage-distribution.

This PR respects that, and also reintroduces build/pkgs/*/version_requirements.txt files to specify further version constraints of the sage packages for the sage-distribution.

@mkoeppe Am I right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kwankyu That's correct.

2 changes: 1 addition & 1 deletion build/pkgs/fpylll/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fpylll >=0.5.9
fpylll
1 change: 1 addition & 0 deletions build/pkgs/gmpy2/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gmpy2
4 changes: 1 addition & 3 deletions build/pkgs/importlib_metadata/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# 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 changes: 1 addition & 3 deletions build/pkgs/importlib_resources/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# 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
2 changes: 1 addition & 1 deletion build/pkgs/ipykernel/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ipykernel >=5.2.1
ipykernel
2 changes: 1 addition & 1 deletion build/pkgs/ipython/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ipython >=7.13.0
ipython
2 changes: 1 addition & 1 deletion build/pkgs/ipywidgets/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ipywidgets >=7.5.1
ipywidgets
1 change: 1 addition & 0 deletions build/pkgs/jupyter_core/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jupyter-core
2 changes: 1 addition & 1 deletion build/pkgs/lrcalc_python/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lrcalc ~=2.1
lrcalc
4 changes: 1 addition & 3 deletions build/pkgs/matplotlib/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# Issue #33642: Set lower bound for use of matplotlib color maps introduced in #33491,
# and to suppress deprecation warnings (https://github.com/matplotlib/matplotlib/pull/21073)
matplotlib >=3.5.1
matplotlib
1 change: 1 addition & 0 deletions build/pkgs/memory_allocator/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
memory_allocator
2 changes: 1 addition & 1 deletion build/pkgs/mpmath/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mpmath >=1.1.0
mpmath
2 changes: 1 addition & 1 deletion build/pkgs/networkx/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
networkx >=2.4
networkx
1 change: 1 addition & 0 deletions build/pkgs/numpy/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
numpy
2 changes: 1 addition & 1 deletion build/pkgs/pexpect/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pexpect >=4.8.0
pexpect
2 changes: 1 addition & 1 deletion build/pkgs/pillow/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pillow >=7.2.0
pillow
1 change: 1 addition & 0 deletions build/pkgs/pkgconfig/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pkgconfig
1 change: 1 addition & 0 deletions build/pkgs/pplpy/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pplpy
2 changes: 1 addition & 1 deletion build/pkgs/ptyprocess/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ptyprocess > 0.5
ptyprocess
2 changes: 1 addition & 1 deletion build/pkgs/requests/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
requests >=2.13.0
requests
2 changes: 1 addition & 1 deletion build/pkgs/rpy2/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rpy2 >=3.3
rpy2
8 changes: 1 addition & 7 deletions build/pkgs/scipy/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
# 1.8 is known good version.
# Per https://docs.scipy.org/doc/scipy/dev/core-dev/index.html#version-numbering
# and https://docs.scipy.org/doc/scipy/dev/core-dev/index.html#deprecations,
# deprecations cannot be introduced in micro releases.
# SciPy devs wait "at least 6 months", "in practice two (minor) releases"
# from deprecation to removal of a feature.
scipy >=1.5
scipy
1 change: 1 addition & 0 deletions build/pkgs/setuptools/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setuptools
2 changes: 1 addition & 1 deletion build/pkgs/six/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
six >=1.15.0
six
2 changes: 1 addition & 1 deletion build/pkgs/sympy/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sympy >=1.6, <2.0
sympy
4 changes: 1 addition & 3 deletions build/pkgs/typing_extensions/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# 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
1 change: 1 addition & 0 deletions build/pkgs/wheel/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
wheel
1 change: 0 additions & 1 deletion pkgs/sagemath-standard/setup.cfg

This file was deleted.

1 change: 0 additions & 1 deletion pkgs/sagemath-standard/setup.cfg.m4

This file was deleted.

4 changes: 2 additions & 2 deletions pkgs/sagemath-standard/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[tox]
envlist =
# Build and test without using the concrete dependencies specified by requirements.txt,
# using the dependencies declared in pyproject.toml and setup.cfg (install-requires) only:
# using the dependencies declared in pyproject.toml (build-system requires, dependencies) only:
# Still use ONLY the wheels built and stored by the Sage distribution (no PyPI).
#
# ./sage -sh -c '(cd pkgs/sagemath-standard && tox -v -v -v -e sagepython-sagewheels-nopypi-norequirements)'
Expand Down Expand Up @@ -58,7 +58,7 @@ envlist =
#
# ./sage -sh -c '(cd pkgs/sagemath-standard && tox -v -v -v -e sagepython-sagewheels-pipenv-dist)'
#
# Build using the dependencies declared in pyproject.toml and setup.cfg (install-requires) only.
# Build using the dependencies declared in pyproject.toml (build-system requires, dependencies) only:
# Use the wheels built and stored by the Sage distribution,
# and additionally allow packages from PyPI.
#
Expand Down
8 changes: 4 additions & 4 deletions src/Pipfile.m4
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
## We do not list packages that are already declared as install_requires
## in setup.cfg
## We do not list packages that are already declared as dependencies (install_requires)
## in pyproject.toml
pycodestyle = "*"
tox = "*"
pytest = "*"
rope = "*"
six = "*"

[packages]
## We do not list packages that are already declared as install_requires
## in setup.cfg
## We do not list packages that are already declared as dependencies (install_requires)
## in pyproject.toml

[packages.e1839a8]
path = "."
4 changes: 2 additions & 2 deletions src/doc/en/developer/coding_basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ included in one of the following places:
This practice is deprecated, see :issue:`33037`.

In all cases, the files must be listed (explicitly or via wildcards) in
the section ``options.package_data`` of the file
:sage_root:`pkgs/sagemath-standard/setup.cfg.m4` (or the corresponding
the section ``[tool.setuptools.package-data]`` of the file
:sage_root:`SAGE_ROOT/pkgs/sagemath-standard/pyproject.toml` (or the corresponding
file of another distribution).

Large data files should not be added to the Sage source tree. Instead, it
Expand Down
6 changes: 4 additions & 2 deletions src/doc/en/developer/coding_in_python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ Python language standard

Sage library code needs to be compatible with all versions of Python
that Sage supports. The information regarding the supported versions
can be found in the files ``build/pkgs/python3/spkg-configure.m4`` and
``src/setup.cfg.m4``.
can be found in the files ``build/pkgs/python3/spkg-configure.m4``
(for the Sage distribution), ``src/pyproject.toml`` (for the Sage
library), and ``m4/pyproject_toml_metadata.m4`` (for most other
distribution packages in ``pkgs/``).

Python 3.9 is the oldest supported version. Hence,
all language and library features that are available in Python 3.9 can
Expand Down
25 changes: 14 additions & 11 deletions src/doc/en/developer/packaging_sage_library.rst
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ The source directory of a distribution package, such as

$ ./sage --fixdistributions --set all --from-egg-info

- `pyproject.toml <https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/>`_,
`setup.cfg <https://setuptools.pypa.io/en/latest/userguide/declarative_config.html>`_,
- `pyproject.toml <https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/>`_
and `requirements.txt <https://pip.pypa.io/en/stable/user_guide/#requirements-files>`_ --
standard Python packaging metadata, declaring the distribution name, dependencies,
etc.
Expand Down Expand Up @@ -288,8 +287,9 @@ modules must be part of the distribution, or provided by another
distribution -- which then must be declared as a run-time dependency.

*Declaring run-time dependencies:* These dependencies are declared in
``setup.cfg`` (generated from ``setup.cfg.m4``) as
`install_requires <https://setuptools.pypa.io/en/latest/userguide/dependency_management.html#declaring-required-dependency>`_.
``pyproject.toml`` (generated from ``pyproject.toml.m4``) as
`[project] dependencies <https://setuptools.pypa.io/en/latest/userguide/dependency_management.html#declaring-required-dependency>`_ (in the older terminology of ``setup.cfg`` and ``setup.py``,
these dependencies were known as ``install_requires``).

*Reducing module-level run-time dependencies:*

Expand Down Expand Up @@ -467,14 +467,17 @@ features, which will only be working if the user also has installed
**sagemath-symbolics**.

*Declaring optional run-time dependencies:* It is possible to declare
such optional dependencies as `extras_require <https://setuptools.pypa.io/en/latest/userguide/dependency_management.html#optional-dependencies>`_ in ``setup.cfg``
(generated from ``setup.cfg.m4``). This is a very limited mechanism
such dependencies as `[project.optional-dependencies] <https://setuptools.pypa.io/en/latest/userguide/dependency_management.html#optional-dependencies>`_ in ``pyproject.toml``
(generated from ``pyproject.toml.m4``).
(In the older terminology of ``setup.cfg`` and ``setup.py``,
these optional dependencies were known as ``extras_require``.)
This is a very limited mechanism
-- in particular it does not affect the build phase of the
distribution in any way. It basically only provides a way to give a
nickname to a distribution that can be installed as an add-on.

In our example, we could declare an ``extras_require`` so that users
could use ``pip install sagemath-coding[symbolics]``.
In our example, we could declare an optional dependency so that users
could use ``pip install "sagemath-coding[symbolics]"``.


Doctest-only dependencies
Expand Down Expand Up @@ -516,7 +519,7 @@ The version information for dependencies comes from the files
``build/pkgs/*/package-version.txt``. We use the
`m4 <https://www.gnu.org/software/m4/manual/html_node/index.html>`_
macro processor to insert the version information in the generated files
``pyproject.toml``, ``setup.cfg``, ``requirements.txt``.
``pyproject.toml`` and ``requirements.txt``.


Hierarchy of distribution packages
Expand Down Expand Up @@ -546,8 +549,8 @@ Hierarchy of distribution packages
sphinx_plot(g, figsize=(8, 4), axes=False)


Solid arrows indicate ``install_requires``, i.e., a declared runtime dependency.
Dashed arrows indicate ``extras_require``, i.e., a declared optional runtime dependency.
Solid arrows indicate declared runtime dependencies (``install_requires``).
Dashed arrows indicate declared optional runtime dependencies (``extras_require``).
Not shown in the diagram are build dependencies and optional dependencies for testing.

- `sage_conf <https://pypi.org/project/sage-conf/>`_ is a configuration
Expand Down
Loading
Loading