Skip to content

Commit f384783

Browse files
author
Release Manager
committed
sagemathgh-35618: Use `pypa/build` instead of `pip wheel` <!-- Please provide a concise, informative and self-explanatory title. --> <!-- Don't put issue numbers in the title. Put it in the Description below. --> <!-- For example, instead of "Fixes sagemath#12345", use "Add a new method to multiply two integers" --> ### 📚 Description This is the next step of the long term effort to use the standard tools of modern Python packaging in the build system of the Sage distribution, enabled by making `python_build` a standard package. We add `python_build` to our `PYTHON_TOOLCHAIN` and replace the use of `pip wheel` by using `python -m build`. <!-- Describe your changes here in detail. --> <!-- 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 sagemath#12345". --> - Resolves sagemath#34590. - Also, we remove the unused helper function `sdh_prefix_args`. <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x ]`. --> - [x] The title is concise, informative, and self-explanatory. - [ ] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> - Depends on sagemath#37300 <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#35618 Reported by: Matthias Köppe Reviewer(s): Kwankyu Lee
2 parents c4363fc + c8799b1 commit f384783

File tree

9 files changed

+33
-38
lines changed

9 files changed

+33
-38
lines changed

build/bin/sage-dist-helpers

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@
6969
#
7070
# Runs `pip uninstall` with the given arguments. If unsuccessful, it displays a warning.
7171
#
72-
# - eval sdh_prefix_args PREFIX [...]
73-
#
74-
# Helper function for transforming build options so that they can be passed
75-
# through "pip".
76-
#
7772
# - sdh_cmake [...]
7873
#
7974
# Runs `cmake` in the current directory with the given arguments, as well as
@@ -220,42 +215,39 @@ sdh_setup_bdist_wheel() {
220215
"$@" || sdh_die "Error building a wheel for $PKG_NAME"
221216
}
222217

