Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLD: switch to meson-python as the default build backend #23838

Merged
merged 30 commits into from Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e3cb66a
BLD: default to using meson-python as build backend
rgommers May 29, 2023
ea1bd89
CI: tweak CI for the change to meson-python as default build backend
rgommers May 29, 2023
f7c55aa
CI: drop 32-bit Windows Azure testing, adjust 64-bit for Meson
rgommers May 29, 2023
6c024e4
BLD: fix bug with CMake fallback detection of BLAS/LAPACK
rgommers May 29, 2023
4917ebf
CI: upgrade rtools to 4.3 to get a new enough GCC version in Azure
rgommers May 29, 2023
29dcb05
CI: keep the Emscripten/Pyodide job on a setup.py-based build
rgommers May 29, 2023
618181d
use MSVC and force 64-bit OpenBLAS interfaces
mattip Jun 11, 2023
9a80630
drop rtools in wheel builds, do -DDBLAS_SYMBOL_SUFFIX=64_ differently
mattip Jun 11, 2023
1462b62
typo, install pkg-config on windows
mattip Jun 11, 2023
bebbde7
set PKG_CONFIG_PATH for windows, add CXXFLAGS
mattip Jun 11, 2023
80e0d70
disable pypy builds, move PKG_CONFIG_PATH for windows
mattip Jun 11, 2023
89ffd57
fixes from review, try a -O0 build
mattip Jun 12, 2023
aef314b
BLD: handle license files inclusion in wheels correctly
rgommers Jun 12, 2023
34933ac
windows fixes, xfail test on manylinux2014
mattip Jun 13, 2023
aabacc7
fix PKG_CONFIG_PATH, force vsenv on windows builds, fix glibc version
mattip Jun 13, 2023
2e84e21
reuse parts of scipy's scripts for windows includding delvewheel; fix…
mattip Jun 13, 2023
fae400b
tweaks and xfail a failing test on windows
mattip Jun 13, 2023
1a02d5f
TST: Azure: avoid running tests from root of repo
rgommers Jun 18, 2023
15cfdec
TST: put back xfail for array-api entrypoint temporarily
rgommers Jun 18, 2023
a5ef06b
REL: don't build 32-bit Python wheels with cibuildwheel
rgommers Jun 18, 2023
7948464
TST: disable longdouble string/print tests on Linux aarch64
rgommers Jun 18, 2023
c808cfd
BLD: hack around broken long double size detection on 32-bit Linux
rgommers Jun 18, 2023
9d588cf
TST: fix deprecation warnings from f2py test for ndim>0
rgommers Jun 18, 2023
c41a1e2
TST: xfail einsum int8/uint8 test temporarily
rgommers Jun 18, 2023
515403f
TST: disable `test_new_policy` test for memory allocator.
rgommers Jun 18, 2023
910c686
CI: avoid use of pytest for 32-bit Linux Azure job; remove xml coverage
rgommers Jun 18, 2023
69f26cf
CI: fix ILP64 usage on macOS arm64 with cibuildwheel
rgommers Jun 18, 2023
302f244
CI: disable pypy3.9 job on Azure temporarily
rgommers Jun 18, 2023
11a3cef
BLD: on 32-bit Linux, if `sizeof(long double)` is 12, change format
rgommers Jun 18, 2023
e3ddda5
Merge remote-tracking branch 'upstream/main' into default-to-meson
rgommers Jun 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .circleci/config.yml
Expand Up @@ -61,7 +61,6 @@ jobs:
name: build numpy
command: |
. venv/bin/activate
pip install --progress-bar=off --upgrade pip 'setuptools<49.2.0'
pip install --progress-bar=off -r test_requirements.txt
pip install --progress-bar=off -r doc_requirements.txt
pip install .
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_test.yml
Expand Up @@ -436,7 +436,7 @@ jobs:
run: |
export CC=/usr/bin/gcc-12
export CXX=/usr/bin/g++-12
python -m pip install -e .
python setup.py develop
rgommers marked this conversation as resolved.
Show resolved Hide resolved
- name: Show config
run: |
python -c "import numpy as np; np.show_config()"
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/emscripten.yml
Expand Up @@ -55,7 +55,11 @@ jobs:
run: pip install pyodide-build==$PYODIDE_VERSION

