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

Make pyproject.toml the source for build dependencies #36982

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@

/src/setup.cfg
/src/requirements.txt
/src/pyproject.toml
/src/Pipfile
/src/Pipfile.lock
/Pipfile
Expand Down Expand Up @@ -186,6 +185,19 @@ __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
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,19 @@ bootstrap-clean:
rm -rf src/doc/en/reference/spkg/*.rst
for a in environment environment-optional src/environment src/environment-dev src/environment-optional; do rm -f $$a.yml $$a-3.[89].yml $$a-3.1[0-9].yml; done
rm -f src/Pipfile
rm -f src/pyproject.toml
rm -f src/requirements.txt
rm -f src/setup.cfg
tobiasdiez marked this conversation as resolved.
Show resolved Hide resolved
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
22 changes: 21 additions & 1 deletion bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ CONFVERSION=$(cat $PKG/package-version.txt)


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
tobiasdiez marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -233,7 +242,18 @@ save () {
src/Pipfile \
src/pyproject.toml \
src/requirements.txt \
src/setup.cfg
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

# Update version
echo "$NEWCONFVERSION" >$PKG/package-version.txt
Expand Down
34 changes: 25 additions & 9 deletions build/bin/sage-get-system-packages
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,25 @@ fi

case "$SYSTEM" in
install-requires)
# Collect version_requirements.txt (falling back to requirements.txt) and output it in the format
# Collect from src/pyproject.toml or from version_requirements.txt (falling back to requirements.txt) and output it in the format
# needed by setup.cfg [options] version_requirements=
SYSTEM_PACKAGES_FILE_NAMES="version_requirements.txt requirements.txt"
STRIP_COMMENTS="sed s/#.*//;/^[[:space:]]*$/d;"
FROM_PYPROJECT_TOML=1
COLLECT=
;;
install-requires-toml)
# Collect version_requirements.txt (falling back to requirements.txt) and output it in the format
# Collect from src/pyproject.toml or from version_requirements.txt (falling back to requirements.txt) and output it in the format
# needed by pyproject.toml [build-system] requires=
SYSTEM_PACKAGES_FILE_NAMES="version_requirements.txt requirements.txt"
STRIP_COMMENTS="sed s/#.*//;/^[[:space:]]*$/d;s/^/'/;s/$/',/;"
FROM_PYPROJECT_TOML=1
COLLECT=
;;
pip)
SYSTEM_PACKAGES_FILE_NAMES="requirements.txt version_requirements.txt"
STRIP_COMMENTS='sed s/#.*//;s/[[:space:]]//g;'
FROM_PYPROJECT_TOML=1
COLLECT=echo
;;
*)
Expand All @@ -42,11 +45,24 @@ case "$SYSTEM" in
fi
SYSTEM_PACKAGES_FILE_NAMES="distros/$SYSTEM.txt"
STRIP_COMMENTS="sed s/#.*//;s/\${PYTHON_MINOR}/${PYTHON_MINOR}/g"
FROM_PYPROJECT_TOML=0
COLLECT=echo
;;
esac
for PKG_BASE in $SPKGS; do

