Skip to content
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
36 changes: 20 additions & 16 deletions build/bin/sage-dist-helpers
Original file line number Diff line number Diff line change
Expand Up @@ -205,25 +205,16 @@ 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_pip_install() {
echo "Installing $PKG_NAME"
sdh_build_wheel() {
mkdir -p dist
rm -f dist/*.whl
export PIP_NO_INDEX=1
install_options=""
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
Expand All @@ -243,6 +234,9 @@ sdh_pip_install() {
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"
;;
Expand All @@ -258,20 +252,20 @@ sdh_pip_install() {
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
*--no-isolation*)
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 [email protected], including the build log of this package."
else
sdh_die "Error building a wheel for $PKG_NAME"
Expand All @@ -282,6 +276,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 .
}

Expand Down
9 changes: 0 additions & 9 deletions build/pkgs/sage_conf/spkg-install.in

This file was deleted.

1 change: 1 addition & 0 deletions build/pkgs/sage_conf/spkg-install.in
9 changes: 0 additions & 9 deletions build/pkgs/sage_docbuild/spkg-install.in

This file was deleted.

1 change: 1 addition & 0 deletions build/pkgs/sage_docbuild/spkg-install.in
2 changes: 1 addition & 1 deletion build/pkgs/sage_setup/spkg-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
9 changes: 0 additions & 9 deletions build/pkgs/sage_sws2rst/spkg-install.in

This file was deleted.

1 change: 1 addition & 0 deletions build/pkgs/sage_sws2rst/spkg-install.in
2 changes: 1 addition & 1 deletion build/pkgs/sagelib/spkg-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions build/pkgs/sagemath_objects/spkg-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
8 changes: 0 additions & 8 deletions src/doc/en/developer/packaging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down