Skip to content

Commit f19f431

Browse files
author
Release Manager
committed
gh-36982: Make pyproject.toml the source for build dependencies <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> As noted in #36951 (comment), the fact that the dependency declaration of sage-the-library depends on information contain in sage-the-distro's build folder is problematic for the separation of concerns. Sage-the-distro should rely on information of sage-the-library, not the other way around. Here we fix this for the build requirements by making `src/pyproject.toml` the single source of thruth. The corresponding `install-requires.txt` are demoted to mere indicator files (to be removed later). Moreover, this change allows us to make `pyproject.toml` a static file (no longer generated by configure), which should help with downstream packaging. --- Happy new year! <!-- 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". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [ ] The title is concise, informative, and self-explanatory. - [ ] 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 - #37796 <!-- 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: #36982 Reported by: Tobias Diez Reviewer(s): Dima Pasechnik, Gonzalo Tornaría, Matthias Köppe, Tobias Diez
2 parents 23ba3d8 + 33227cb commit f19f431

File tree

19 files changed

+98
-53
lines changed

19 files changed

+98
-53
lines changed

.gitignore

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353

5454
/src/setup.cfg
5555
/src/requirements.txt
56-
/src/pyproject.toml
5756
/src/Pipfile
5857
/src/Pipfile.lock
5958
/Pipfile
@@ -186,6 +185,19 @@ __pycache__/
186185
build/temp.*/
187186
build/bin/sage-build-env-config
188187

188+
# Generated files in build
189+
build/pkgs/cypari/version_requirements.txt
190+
build/pkgs/cysignals/version_requirements.txt
191+
build/pkgs/cython/version_requirements.txt
192+
build/pkgs/gmpy2/version_requirements.txt
193+
build/pkgs/jupyter_core/version_requirements.txt
194+
build/pkgs/memory_allocator/version_requirements.txt
195+
build/pkgs/numpy/version_requirements.txt
196+
build/pkgs/pkgconfig/version_requirements.txt
197+
build/pkgs/pplpy/version_requirements.txt
198+
build/pkgs/setuptools/version_requirements.txt
199+
build/pkgs/wheel/version_requirements.txt
200+
189201
# Generated files in the top-level source trees
190202
/pkgs/*/build
191203
/pkgs/*/dist

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,19 @@ bootstrap-clean:
175175
rm -rf src/doc/en/reference/spkg/*.rst
176176
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
177177
rm -f src/Pipfile
178-
rm -f src/pyproject.toml
179178
rm -f src/requirements.txt
180179
rm -f src/setup.cfg
180+
rm -f build/pkgs/cypari/version_requirements.txt
181+
rm -f build/pkgs/cysignals/version_requirements.txt
182+
rm -f build/pkgs/cython/version_requirements.txt
183+
rm -f build/pkgs/gmpy2/version_requirements.txt
184+
rm -f build/pkgs/jupyter_core/version_requirements.txt
185+
rm -f build/pkgs/memory_allocator/version_requirements.txt
186+
rm -f build/pkgs/numpy/version_requirements.txt
187+
rm -f build/pkgs/pkgconfig/version_requirements.txt
188+
rm -f build/pkgs/pplpy/version_requirements.txt
189+
rm -f build/pkgs/setuptools/version_requirements.txt
190+
rm -f build/pkgs/wheel/version_requirements.txt
181191

182192
# Remove absolutely everything which isn't part of the git repo
183193
maintainer-clean: distclean bootstrap-clean

bootstrap

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ CONFVERSION=$(cat $PKG/package-version.txt)
3535

3636

3737
bootstrap () {
38+
for pkgname in cypari cysignals cython gmpy2 jupyter_core memory_allocator numpy pkgconfig pplpy setuptools wheel; do
39+
# Write the version_requirements.txt files for dependencies declared in pyproject.toml
40+
target=build/pkgs/${pkgname}/version_requirements.txt
41+
if [ "${BOOTSTRAP_QUIET}" = "no" ]; then
42+
echo "bootstrap:$LINENO: installing '"$target"'"
43+
fi
44+
echo "# Generated by SAGE_ROOT/bootstrap based on src/pyproject.toml; do not edit directly" > $target
45+
sage-get-system-packages install-requires ${pkgname} >> $target
46+
done
3847
for a in m4/sage_spkg_configures.m4 m4/sage_spkg_versions.m4 m4/sage_spkg_versions_toml.m4; do
3948
if [ "${BOOTSTRAP_QUIET}" = "no" ]; then
4049
echo "bootstrap:$LINENO: installing '"$a"'"
@@ -233,7 +242,18 @@ save () {
233242
src/Pipfile \
234243
src/pyproject.toml \
235244
src/requirements.txt \
236-
src/setup.cfg
245+
src/setup.cfg \
246+
build/pkgs/cypari/version_requirements.txt \
247+
build/pkgs/cysignals/version_requirements.txt \
248+
build/pkgs/cython/version_requirements.txt \
249+
build/pkgs/gmpy2/version_requirements.txt \
250+
build/pkgs/jupyter_core/version_requirements.txt \
251+
build/pkgs/memory_allocator/version_requirements.txt \
252+
build/pkgs/numpy/version_requirements.txt \
253+
build/pkgs/pkgconfig/version_requirements.txt \
254+
build/pkgs/pplpy/version_requirements.txt \
255+
build/pkgs/setuptools/version_requirements.txt \
256+
build/pkgs/wheel/version_requirements.txt
237257

238258
# Update version
239259
echo "$NEWCONFVERSION" >$PKG/package-version.txt

build/bin/sage-get-system-packages

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,25 @@ fi
1414

1515
case "$SYSTEM" in
1616
install-requires)
17-
# Collect version_requirements.txt (falling back to requirements.txt) and output it in the format
17+
# Collect from src/pyproject.toml or from version_requirements.txt (falling back to requirements.txt) and output it in the format
1818
# needed by setup.cfg [options] version_requirements=
1919
SYSTEM_PACKAGES_FILE_NAMES="version_requirements.txt requirements.txt"
2020
STRIP_COMMENTS="sed s/#.*//;/^[[:space:]]*$/d;"
21+
FROM_PYPROJECT_TOML=1
2122
COLLECT=
2223
;;
2324
install-requires-toml)
24-
# Collect version_requirements.txt (falling back to requirements.txt) and output it in the format
25+
# Collect from src/pyproject.toml or from version_requirements.txt (falling back to requirements.txt) and output it in the format
2526
# needed by pyproject.toml [build-system] requires=
2627
SYSTEM_PACKAGES_FILE_NAMES="version_requirements.txt requirements.txt"
2728
STRIP_COMMENTS="sed s/#.*//;/^[[:space:]]*$/d;s/^/'/;s/$/',/;"
29+
FROM_PYPROJECT_TOML=1
2830
COLLECT=
2931
;;
3032
pip)
3133
SYSTEM_PACKAGES_FILE_NAMES="requirements.txt version_requirements.txt"
3234
STRIP_COMMENTS='sed s/#.*//;s/[[:space:]]//g;'
35+
FROM_PYPROJECT_TOML=1
3336
COLLECT=echo
3437
;;
3538
*)
@@ -42,11 +45,24 @@ case "$SYSTEM" in
4245
fi
4346
SYSTEM_PACKAGES_FILE_NAMES="distros/$SYSTEM.txt"
4447
STRIP_COMMENTS="sed s/#.*//;s/\${PYTHON_MINOR}/${PYTHON_MINOR}/g"
48+
FROM_PYPROJECT_TOML=0
4549
COLLECT=echo
4650
;;
4751
esac
48-
for PKG_BASE in $SPKGS; do
4952