- name: Build
run: CFLAGS=-g2 LDFLAGS=-g2 pyodide build
run: |
# Pyodide is still in the process of adding better/easier support for
# non-setup.py based builds.
cp pyproject.toml.setuppy pyproject.toml
CFLAGS=-g2 LDFLAGS=-g2 pyodide build

- name: set up node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
Expand Down
20 changes: 7 additions & 13 deletions .github/workflows/wheels.yml
Expand Up @@ -78,8 +78,8 @@ jobs:
- [ubuntu-20.04, musllinux_x86_64]
- [macos-12, macosx_x86_64]
- [windows-2019, win_amd64]
- [windows-2019, win32]
python: ["cp39", "cp310", "cp311", "pp39"]
python: ["cp39", "cp310", "cp311"]
# python: ["cp39", "cp310", "cp311", "pp39"]
exclude:
# Don't build PyPy 32-bit windows
- buildplat: [windows-2019, win32]
Expand All @@ -101,22 +101,16 @@ jobs:
# https://github.com/actions/checkout/issues/338
fetch-depth: 0

- name: pkg-config-for-win
run: |
choco install -y --checksum 6004DF17818F5A6DBF19CB335CC92702 pkgconfiglite
if: runner.os == 'windows'

# Used to push the built wheels
- uses: actions/setup-python@bd6b4b6205c4dbad673328db7b31b7fab9e241c0 # v4.6.1
with:
python-version: "3.x"

# We need rtools 4.0 to have 32 bit support on windows
- if: runner.os == 'windows'
uses: r-windows/install-rtools@ca1090c210479e995c03019a22b9798cdf57073a # main

- name: setup rtools for 32-bit
run: |
echo "PLAT=i686" >> $env:GITHUB_ENV
echo "PATH=c:\rtools40\mingw32\bin;$env:PATH" >> $env:GITHUB_ENV
gfortran --version
if: ${{ matrix.buildplat[1] == 'win32' }}

- name: Build wheels
uses: pypa/cibuildwheel@0ecddd92b62987d7a2ae8911f4bb8ec9e2e4496a # v2.13.1
env:
Expand Down
40 changes: 12 additions & 28 deletions azure-pipelines.yml
Expand Up @@ -114,16 +114,9 @@ stages:
python3 -m pip install -r test_requirements.txt && \
echo CFLAGS \$CFLAGS && \
python3 -m pip install -v . && \
python3 runtests.py -n --debug-info --mode=full -- -rsx --junitxml=junit/test-results.xml && \
python3 -m pip install threadpoolctl && \
python3 tools/openblas_support.py --check_version"
cd tools && \
python3 -m pytest --pyargs numpy"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has removed the check for the openblas version. Is that on purpose?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we now have proper logging in the build log for the version, and this cannot really be wrong (no other OpenBLAS version is installed in CI). This job was painful to debug, so I trimmed it down as much as possible.

displayName: 'Run 32-bit manylinux2014 Docker Build / Tests'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: '**/test-*.xml'
failTaskOnFailedTests: true
testRunTitle: 'Publish test results for Python 3.9-32 bit full Linux'


- job: macOS
Expand Down Expand Up @@ -249,36 +242,27 @@ stages:
pool:
vmImage: 'windows-2019'
strategy:
maxParallel: 5
maxParallel: 3
matrix:
Python39-32bit-full:
PYTHON_VERSION: '3.9'
PYTHON_ARCH: 'x86'
TEST_MODE: full
BITS: 32
Python310-64bit-fast:
PYTHON_VERSION: '3.10'
PYTHON_ARCH: 'x64'
TEST_MODE: fast
BITS: 64
Python311-32bit-fast:
PYTHON_VERSION: '3.11'
PYTHON_ARCH: 'x86'
TEST_MODE: fast
BITS: 32
Python311-64bit-full:
PYTHON_VERSION: '3.11'
PYTHON_ARCH: 'x64'
TEST_MODE: full
BITS: 64
NPY_USE_BLAS_ILP64: '1'

PyPy39-64bit-fast:
PYTHON_VERSION: 'pypy3.9'
PYTHON_ARCH: 'x64'
TEST_MODE: fast
BITS: 64
NPY_USE_BLAS_ILP64: '1'
# NPY_USE_BLAS_ILP64: '1'
# TODO: failing because of an issue with ILP64 BLAS being downloaded,
# and that not being handled automatically yet
# PyPy39-64bit-fast:
# PYTHON_VERSION: 'pypy3.9'
# PYTHON_ARCH: 'x64'
# TEST_MODE: fast
# BITS: 64
# NPY_USE_BLAS_ILP64: '1'

