Skip to content

Commit

Permalink
BLD: update requirements to use cython>3.0 (numpy#24236)
Browse files Browse the repository at this point in the history
Cython3.0 has been released. Let's update to use it everywhere.

Signed-off-by: Matti Picus <[email protected]>
  • Loading branch information
mattip authored Jul 24, 2023
1 parent b1c0fbf commit 81ac863
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 47 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,12 @@ jobs:
python-version: ${{ env.PYTHON_VERSION }}
- uses: ./.github/actions

debug_and_cython3:
debug:
needs: [smoke_test]
runs-on: ubuntu-latest
if: github.event_name != 'push'
env:
USE_DEBUG: 1
USE_CYTHON3: 1
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
Expand Down Expand Up @@ -343,11 +342,10 @@ jobs:
sudo apt update
sudo apt install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf gfortran-arm-linux-gnueabihf
# Keep the `test_requirements.txt` dependency-subset synced
docker run --name the_container --interactive -v /:/host arm32v7/ubuntu:22.04 /bin/bash -c "
docker run --name the_container --interactive -v /:/host -v $(pwd):/numpy arm32v7/ubuntu:22.04 /bin/bash -c "
apt update &&
apt install -y git python3 python3-dev python3-pip &&
python3 -m pip install cython==0.29.34 setuptools\<49.2.0 hypothesis==6.23.3 pytest==6.2.5 'typing_extensions>=4.2.0' &&
python3 -m pip install -r /numpy/test_requirements.txt
ln -s /host/lib64 /lib64 &&
ln -s /host/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu &&
ln -s /host/usr/arm-linux-gnueabihf /usr/arm-linux-gnueabihf &&
Expand Down
2 changes: 1 addition & 1 deletion INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Building NumPy requires the following installed software:
e.g., on Debian/Ubuntu one needs to install both `python3` and
`python3-dev`. On Windows and macOS this is normally not an issue.

2) Cython >= 0.29.30 but < 3.0
2) Cython >= 0.29.35

3) pytest__ (optional)

Expand Down
2 changes: 1 addition & 1 deletion build_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
meson-python>=0.10.0
Cython>=0.29.34,<3.0
Cython
wheel==0.38.1
ninja
spin==0.4
6 changes: 3 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ channels:
- conda-forge
dependencies:
- python=3.9 #need to pin to avoid issues with builds
- cython>=0.29.30
- cython>=3.0
- compilers
- openblas
- nomkl
- setuptools=59.2.0
- meson >= 0.64.0
- ninja
- pkg-config
- meson-python
- pip # so you can use pip to install spin
- pip
- spin
# For testing
- pytest
- pytest-cov
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build-system]
build-backend = "mesonpy"
requires = [
"Cython>=0.29.34",
"Cython>=3.0",
"meson-python>=0.13.1",
]

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml.setuppy
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
requires = [
"setuptools==59.2.0",
"wheel==0.38.1",
"Cython>=0.29.34,<3.0",
"Cython>=0.29.34,<3.1",
]
2 changes: 1 addition & 1 deletion test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cython>=0.29.34,<3.0
Cython
wheel==0.38.1
setuptools==59.2.0 ; python_version < '3.12'
setuptools ; python_version >= '3.12'
Expand Down
22 changes: 1 addition & 21 deletions tools/travis-before-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,11 @@ gcc --version

popd

pip install --upgrade pip 'setuptools<49.2.0' wheel

# 'setuptools', 'wheel' and 'cython' are build dependencies. This information
# is stored in pyproject.toml, but there is not yet a standard way to install
# those dependencies with, say, a pip command, so we'll just hard-code their
# installation here. We only need to install them separately for the cases
# where numpy is installed with setup.py, which is the case for the Travis jobs
# where the environment variables USE_DEBUG or USE_WHEEL are set. When pip is
# used to install numpy, pip gets the build dependencies from pyproject.toml.
# A specific version of cython is required, so we read the cython package
# requirement using `grep cython test_requirements.txt` instead of simply
# writing 'pip install setuptools wheel cython'.
if [ -n "$USE_CYTHON3" ]
then
pip install --pre --force-reinstall cython
else
pip install `grep cython test_requirements.txt`
fi

