Skip to content

Commit

Permalink
Merge branch 'build-pyprojecttoml-install-requires' into pyproject-sa…
Browse files Browse the repository at this point in the history
…gelib
  • Loading branch information
tobiasdiez authored Feb 24, 2024
2 parents 30b3d78 + 0e40c3b commit 1cc6131
Show file tree
Hide file tree
Showing 19 changed files with 83 additions and 57 deletions.
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/install-requires.txt
build/pkgs/cysignals/install-requires.txt
build/pkgs/cython/install-requires.txt
build/pkgs/gmpy2/install-requires.txt
build/pkgs/jupyter_core/install-requires.txt
build/pkgs/memory_allocator/install-requires.txt
build/pkgs/numpy/install-requires.txt
build/pkgs/pkgconfig/install-requires.txt
build/pkgs/pplpy/install-requires.txt
build/pkgs/setuptools/install-requires.txt
build/pkgs/wheel/install-requires.txt

# Generated files in the top-level source trees
/pkgs/*/build
/pkgs/*/dist
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ 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

Expand Down
10 changes: 10 additions & 0 deletions bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ bootstrap () {
for a in m4/sage_spkg_versions.m4 m4/sage_spkg_versions_toml.m4; do
echo 'changequote(`>>>'"'"', `<<<'"')dnl" >> $a
done

for pkgname in cypari cysignals cython gmpy2 jupyter_core memory_allocator numpy pkgconfig pplpy setuptools wheel; do
# Write the install-requires.txt files for dependencies declared in pyproject.toml
target=build/pkgs/${pkgname}/install-requires.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
spkg_configures=""
# initialize SAGE_ENABLE... options for standard packages
for pkgname in $(sage-package list :standard:); do
Expand Down
33 changes: 25 additions & 8 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 install-requires.txt (falling back to requirements.txt) and output it in the format
# Collect from src/pyproject.toml or from 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 requirements.txt"
STRIP_COMMENTS="sed s/#.*//;/^[[:space:]]*$/d;"
FROM_PYPROJECT_TOML=1
COLLECT=
;;
install-requires-toml)
# Collect install-requires.txt (falling back to requirements.txt) and output it in the format
# Collect from src/pyproject.toml or from 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 requirements.txt"
STRIP_COMMENTS="sed s/#.*//;/^[[:space:]]*$/d;s/^/'/;s/$/',/;"
FROM_PYPROJECT_TOML=1
COLLECT=
;;
pip)
SYSTEM_PACKAGES_FILE_NAMES="requirements.txt install-requires.txt"
STRIP_COMMENTS='sed s/#.*//;s/[[:space:]]//g;'
FROM_PYPROJECT_TOML=1
COLLECT=echo
;;
*)
Expand All @@ -42,10 +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
if [ $FROM_PYPROJECT_TOML -eq 1 ]; then
if [ -f "$SAGE_ROOT/src/pyproject.toml" ]; then
# Extract from the "requires" block in src/pyproject.toml
REQUIRES=$(sed -n '/requires = \[/,/^\]/p' "$SAGE_ROOT/src/pyproject.toml")
# Packages are in the format "'sage-conf ~= 10.3b3',"
PACKAGE_INFO=$(echo "$REQUIRES" | sed -n "s/^\s*'\($PKG_BASE.*\)',/\1/p")
if [ -n "$PACKAGE_INFO" ]; then
echo "$PACKAGE_INFO" | ${STRIP_COMMENTS}
continue
fi
fi
fi

case "$SYSTEM:$ENABLE_SYSTEM_SITE_PACKAGES" in
install-requires*|pip*)
Expand Down Expand Up @@ -73,12 +90,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/install-requires.txt

This file was deleted.

1 change: 0 additions & 1 deletion build/pkgs/cysignals/install-requires.txt

This file was deleted.

3 changes: 0 additions & 3 deletions build/pkgs/cython/install-requires.txt

This file was deleted.

1 change: 0 additions & 1 deletion build/pkgs/gmpy2/install-requires.txt

This file was deleted.

1 change: 0 additions & 1 deletion build/pkgs/jupyter_core/install-requires.txt

This file was deleted.

1 change: 0 additions & 1 deletion build/pkgs/memory_allocator/install-requires.txt

This file was deleted.

1 change: 0 additions & 1 deletion build/pkgs/numpy/install-requires.txt

This file was deleted.

1 change: 0 additions & 1 deletion build/pkgs/pkgconfig/install-requires.txt

This file was deleted.

2 changes: 0 additions & 2 deletions build/pkgs/pplpy/install-requires.txt

This file was deleted.

3 changes: 0 additions & 3 deletions build/pkgs/setuptools/install-requires.txt

This file was deleted.

2 changes: 0 additions & 2 deletions build/pkgs/wheel/install-requires.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 @@ -608,6 +608,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``.
It is strongly recommended to include comments (starting with ``#``)
in the file that explain why a particular lower or upper bound is
Expand Down
33 changes: 33 additions & 0 deletions src/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by SAGE_ROOT/bootstrap; do not edit
[build-system]
# Minimum requirements for the build system to execute.
requires = [
"sage_setup[autogen]",
# Some version of sage-conf is required.
# Note that PEP517/518 have no notion of optional sage_spkg dependencies:
# https://github.com/pypa/pip/issues/6144
'sage-conf ~= 10.3b4',
# 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',
'sage-setup ~= 10.3b4',
'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'
]
29 changes: 0 additions & 29 deletions src/pyproject.toml.m4

This file was deleted.

0 comments on commit 1cc6131

Please sign in to comment.