for PKG_BASE in $SPKGS; do
if [ $FROM_PYPROJECT_TOML -eq 1 ]; then
if [ -f "$SAGE_ROOT/src/pyproject.toml" ]; then
# Extract from the "requires" block in src/pyproject.toml
# Packages are in the format "'sage-conf ~= 10.3b3',"
PACKAGE_INFO=$(sed -n '/requires *= *\[/,/^\]/s/^ *'\''\('$PKG_BASE'.*\)'\'',/\1/p' "$SAGE_ROOT/src/pyproject.toml")
if [ -n "$PACKAGE_INFO" ]; then
echo "$PACKAGE_INFO" | ${STRIP_COMMENTS}
continue
fi
fi
fi

case "$SYSTEM:$ENABLE_SYSTEM_SITE_PACKAGES" in
install-requires*|pip*)
# This is output for installation of packages into a Python environment.
Expand All @@ -73,12 +89,12 @@ for PKG_BASE in $SPKGS; do
for NAME in $SYSTEM_PACKAGES_FILE_NAMES; do
SYSTEM_PACKAGES_FILE="$SAGE_ROOT"/build/pkgs/$PKG_BASE/$NAME
if [ -f $SYSTEM_PACKAGES_FILE ]; then
if [ -z "$COLLECT" ]; then
${STRIP_COMMENTS} $SYSTEM_PACKAGES_FILE
else
$COLLECT $(${STRIP_COMMENTS} $SYSTEM_PACKAGES_FILE)
fi
break
if [ -z "$COLLECT" ]; then
${STRIP_COMMENTS} $SYSTEM_PACKAGES_FILE
else
$COLLECT $(${STRIP_COMMENTS} $SYSTEM_PACKAGES_FILE)
fi
break
fi
done
done
1 change: 0 additions & 1 deletion build/pkgs/cypari/version_requirements.txt

This file was deleted.

1 change: 0 additions & 1 deletion build/pkgs/cysignals/version_requirements.txt

This file was deleted.

3 changes: 0 additions & 3 deletions build/pkgs/cython/version_requirements.txt

This file was deleted.

1 change: 0 additions & 1 deletion build/pkgs/gmpy2/version_requirements.txt

This file was deleted.

1 change: 0 additions & 1 deletion build/pkgs/jupyter_core/version_requirements.txt

This file was deleted.

1 change: 0 additions & 1 deletion build/pkgs/memory_allocator/version_requirements.txt

This file was deleted.

1 change: 0 additions & 1 deletion build/pkgs/numpy/version_requirements.txt

This file was deleted.

1 change: 0 additions & 1 deletion build/pkgs/pkgconfig/version_requirements.txt

This file was deleted.

2 changes: 0 additions & 2 deletions build/pkgs/pplpy/version_requirements.txt

This file was deleted.

3 changes: 0 additions & 3 deletions build/pkgs/setuptools/version_requirements.txt

This file was deleted.

2 changes: 0 additions & 2 deletions build/pkgs/wheel/version_requirements.txt

This file was deleted.

1 change: 0 additions & 1 deletion pkgs/sagemath-standard/pyproject.toml.m4

This file was deleted.

2 changes: 2 additions & 0 deletions src/doc/en/developer/packaging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,8 @@ and upper bounds). The constraints are in the format of the
<https://setuptools.readthedocs.io/en/latest/userguide/declarative_config.html>`_
or `setup.py
<https://packaging.python.org/discussions/install-requires-vs-requirements/#id5>`_.
An exception are build time dependencies of Sage library, which should instead
be declared in the ``requires`` block of ``pyproject.toml``.

Sage uses these version constraints for two purposes:

Expand Down
26 changes: 26 additions & 0 deletions src/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[build-system]
# Minimum requirements for the build system to execute.
requires = [
# 68.1.0 Promote pyproject.toml's [tool.setuptools] out of beta.
# 68.1.1 Fix editable install finder handling of nested packages
'setuptools >= 68.1.1',
# version constraint for macOS Big Sur support (see https://github.com/sagemath/sage/issues/31050)
'wheel >=0.36.2',
'cypari2 >=2.1.1',
'cysignals >=1.10.2',
# Exclude 3.0.3 because of https://github.com/cython/cython/issues/5748
'cython >=3.0, != 3.0.3, <4.0',
'gmpy2 ~=2.1.b999',
'jupyter_core >=4.6.3',
'memory_allocator',
'numpy >=1.19',
'pkgconfig',
# pplpy 0.8.4 and earlier do not declare dependencies correctly (see https://github.com/sagemath/sage/issues/30922)
'pplpy >=0.8.6',
]
build-backend = "setuptools.build_meta"

[tool.conda-lock]
platforms = [
'osx-64', 'linux-64', 'linux-aarch64', 'osx-arm64'
]
23 changes: 0 additions & 23 deletions src/pyproject.toml.m4

This file was deleted.

Loading