steps:
- template: azure-steps-windows.yml
Expand Down
72 changes: 31 additions & 41 deletions azure-steps-windows.yml
Expand Up @@ -14,49 +14,41 @@ steps:
displayName: 'Install dependencies; some are optional to avoid test skips'

- powershell: |
# rtools 42+ does not support 32 bits builds.
choco install --confirm --no-progress --allow-downgrade rtools --version=4.0.0.20220206
echo "##vso[task.setvariable variable=RTOOLS40_HOME]c:\rtools40"
displayName: 'Install rtools'
# Note that rtools 42+ does not support 32 bits builds. We dropped testing
# those, but if there's a need to go back on that, use version 4.0.0.20220206
choco install --confirm --no-progress --side-by-side rtools --version=4.3.5550
choco install unzip -y
choco install -y --checksum 6004DF17818F5A6DBF19CB335CC92702 pkgconfiglite
echo "##vso[task.setvariable variable=RTOOLS43_HOME]c:\rtools43"
displayName: 'Install utilities'

- powershell: |
$ErrorActionPreference = "Stop"
# Download and get the path to "openblas". We cannot copy it
# to $PYTHON_EXE's directory since that is on a different drive which
# mingw does not like. Instead copy it to a directory and set OPENBLAS,
# since OPENBLAS will be picked up by the openblas discovery
$target = $(python tools/openblas_support.py)
mkdir openblas
echo "Copying $target to openblas/"
cp -r $target/* openblas/
$env:OPENBLAS = $target
mkdir C:/opt/openblas/openblas_dll
mkdir C:/opt/32/lib/pkgconfig
mkdir C:/opt/64/lib/pkgconfig
# TBD: support 32 bit testing
$target=$(python -c "import tools.openblas_support as obs; plat=obs.get_plat(); ilp64=obs.get_ilp64(); target=f'openblas_{plat}.zip'; obs.download_openblas(target, plat, ilp64);print(target)")
unzip -o -d c:/opt/ $target
echo "##vso[task.setvariable variable=PKG_CONFIG_PATH]c:/opt/64/lib/pkgconfig"
copy C:/opt/64/bin/*.dll C:/opt/openblas/openblas_dll
displayName: 'Download / Install OpenBLAS'

# NOTE: for Windows builds it seems much more tractable to use runtests.py
# vs. manual setup.py and then runtests.py for testing only

- powershell: |
ls openblas
If ($(BITS) -eq 32) {
$env:CFLAGS = "-m32"
$env:LDFLAGS = "-m32"
$env:PATH = "$env:RTOOLS40_HOME\\mingw32\\bin;$env:PATH"
}
Else
{
$env:PATH = "$env:RTOOLS40_HOME\\mingw64\\bin;$env:PATH"
}
If ( Test-Path env:NPY_USE_BLAS_ILP64 ) {
$env:OPENBLAS64_ = "openblas"
$env:OPENBLAS64_="openblas"
# This does not work, the flags are passed together and not separately
$env:CFLAGS="-DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64"
$env:CXXFLAGS="-DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64"
} else {
$env:OPENBLAS = "openblas"
}
python -c "from tools import openblas_support; openblas_support.make_init('numpy')"
python -m pip wheel -v -v -v --no-build-isolation --no-use-pep517 --wheel-dir=dist .

ls dist -r | Foreach-Object {
python -m pip install $_.FullName
}
python -m pip install . --config-settings=setup-args="--vsenv"
# copy from c:/opt/openblas/openblas_dll to numpy/.libs
$target = $(python -c "import sysconfig; print(sysconfig.get_path('platlib'))")
mkdir $target/numpy/.libs
copy C:/opt/openblas/openblas_dll/*.dll $target/numpy/.libs
displayName: 'Build NumPy'

- script: |
Expand All @@ -65,16 +57,14 @@ steps:
displayName: 'Check OpenBLAS version'

- powershell: |
If ($(BITS) -eq 32) {
$env:CFLAGS = "-m32"
$env:LDFLAGS = "-m32"
$env:PATH = "$env:RTOOLS40_HOME\\mingw32\\bin;$env:PATH"
}
Else
{
$env:PATH = "$env:RTOOLS40_HOME\\mingw64\\bin;$env:PATH"
cd tools # avoid root dir to not pick up source tree
# Get a gfortran onto the path for f2py tests
$env:PATH = "$env:RTOOLS43_HOME\\x86_64-w64-mingw32.static.posix\\bin;$env:PATH"
If ( $env:TEST_MODE -eq "full" ) {
pytest --pyargs numpy -rsx --junitxml=junit/test-results.xml
} else {
pytest --pyargs numpy -m "not slow" -rsx --junitxml=junit/test-results.xml
}
python runtests.py -n --show-build-log --mode=$(TEST_MODE) -- -rsx --junitxml=junit/test-results.xml
displayName: 'Run NumPy Test Suite'

- task: PublishTestResults@2
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Expand Up @@ -4,7 +4,7 @@ project(
# Note that the git commit hash cannot be added dynamically here
# It is dynamically added upon import by versioneer
# See `numpy/__init__.py`
version: '1.24.0.dev0',
version: '2.0.0.dev0',
rgommers marked this conversation as resolved.
Show resolved Hide resolved
license: 'BSD-3',
meson_version: '>= 1.1.0',
default_options: [
Expand Down
3 changes: 3 additions & 0 deletions numpy/core/tests/test_arrayprint.py
@@ -1,3 +1,4 @@
import platform
import sys
import gc
from hypothesis import given
Expand Down Expand Up @@ -161,6 +162,8 @@ def test_fieldless_structured(self):


class TestComplexArray:
@pytest.mark.xfail(platform.machine() == 'aarch64',
reason="Failing on Meson build, see gh-23974")
def test_str(self):
rvals = [0, 1, -1, np.inf, -np.inf, np.nan]
cvals = [complex(rp, ip) for rp in rvals for ip in rvals]
Expand Down
6 changes: 6 additions & 0 deletions numpy/core/tests/test_einsum.py
@@ -1,4 +1,6 @@
import itertools
import sys
import platform

import pytest

Expand Down Expand Up @@ -609,9 +611,13 @@ def check_einsum_sums(self, dtype, do_opt=False):
[2.]) # contig_stride0_outstride0_two

def test_einsum_sums_int8(self):
if sys.platform == 'darwin' and platform.machine() == 'x86_64':
pytest.xfail('Fails on macOS x86-64 with Meson, see gh-23838')
self.check_einsum_sums('i1')

def test_einsum_sums_uint8(self):
if sys.platform == 'darwin' and platform.machine() == 'x86_64':
pytest.xfail('Fails on macOS x86-64 with Meson, see gh-23838')
self.check_einsum_sums('u1')

def test_einsum_sums_int16(self):
Expand Down
2 changes: 2 additions & 0 deletions numpy/core/tests/test_longdouble.py
Expand Up @@ -33,6 +33,8 @@ def test_scalar_extraction():
# +2 from macro block starting around line 842 in scalartypes.c.src.


@pytest.mark.xfail(platform.machine() == 'aarch64',
reason="Failing on Meson build, see gh-23974")
@pytest.mark.skipif(IS_MUSL,
reason="test flaky on musllinux")
@pytest.mark.skipif(LD_INFO.precision + 2 >= repr_precision,
Expand Down
7 changes: 4 additions & 3 deletions numpy/core/tests/test_mem_policy.py
Expand Up @@ -359,7 +359,7 @@ def test_thread_locality(get_module):
assert np.core.multiarray.get_handler_name() == orig_policy_name


@pytest.mark.slow
@pytest.mark.skip(reason="too slow, see gh-23975")
def test_new_policy(get_module):
a = np.arange(10)
orig_policy_name = np.core.multiarray.get_handler_name(a)
Expand All @@ -377,10 +377,11 @@ def test_new_policy(get_module):
#
# if needed, debug this by
# - running tests with -- -s (to not capture stdout/stderr
# - setting verbose=2
# - setting extra_argv=['-vv'] here
assert np.core.test('full', verbose=2, extra_argv=['-vv'])
assert np.core.test('full', verbose=1, extra_argv=[])
# also try the ma tests, the pickling test is quite tricky
assert np.ma.test('full', verbose=2, extra_argv=['-vv'])
assert np.ma.test('full', verbose=1, extra_argv=[])

get_module.set_old_policy(orig_policy)

Expand Down
20 changes: 14 additions & 6 deletions numpy/core/tests/test_print.py
@@ -1,4 +1,5 @@
import sys
import platform

import pytest

Expand All @@ -12,7 +13,14 @@
_REF = {np.inf: 'inf', -np.inf: '-inf', np.nan: 'nan'}


@pytest.mark.parametrize('tp', [np.float32, np.double, np.longdouble])
# longdouble printing issue on aarch64, see gh-23974
if platform.machine() == 'aarch64':
_real_dtypes = [np.float32, np.double]
_complex_dtypes = [np.complex64, np.cdouble]
else:
_real_dtypes = [np.float32, np.double, np.longdouble]
_complex_dtypes = [np.complex64, np.cdouble, np.clongdouble]
@pytest.mark.parametrize('tp', _real_dtypes)
def test_float_types(tp):
""" Check formatting.

Expand All @@ -34,7 +42,7 @@ def test_float_types(tp):
err_msg='Failed str formatting for type %s' % tp)


@pytest.mark.parametrize('tp', [np.float32, np.double, np.longdouble])
@pytest.mark.parametrize('tp', _real_dtypes)
def test_nan_inf_float(tp):
""" Check formatting of nan & inf.

Expand All @@ -48,7 +56,7 @@ def test_nan_inf_float(tp):
err_msg='Failed str formatting for type %s' % tp)


@pytest.mark.parametrize('tp', [np.complex64, np.cdouble, np.clongdouble])
@pytest.mark.parametrize('tp', _complex_dtypes)
def test_complex_types(tp):
"""Check formatting of complex types.

Expand All @@ -74,7 +82,7 @@ def test_complex_types(tp):
err_msg='Failed str formatting for type %s' % tp)


@pytest.mark.parametrize('dtype', [np.complex64, np.cdouble, np.clongdouble])
@pytest.mark.parametrize('dtype', _complex_dtypes)
def test_complex_inf_nan(dtype):
"""Check inf/nan formatting of complex types."""
TESTS = {
Expand Down Expand Up @@ -119,7 +127,7 @@ def _test_redirected_print(x, tp, ref=None):
err_msg='print failed for type%s' % tp)


@pytest.mark.parametrize('tp', [np.float32, np.double, np.longdouble])
@pytest.mark.parametrize('tp', _real_dtypes)
def test_float_type_print(tp):
"""Check formatting when using print """
for x in [0, 1, -1, 1e20]:
Expand All @@ -135,7 +143,7 @@ def test_float_type_print(tp):
_test_redirected_print(float(1e16), tp, ref)


@pytest.mark.parametrize('tp', [np.complex64, np.cdouble, np.clongdouble])
@pytest.mark.parametrize('tp', _complex_dtypes)
def test_complex_type_print(tp):
"""Check formatting when using print """
# We do not create complex with inf/nan directly because the feature is
Expand Down
10 changes: 8 additions & 2 deletions numpy/core/tests/test_scalarprint.py
Expand Up @@ -13,7 +13,11 @@
class TestRealScalars:
def test_str(self):
svals = [0.0, -0.0, 1, -1, np.inf, -np.inf, np.nan]
styps = [np.float16, np.float32, np.float64, np.longdouble]
# longdouble printing issue on aarch64, see gh-23974
if platform.machine() == 'aarch64':
styps = [np.float16, np.float32, np.float64]
else:
styps = [np.float16, np.float32, np.float64, np.longdouble]
wanted = [
['0.0', '0.0', '0.0', '0.0' ],
['-0.0', '-0.0', '-0.0', '-0.0'],
Expand Down Expand Up @@ -263,7 +267,9 @@ def test_dragon4(self):
def test_dragon4_interface(self):
tps = [np.float16, np.float32, np.float64]
# test is flaky for musllinux on np.float128
if hasattr(np, 'float128') and not IS_MUSL:
# also currently failing on Linux aarch64 with Meson (see gh-23974)
is_aarch64 = platform.machine() == 'aarch64'
if hasattr(np, 'float128') and not IS_MUSL and not is_aarch64:
tps.append(np.float128)

fpos = np.format_float_positional
Expand Down