Skip to content

Commit

Permalink
gh-36123: Upgrade numpy to 1.26.0, setuptools to 68.2.2
Browse files Browse the repository at this point in the history
    
<!-- ^^^^^
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 -->

NumPy 1.26 provides Python 3.12 support and Cython 3 compatibility.

1.26.0 was released 2023-09-16.

As NumPy has changed its build system from setuptools-pinned-to-an-
ancient-version to meson_python, we get rid of our ancient version of
`setuptools`. The SPKGs `setuptools` and `setuptools_wheel` now ship the
same (current) version.

- [x] Check portability run:
https://github.com/mkoeppe/sage/actions/runs/5959239800
- [ ] Check SAGE_FAT_BINARY

<!-- 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". -->
Resolves #34816
<!-- 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. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] 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
- Depends on #36112 (for the `meson_python` upgrades, merged here)
- Depends on #35404 (merged here as
part of above)
- Depends on #35810 (merged here as part of above)
- Depends on #36110 (merged here)
- Depends on #36263 (merged here)
- Depends on #36238 (merged here)
- Depends on #36255 (merged here)
<!-- 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: #36123
Reported by: Matthias Köppe
Reviewer(s):
  • Loading branch information
Release Manager committed Oct 4, 2023
2 parents fdf30fb + 2eb2250 commit 868fefa
Show file tree
Hide file tree
Showing 18 changed files with 49 additions and 154 deletions.
6 changes: 3 additions & 3 deletions build/pkgs/numpy/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tarball=numpy-VERSION.tar.gz
sha1=6c7f2278b4ddd113b30821e7e4d5f246dc3ee735
md5=8b2692a511a3795f3af8af2cd7566a15
cksum=3950457778
sha1=a3f9d79d7852f5d35ff35693fc31d17ea270d2d0
md5=69bd28f07afbeed2bb6ecd467afcd469
cksum=3599108965
upstream_url=https://pypi.io/packages/source/n/numpy/numpy-VERSION.tar.gz
2 changes: 1 addition & 1 deletion build/pkgs/numpy/dependencies
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$(BLAS) gfortran | $(PYTHON_TOOLCHAIN) pkgconfig cython $(PYTHON)
$(BLAS) gfortran | $(PYTHON_TOOLCHAIN) pkgconfig cython meson_python $(PYTHON)

----------
All lines of this file are ignored except the first.
37 changes: 0 additions & 37 deletions build/pkgs/numpy/lapack_conf.py

This file was deleted.

2 changes: 1 addition & 1 deletion build/pkgs/numpy/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.23.5
1.26.0
31 changes: 0 additions & 31 deletions build/pkgs/numpy/patches/21891.patch

This file was deleted.

12 changes: 0 additions & 12 deletions build/pkgs/numpy/patches/cython3-legacy.patch

This file was deleted.

60 changes: 18 additions & 42 deletions build/pkgs/numpy/spkg-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,33 @@ cd src

set -e

if [ `uname` = "Darwin" ]; then
unset ATLAS
unset BLAS
unset LAPACK
# https://github.com/sagemath/sage/issues/34110#comment:35
# The fix for "reciprocal" (affected by a clang compiler bug) in
# https://github.com/numpy/numpy/pull/19926 relies on -ftrapping-math
# being used when Apple clang v12+ is used.
# But numpy.distutils.ccompiler only sets this flag when
# $CC contains the string "clang" -- missing the case CC=/usr/bin/gcc.
# So we set it here explicitly if the compiler supports the flag.
export CFLAGS="$(testcflags.sh $CFLAGS -ftrapping-math)"
else
export {ATLAS,PTATLAS,OPENBLAS,MKL,MKLROOT}=None
export LDFLAGS="${LDFLAGS} -shared"
fi
# https://github.com/scipy/scipy/issues/16536 - meson breaks when CXX="g++ -std=gnu++11"
# -- this also affects numpy
export CXX=$(echo "$CXX" | sed 's/-std=[a-z0-9+]*//g')

if [ "$UNAME" = "CYGWIN" ]; then
# Trac #30643
export CPPFLAGS="${CPPFLAGS} -D_GNU_SOURCE"
fi

# Trac #32746: pkg-config omits -I and -L flags that refer to directories
# that are already on CPATH, LIBRARY_PATH.
# But our script tries to obtain the list of include_dirs and library_dirs
# from pkg-config!
(unset CPATH LIBRARY_PATH; python3 ../lapack_conf.py)

# Make sure that the fortran objects are compiled with -fPIC
export FFLAGS="$FFLAGS -fPIC"
export FCFLAGS="$FCFLAGS -fPIC"

if [ "$SAGE_FAT_BINARY" = "yes" ]; then
export NUMPY_FCONFIG="--cpu-baseline=NONE"
else
export NUMPY_FCONFIG=""
fi