223-
sdh_prefix_args () {
224-
prefix="$1"
225-
shift
226-
while [ $# -gt 0 ]; do
227-
# Quoted quotes because the result is to be run through eval
228-
echo "$prefix" \"$1\"
229-
shift
230-
done
231-
}
232-
233218
sdh_pip_install() {
234219
echo "Installing $PKG_NAME"
235220
mkdir -p dist
236221
rm -f dist/*.whl
222+
export PIP_NO_INDEX=1
237223
install_options=""
238224
build_options=""
239225
# pip has --no-build-isolation but no flag that turns the default back on...
240-
build_isolation_option="--find-links=$SAGE_SPKG_WHEELS"
226+
build_isolation_option=""
227+
export PIP_FIND_LINKS="$SAGE_SPKG_WHEELS"
228+
unset PIP_NO_BINARY
241229
while [ $# -gt 0 ]; do
242230
case "$1" in
243231
--build-isolation)
244232
# Our default after #33789 (Sage 9.7): We allow the package to provision
245233
# its build environment using the stored wheels.
246234
# We pass --find-links.
247235
# The SPKG needs to declare "setuptools" as a dependency.
248-
build_isolation_option="--find-links=$SAGE_SPKG_WHEELS"
236+
build_isolation_option=""
237+
export PIP_FIND_LINKS="$SAGE_SPKG_WHEELS"
238+
unset PIP_NO_BINARY
249239
;;
250240
--no-build-isolation)
251241
# Use --no-binary, so that no wheels from caches are used.
252-
build_isolation_option="--no-build-isolation --no-binary :all:"
242+
unset PIP_FIND_LINKS
243+
export PIP_NO_BINARY=:all:
244+
build_isolation_option="--no-isolation --skip-dependency-check"
253245
;;
254246
--no-deps)
255247
install_options="$install_options $1"
256248
;;
257249
-C|--config-settings)
258-
build_options="$build_options $1"
250+
build_options="$build_options --config-setting"
259251
shift
260252
build_options="$build_options $1"
261253
;;
@@ -265,25 +257,30 @@ sdh_pip_install() {
265257
esac
266258
shift
267259
done
268-
if python3 -m pip wheel --wheel-dir=dist --verbose --no-deps --no-index --isolated --ignore-requires-python $build_isolation_option $build_options "$@"; then
260+
if python3 -m build --wheel --outdir=dist $build_isolation_option $build_options "$@"; then
269261
: # successful
270262
else
271263
case $build_isolation_option in
272-
*--no-build-isolation*)
264+
*--no-isolation*)
273265
sdh_die "Error building a wheel for $PKG_NAME"
274266
;;
275267
*)
276-
echo >&2 "Warning: building with \"python3 -m pip wheel --wheel-dir=dist --verbose --no-deps --no-index --isolated --ignore-requires-python $build_isolation_option\" failed."
277-
build_isolation_option="--no-build-isolation --no-binary :all:"
278-
echo >&2 "Retrying with \"python3 -m pip wheel --wheel-dir=dist --verbose --no-deps --no-index --isolated --ignore-requires-python $build_isolation_option\"."
279-
if python3 -m pip wheel --wheel-dir=dist --verbose --no-deps --no-index --isolated --ignore-requires-python $build_isolation_option $build_options "$@"; then
268+
echo >&2 "Warning: building with \"python3 -m build --wheel --outdir=dist $build_isolation_option $build_options $@\" failed."
269+
unset PIP_FIND_LINKS
270+
export PIP_NO_BINARY=:all:
271+
build_isolation_option="--no-isolation --skip-dependency-check"
272+
echo >&2 "Retrying with \"python3 -m build --wheel --outdir=dist $build_isolation_option $build_options $@\"."
273+
if python3 -m build --wheel --outdir=dist $build_isolation_option $build_options "$@"; then
280274
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."
281275
else
282276
sdh_die "Error building a wheel for $PKG_NAME"
283277
fi
284278
;;
285279
esac
286280
fi
281+
unset PIP_FIND_LINKS
282+
unset PIP_NO_BINARY
283+
unset PIP_NO_INDEX
287284
sdh_store_and_pip_install_wheel $install_options .
288285
}
289286

build/make/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ all-toolchain: base-toolchain
324324

325325
# Shorthand for a list of packages sufficient for building and installing
326326
# typical Python packages from source. Wheel packages only need pip.
327-
PYTHON_TOOLCHAIN = setuptools pip setuptools_scm wheel flit_core hatchling
327+
PYTHON_TOOLCHAIN = setuptools pip setuptools_scm wheel flit_core hatchling python_build
328328

329329
# Issue #32056: Avoid installed setuptools leaking into the build of python3 by uninstalling it.
330330
# It will have to be reinstalled anyway because of its dependency on $(PYTHON).

build/pkgs/editables/checksums.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
tarball=editables-VERSION.tar.gz
2-
sha1=90efed858e78bf6276d1a5959ec6692e11a6bce9
3-
md5=520de8c3a9dc5dfb2b365d104541c9de
4-
cksum=3074203672
5-
upstream_url=https://pypi.io/packages/source/e/editables/editables-VERSION.tar.gz
1+
tarball=editables-VERSION-py3-none-any.whl
2+
sha1=7aa90de86b05d6dc1a04c219b01ca7eab09de113
3+
md5=5de129d3a039b26b7f6798a4002acdf6
4+
cksum=24000838
5+
upstream_url=https://pypi.io/packages/py3/e/editables/editables-VERSION-py3-none-any.whl

build/pkgs/editables/dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
| flit_core $(PYTHON)
1+
| pip $(PYTHON)
22

33
----------
44
All lines of this file are ignored except the first.

build/pkgs/editables/spkg-install.in

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
zipp typing_extensions | $(PYTHON_TOOLCHAIN) tomli $(PYTHON)
1+
zipp typing_extensions | pip tomli $(PYTHON)
22

33
----------
44
All lines of this file are ignored except the first.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
| $(PYTHON_TOOLCHAIN) $(PYTHON)
1+
| pip $(PYTHON)
22

33
----------
44
All lines of this file are ignored except the first.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tomli packaging pyproject_hooks importlib_metadata | $(PYTHON_TOOLCHAIN) $(PYTHON)
1+
tomli packaging pyproject_hooks importlib_metadata | pip $(PYTHON)
22

33
----------
44
All lines of this file are ignored except the first.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
| $(PYTHON_TOOLCHAIN) $(PYTHON)
1+
| pip $(PYTHON)
22

33
----------
44
All lines of this file are ignored except the first.

0 commit comments

Comments
 (0)