From cb5f1b927f99c135a73fe774bb1d64615e1cc122 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 9 May 2024 20:38:04 -0700 Subject: [PATCH 1/6] build/bin/sage-dist-helpers (sdh_build_wheel): Split out from sdh_pip_install --- build/bin/sage-dist-helpers | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/build/bin/sage-dist-helpers b/build/bin/sage-dist-helpers index d55ac539837..f7c91bde629 100644 --- a/build/bin/sage-dist-helpers +++ b/build/bin/sage-dist-helpers @@ -215,8 +215,7 @@ sdh_setup_bdist_wheel() { "$@" || sdh_die "Error building a wheel for $PKG_NAME" } -sdh_pip_install() { - echo "Installing $PKG_NAME" +sdh_build_wheel() { mkdir -p dist rm -f dist/*.whl export PIP_NO_INDEX=1 @@ -282,6 +281,16 @@ sdh_pip_install() { unset PIP_FIND_LINKS unset PIP_NO_BINARY unset PIP_NO_INDEX +} + +sdh_build_and_store_wheel() { + sdh_build_wheel "$@" + sdh_store_wheel . +} + +sdh_pip_install() { + echo "Installing $PKG_NAME" + sdh_build_wheel "$@" sdh_store_and_pip_install_wheel $install_options . } From 03d0a0156d2ebcb7c1c76ff8bd98bdb7d58dbc91 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 11 Jun 2024 18:40:33 -0700 Subject: [PATCH 2/6] build/bin/sage-dist-helpers (sdh_build_wheel): New option --sdist-then-wheel --- build/bin/sage-dist-helpers | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/build/bin/sage-dist-helpers b/build/bin/sage-dist-helpers index f7c91bde629..26971f2f7b5 100644 --- a/build/bin/sage-dist-helpers +++ b/build/bin/sage-dist-helpers @@ -223,6 +223,8 @@ sdh_build_wheel() { build_options="" # pip has --no-build-isolation but no flag that turns the default back on... build_isolation_option="" + # build has --wheel but no flag that turns the default (build sdist and then wheel) back on + dist_option="--wheel" export PIP_FIND_LINKS="$SAGE_SPKG_WHEELS" unset PIP_NO_BINARY while [ $# -gt 0 ]; do @@ -242,6 +244,9 @@ sdh_build_wheel() { export PIP_NO_BINARY=:all: build_isolation_option="--no-isolation --skip-dependency-check" ;; + --sdist-then-wheel) + dist_option="" + ;; --no-deps) install_options="$install_options $1" ;; @@ -257,7 +262,7 @@ sdh_build_wheel() { esac shift done - if python3 -m build --wheel --outdir=dist $build_isolation_option $build_options "$@"; then + if python3 -m build $dist_option --outdir=dist $build_isolation_option $build_options "$@"; then : # successful else case $build_isolation_option in @@ -265,12 +270,12 @@ sdh_build_wheel() { sdh_die "Error building a wheel for $PKG_NAME" ;; *) - echo >&2 "Warning: building with \"python3 -m build --wheel --outdir=dist $build_isolation_option $build_options $@\" failed." + echo >&2 "Warning: building with \"python3 -m build $dist_option --outdir=dist $build_isolation_option $build_options $@\" failed." unset PIP_FIND_LINKS export PIP_NO_BINARY=:all: build_isolation_option="--no-isolation --skip-dependency-check" - echo >&2 "Retrying with \"python3 -m build --wheel --outdir=dist $build_isolation_option $build_options $@\"." - if python3 -m build --wheel --outdir=dist $build_isolation_option $build_options "$@"; then + echo >&2 "Retrying with \"python3 -m build $dist_option --outdir=dist $build_isolation_option $build_options $@\"." + if python3 -m build $dist_option --outdir=dist $build_isolation_option $build_options "$@"; then echo >&2 "Warning: Wheel building needed to use \"$build_isolation_option\" to succeed. This means that a dependencies file in build/pkgs/ needs to be updated. Please report this to sage-devel@googlegroups.com, including the build log of this package." else sdh_die "Error building a wheel for $PKG_NAME" From acf10831adaa9d5b1454c9b8a64f5c672336a6e2 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 11 Jun 2024 18:43:02 -0700 Subject: [PATCH 3/6] build/pkgs/sagemath_objects/spkg-install.in: Use sdh_build_and_store_wheel --sdist-then-wheel --- build/pkgs/sagemath_objects/spkg-install.in | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/build/pkgs/sagemath_objects/spkg-install.in b/build/pkgs/sagemath_objects/spkg-install.in index 62cb1b73b22..53c094fde04 100644 --- a/build/pkgs/sagemath_objects/spkg-install.in +++ b/build/pkgs/sagemath_objects/spkg-install.in @@ -7,8 +7,4 @@ export PIP_FIND_LINKS="file://$SAGE_SPKG_WHEELS" # https://pypa-build.readthedocs.io/en/latest/#python--m-build # (Important because sagemath-objects uses MANIFEST.in for filtering.) # Do not install the wheel. -DIST_DIR="$(mktemp -d)" -python3 -m build --outdir "$DIST_DIR"/dist . || sdh_die "Failure building sdist and wheel" - -wheel=$(cd "$DIST_DIR" && sdh_store_wheel . >&2 && echo $wheel) -ls -l "$wheel" +sdh_build_and_store_wheel --sdist-then-wheel . From 8a6e2b0be61d8f89943fb24dcc92a5937f262ad2 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 11 Jun 2024 18:56:30 -0700 Subject: [PATCH 4/6] build/pkgs/{sage_conf,sage_docbuild,sage_setup,sage_sws2rst}/spkg-install.in: Use sdh_build_and_store_wheel --- build/pkgs/sage_conf/spkg-install.in | 10 +--------- build/pkgs/sage_docbuild/spkg-install.in | 10 +--------- build/pkgs/sage_setup/spkg-install.in | 2 +- build/pkgs/sage_sws2rst/spkg-install.in | 10 +--------- 4 files changed, 4 insertions(+), 28 deletions(-) mode change 100644 => 120000 build/pkgs/sage_conf/spkg-install.in mode change 100644 => 120000 build/pkgs/sage_docbuild/spkg-install.in mode change 100644 => 120000 build/pkgs/sage_sws2rst/spkg-install.in diff --git a/build/pkgs/sage_conf/spkg-install.in b/build/pkgs/sage_conf/spkg-install.in deleted file mode 100644 index 4479c541b1c..00000000000 --- a/build/pkgs/sage_conf/spkg-install.in +++ /dev/null @@ -1,9 +0,0 @@ -cd src -if [ "$SAGE_EDITABLE" = yes ]; then - sdh_pip_editable_install . - if [ "$SAGE_WHEELS" = yes ]; then - sdh_setup_bdist_wheel && sdh_store_wheel . - fi -else - sdh_pip_install . -fi diff --git a/build/pkgs/sage_conf/spkg-install.in b/build/pkgs/sage_conf/spkg-install.in new file mode 120000 index 00000000000..428e161a850 --- /dev/null +++ b/build/pkgs/sage_conf/spkg-install.in @@ -0,0 +1 @@ +../sage_setup/spkg-install.in \ No newline at end of file diff --git a/build/pkgs/sage_docbuild/spkg-install.in b/build/pkgs/sage_docbuild/spkg-install.in deleted file mode 100644 index 4479c541b1c..00000000000 --- a/build/pkgs/sage_docbuild/spkg-install.in +++ /dev/null @@ -1,9 +0,0 @@ -cd src -if [ "$SAGE_EDITABLE" = yes ]; then - sdh_pip_editable_install . - if [ "$SAGE_WHEELS" = yes ]; then - sdh_setup_bdist_wheel && sdh_store_wheel . - fi -else - sdh_pip_install . -fi diff --git a/build/pkgs/sage_docbuild/spkg-install.in b/build/pkgs/sage_docbuild/spkg-install.in new file mode 120000 index 00000000000..428e161a850 --- /dev/null +++ b/build/pkgs/sage_docbuild/spkg-install.in @@ -0,0 +1 @@ +../sage_setup/spkg-install.in \ No newline at end of file diff --git a/build/pkgs/sage_setup/spkg-install.in b/build/pkgs/sage_setup/spkg-install.in index 4479c541b1c..da7d7a2870f 100644 --- a/build/pkgs/sage_setup/spkg-install.in +++ b/build/pkgs/sage_setup/spkg-install.in @@ -2,7 +2,7 @@ cd src if [ "$SAGE_EDITABLE" = yes ]; then sdh_pip_editable_install . if [ "$SAGE_WHEELS" = yes ]; then - sdh_setup_bdist_wheel && sdh_store_wheel . + sdh_build_and_store_wheel --no-isolation . fi else sdh_pip_install . diff --git a/build/pkgs/sage_sws2rst/spkg-install.in b/build/pkgs/sage_sws2rst/spkg-install.in deleted file mode 100644 index 4479c541b1c..00000000000 --- a/build/pkgs/sage_sws2rst/spkg-install.in +++ /dev/null @@ -1,9 +0,0 @@ -cd src -if [ "$SAGE_EDITABLE" = yes ]; then - sdh_pip_editable_install . - if [ "$SAGE_WHEELS" = yes ]; then - sdh_setup_bdist_wheel && sdh_store_wheel . - fi -else - sdh_pip_install . -fi diff --git a/build/pkgs/sage_sws2rst/spkg-install.in b/build/pkgs/sage_sws2rst/spkg-install.in new file mode 120000 index 00000000000..428e161a850 --- /dev/null +++ b/build/pkgs/sage_sws2rst/spkg-install.in @@ -0,0 +1 @@ +../sage_setup/spkg-install.in \ No newline at end of file From 0b2033c31dd289c6259af09a1c401b85d14f8b35 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 11 Jun 2024 18:58:42 -0700 Subject: [PATCH 5/6] build/pkgs/sagelib/spkg-install.in: Use sdh_build_and_store_wheel --- build/pkgs/sagelib/spkg-install.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pkgs/sagelib/spkg-install.in b/build/pkgs/sagelib/spkg-install.in index e085d2884fb..ff883b5fcb2 100644 --- a/build/pkgs/sagelib/spkg-install.in +++ b/build/pkgs/sagelib/spkg-install.in @@ -53,7 +53,7 @@ if [ "$SAGE_EDITABLE" = yes ]; then if [ "$SAGE_WHEELS" = yes ]; then # Additionally build a wheel (for use in other venvs) - cd $SAGE_PKGS/sagelib/src && time sdh_setup_bdist_wheel && sdh_store_wheel . + cd $SAGE_PKGS/sagelib/src && time sdh_build_and_store_wheel --no-build-isolation . fi else # Now implied: "$SAGE_WHEELS" = yes From 0878cc26feee3205511f7a85e10c6e784a2fc2f4 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 11 Jun 2024 19:01:25 -0700 Subject: [PATCH 6/6] build/bin/sage-dist-helpers (sdh_setup_bdist_wheel): Remove --- build/bin/sage-dist-helpers | 10 ---------- src/doc/en/developer/packaging.rst | 8 -------- 2 files changed, 18 deletions(-) diff --git a/build/bin/sage-dist-helpers b/build/bin/sage-dist-helpers index 26971f2f7b5..520b6ceec5a 100644 --- a/build/bin/sage-dist-helpers +++ b/build/bin/sage-dist-helpers @@ -205,16 +205,6 @@ sdh_make_install() { sdh_die "Error installing $PKG_NAME" } -sdh_setup_bdist_wheel() { - # Issue #32046: Most uses of this function can be replaced by sdh_pip_install - mkdir -p dist - rm -f dist/*.whl - BDIST_DIR="$(mktemp -d)" - python3 setup.py --no-user-cfg \ - bdist_wheel --bdist-dir "$BDIST_DIR" \ - "$@" || sdh_die "Error building a wheel for $PKG_NAME" -} - sdh_build_wheel() { mkdir -p dist rm -f dist/*.whl diff --git a/src/doc/en/developer/packaging.rst b/src/doc/en/developer/packaging.rst index ae8416cd186..d59e5dc07e9 100644 --- a/src/doc/en/developer/packaging.rst +++ b/src/doc/en/developer/packaging.rst @@ -444,10 +444,6 @@ begin with ``sdh_``, which stands for "Sage-distribution helper". arguments. If ``$SAGE_DESTDIR`` is not set then the command is run with ``$SAGE_SUDO``, if set. -- ``sdh_setup_bdist_wheel [...]``: Runs ``setup.py bdist_wheel`` with - the given arguments, as well as additional default arguments used for - installing packages into Sage. - - ``sdh_pip_install [...]``: The equivalent of running ``pip install`` with the given arguments, as well as additional default arguments used for installing packages into Sage with pip. The last argument must be @@ -609,10 +605,6 @@ Where ``sdh_pip_install`` is a function provided by ``sage-dist-helpers`` that points to the correct ``pip`` for the Python used by Sage, and includes some default flags needed for correct installation into Sage. -If ``pip`` will not work for a package but a command like ``python3 setup.py install`` -will, you may use ``sdh_setup_bdist_wheel``, followed by -``sdh_store_and_pip_install_wheel .``. - For ``spkg-check.in`` script templates, use ``python3`` rather than just ``python``. The paths are set by the Sage build system so that this runs the correct version of Python.