# Trac #32423: Fix 32-bit builds on x86_64
ARCH=$($CC -dumpmachine 2>/dev/null || echo unknown)
case "$ARCH" in
*x86_64*)
;;
*)
export NPY_DISABLE_SVML=1
;;
esac

################################################

# Trac #33138: numpy is a PEP 517 package, so the crucial "--build-option"s would be ignored.
eval sdh_pip_install --no-use-pep517 \
$(eval sdh_prefix_args "--build-option" build ${NUMPY_CONFIG} ${NUMPY_FCONFIG}) \
.
### Per https://github.com/numpy/numpy/releases/tag/v1.26.0b1
### "NumPy-specific build customization":
###
### The NPY_* environment variables which control BLAS/LAPACK, SIMD,
### threading, and other such options are no longer supported, nor is
### a site.cfg file to select BLAS and LAPACK. Instead, there are
### command-line flags that can be passed to the build via pip/build's
### config-settings interface. These flags are all listed in
### https://github.com/numpy/numpy/blob/main/meson_options.txt
###
### 1.26.0b1 temporarily vendors Meson and meson-python
### http://scipy.github.io/devdocs/building/index.html


sdh_pip_install .
6 changes: 3 additions & 3 deletions build/pkgs/pip/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tarball=pip-VERSION.tar.gz
sha1=29167fffe19874a74247fe92f4fdba1bb1221c61
md5=996f58a94fe0b8b82b6795c42bd171ba
cksum=537001443
sha1=4bdfd8e976b5122cf55f4f4740f7305f1ffa4310
md5=e9b1226701a56ee3fcc81aba60d25d75
cksum=1940746834
upstream_url=https://pypi.io/packages/source/p/pip/pip-VERSION.tar.gz
2 changes: 1 addition & 1 deletion build/pkgs/pip/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22.3.1
23.2.1
7 changes: 0 additions & 7 deletions build/pkgs/setuptools/SPKG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ Description
setuptools is the classical build system for Python packages,
a collection of enhancements to the Python distutils.

This package represents version 63.x of ``setuptools``.
Sage installs this version to provide the build system
for non-PEP 517 packages. In particular, Sage uses it
for building ``numpy``, whose build system ``numpy.distutils``
is not compatible with newer versions of ``setuptools``,
see https://github.com/numpy/numpy/pull/22154

License
-------

Expand Down
6 changes: 3 additions & 3 deletions build/pkgs/setuptools/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tarball=setuptools-VERSION.tar.gz
sha1=b14b8e2cf965fdb6870ebfccee50c751c056f757
md5=02a0e4dc4fa13168904e8769a077aa26
cksum=2734084418
sha1=b0c9b16863c57d70adc22651906eea7eaee09803
md5=d967ca2ba7f46db887daee2d5c9bd6a2
cksum=2346145273
upstream_url=https://pypi.io/packages/source/s/setuptools/setuptools-VERSION.tar.gz
4 changes: 3 additions & 1 deletion build/pkgs/setuptools/install-requires.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
setuptools >=49.6.0, <64
# 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
2 changes: 1 addition & 1 deletion build/pkgs/setuptools/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
63.4.3
68.2.2
3 changes: 0 additions & 3 deletions build/pkgs/setuptools_wheel/SPKG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ setuptools_wheel: Build the setuptools package as a wheel

After installing setuptools and wheel, we build a wheel of setuptools
to complete the set of wheels stored in our wheelhouse.

This version of setuptools is suitable for PEP 517/518/660 builds,
but it is not suitable for building ``numpy``.
5 changes: 0 additions & 5 deletions build/pkgs/setuptools_wheel/checksums.ini

This file was deleted.

1 change: 1 addition & 0 deletions build/pkgs/setuptools_wheel/checksums.ini
1 change: 0 additions & 1 deletion build/pkgs/setuptools_wheel/install-requires.txt

This file was deleted.

1 change: 1 addition & 0 deletions build/pkgs/setuptools_wheel/install-requires.txt
1 change: 0 additions & 1 deletion build/pkgs/setuptools_wheel/package-version.txt

This file was deleted.

1 change: 1 addition & 0 deletions build/pkgs/setuptools_wheel/package-version.txt
13 changes: 12 additions & 1 deletion src/sage/repl/ipython_kernel/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@
# ***************************************************************************

import sys
from ipykernel.ipkernel import IPythonKernel
import warnings
with warnings.catch_warnings():
# When upstream pydevd (as opposed to the bundled version) is used
# with debugpy, a PEP 420 warning is emitted. Debugpy and/or
# pydevd will eventually work around this, but as of September
# 2023, hiding the warning gives us more flexibility in the
# versions of those packages that we can accept.
warnings.filterwarnings("ignore",
message=r".*pkg_resources\.declare_namespace",
category=DeprecationWarning)
from ipykernel.ipkernel import IPythonKernel

from ipykernel.zmqshell import ZMQInteractiveShell
from traitlets import Type

Expand Down

0 comments on commit 868fefa

Please sign in to comment.