53+
for PKG_BASE in $SPKGS; do
54+
if [ $FROM_PYPROJECT_TOML -eq 1 ]; then
55+
if [ -f "$SAGE_ROOT/src/pyproject.toml" ]; then
56+
# Extract from the "requires" block in src/pyproject.toml
57+
# Packages are in the format "'sage-conf ~= 10.3b3',"
58+
PACKAGE_INFO=$(sed -n '/requires *= *\[/,/^\]/s/^ *'\''\('$PKG_BASE'.*\)'\'',/\1/p' "$SAGE_ROOT/src/pyproject.toml")
59+
if [ -n "$PACKAGE_INFO" ]; then
60+
echo "$PACKAGE_INFO" | ${STRIP_COMMENTS}
61+
continue
62+
fi
63+
fi
64+
fi
65+
5066
case "$SYSTEM:$ENABLE_SYSTEM_SITE_PACKAGES" in
5167
install-requires*|pip*)
5268
# This is output for installation of packages into a Python environment.
@@ -73,12 +89,12 @@ for PKG_BASE in $SPKGS; do
7389
for NAME in $SYSTEM_PACKAGES_FILE_NAMES; do
7490
SYSTEM_PACKAGES_FILE="$SAGE_ROOT"/build/pkgs/$PKG_BASE/$NAME
7591
if [ -f $SYSTEM_PACKAGES_FILE ]; then
76-
if [ -z "$COLLECT" ]; then
77-
${STRIP_COMMENTS} $SYSTEM_PACKAGES_FILE
78-
else
79-
$COLLECT $(${STRIP_COMMENTS} $SYSTEM_PACKAGES_FILE)
80-
fi
81-
break
92+
if [ -z "$COLLECT" ]; then
93+
${STRIP_COMMENTS} $SYSTEM_PACKAGES_FILE
94+
else
95+
$COLLECT $(${STRIP_COMMENTS} $SYSTEM_PACKAGES_FILE)
96+
fi
97+
break
8298
fi
8399
done
84100
done

build/pkgs/cypari/version_requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

build/pkgs/cysignals/version_requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

build/pkgs/cython/version_requirements.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

build/pkgs/gmpy2/version_requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

build/pkgs/jupyter_core/version_requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

build/pkgs/memory_allocator/version_requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)