if [ -n "$DOWNLOAD_OPENBLAS" ]; then
pwd
target=$(python tools/openblas_support.py)
sudo cp -r $target/lib/* /usr/lib
sudo cp $target/include/* /usr/include
fi


if [ -n "$USE_ASV" ]; then pip install asv; fi

22 changes: 9 additions & 13 deletions tools/travis-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ fi

source builds/venv/bin/activate

pip install --upgrade pip 'setuptools<49.2.0'

pip install -r build_requirements.txt

if [ -n "$USE_ASV" ]; then pip install asv; fi
# travis venv tests override python
PYTHON=${PYTHON:-python}
PIP=${PIP:-pip}
Expand All @@ -35,7 +40,8 @@ setup_base()
# use default python flags but remove sign-compare
sysflags="$($PYTHON -c "import sysconfig; \
print (sysconfig.get_config_var('CFLAGS'))")"
export CFLAGS="$sysflags $werrors -Wlogical-op -Wno-sign-compare"
# For cython3.0 add -Wno-error=undef, see cython/cython#5557
export CFLAGS="$sysflags $werrors -Wlogical-op -Wno-sign-compare -Wno-error=undef"

build_args=()
# Strictly disable all kinds of optimizations
Expand All @@ -54,13 +60,6 @@ setup_base()
build_args+=("--simd-test=\$werror BASELINE SSE2 SSE42 XOP FMA4 (FMA3 AVX2) AVX512F AVX512_SKX VSX VSX2 VSX3 NEON ASIMD VX VXE VXE2")
fi
if [ -z "$USE_DEBUG" ]; then
# activates '-Werror=undef' when DEBUG isn't enabled since _cffi_backend'
# extension breaks the build due to the following error:
#
# error: "HAVE_FFI_PREP_CIF_VAR" is not defined, evaluates to 0 [-Werror=undef]
# #if !HAVE_FFI_PREP_CIF_VAR && defined(__arm64__) && defined(__APPLE__)
#
export CFLAGS="$CFLAGS -Werror=undef"
$PYTHON setup.py build "${build_args[@]}" install 2>&1 | tee log
else
# The job run with USE_DEBUG=1 on travis needs this.
Expand Down Expand Up @@ -90,9 +89,6 @@ run_test()
# file does not install correctly when Python's optimization level is set
# to strip docstrings (see https://github.com/eliben/pycparser/issues/291).
PYTHONOPTIMIZE="" $PIP install -r test_requirements.txt pyinstaller
if [ -n "$USE_CYTHON3" ] ; then
$PIP install --pre --force-reinstall cython
fi
DURATIONS_FLAG="--durations 10"

if [ -n "$USE_DEBUG" ]; then
Expand Down Expand Up @@ -202,7 +198,7 @@ export PIP

if [ -n "$USE_WHEEL" ] && [ $# -eq 0 ]; then
# ensure some warnings are not issued
export CFLAGS=$CFLAGS" -Wno-sign-compare -Wno-unused-result"
export CFLAGS=$CFLAGS" -Wno-sign-compare -Wno-unused-result -Wno-error=undef"
# adjust gcc flags if C coverage requested
if [ -n "$RUN_COVERAGE" ]; then
export NPY_DISTUTILS_APPEND_FLAGS=1
Expand All @@ -226,7 +222,7 @@ elif [ -n "$USE_SDIST" ] && [ $# -eq 0 ]; then
# temporary workaround for sdist failures.
$PYTHON -c "import fcntl; fcntl.fcntl(1, fcntl.F_SETFL, 0)"
# ensure some warnings are not issued
export CFLAGS=$CFLAGS" -Wno-sign-compare -Wno-unused-result"
export CFLAGS=$CFLAGS" -Wno-sign-compare -Wno-unused-result -Wno-error=undef"
$PYTHON setup.py sdist
# Make another virtualenv to install into
$PYTHON -m venv venv-for-wheel
Expand Down

0 comments on commit 81ac863

Please sign in to comment.