Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CI: fix wheel builds on the 1.26.x branch #24322

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

Merged
merged 6 commits into from
Aug 3, 2023
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
1 change: 1 addition & 0 deletions .github/workflows/linux_meson.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ jobs:
TERM: xterm-256color
LD_LIBRARY_PATH: "/usr/local/lib/" # to find libopenblas.so.0
run: |
export NPY_RUN_MYPY_IN_TESTSUITE=1
pip install pytest pytest-xdist hypothesis typing_extensions
spin test -j auto
2 changes: 1 addition & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
- [ubuntu-20.04, musllinux_x86_64]
- [macos-12, macosx_x86_64]
- [windows-2019, win_amd64]
python: ["cp39", "cp310", "cp311", "cp312"] # "pp39"
python: ["cp39", "cp310", "cp311", "cp312", "pp39"]
exclude:
# Don't build PyPy 32-bit windows
- buildplat: [windows-2019, win32]
Expand Down
2 changes: 1 addition & 1 deletion numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
NumPy testing tools
distutils
Enhancements to distutils with support for
Fortran compilers support and more.
Fortran compilers support and more (for Python <= 3.11).

Utilities
---------
Expand Down
13 changes: 7 additions & 6 deletions numpy/_pytesttester.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,13 @@ def __call__(self, label='fast', verbose=1, extra_argv=None,
# offset verbosity. The "-q" cancels a "-v".
pytest_args += ["-q"]

with warnings.catch_warnings():
warnings.simplefilter("always")
# Filter out distutils cpu warnings (could be localized to
# distutils tests). ASV has problems with top level import,
# so fetch module for suppression here.
from numpy.distutils import cpuinfo
if sys.version_info < (3, 12):
with warnings.catch_warnings():
warnings.simplefilter("always")
# Filter out distutils cpu warnings (could be localized to
# distutils tests). ASV has problems with top level import,
# so fetch module for suppression here.
from numpy.distutils import cpuinfo

with warnings.catch_warnings(record=True):
# Ignore the warning from importing the array_api submodule. This
Expand Down
5 changes: 4 additions & 1 deletion numpy/core/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ C_API_VERSION = '0x00000011'

# Check whether we have a mismatch between the set C API VERSION and the
# actual C API VERSION. Will raise a MismatchCAPIError if so.
r = run_command('code_generators/verify_c_api_version.py', '--api-version', C_API_VERSION)
r = run_command(
'code_generators/verify_c_api_version.py', '--api-version', C_API_VERSION,
check: true
)

if r.returncode() != 0
error('verify_c_api_version.py failed with output:\n' + r.stderr().strip())
Expand Down
3 changes: 3 additions & 0 deletions numpy/core/tests/test_array_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ def get_module(tmp_path):
more_init=more_init)


# FIXME: numpy.testing.extbuild uses `numpy.distutils`, so this won't work on
# Python 3.12 and up.
@pytest.mark.skipif(sys.version_info >= (3, 12), reason="no numpy.distutils")
@pytest.mark.slow
def test_cstruct(get_module):

Expand Down
5 changes: 5 additions & 0 deletions numpy/core/tests/test_dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,11 @@ def iter_struct_object_dtypes():
yield pytest.param(dt, p, 12, obj, id="<structured subarray 2>")


@pytest.mark.skipif(
sys.version_info >= (3, 12),
reason="Python 3.12 has immortal refcounts, this test will no longer "
"work. See gh-23986"
)
@pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts")
class TestStructuredObjectRefcounting:
"""These tests cover various uses of complicated structured types which
Expand Down
4 changes: 4 additions & 0 deletions numpy/core/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,10 @@ def test_structured_arrays_with_objects1(self):
x[x.nonzero()] = x.ravel()[:1]
assert_(x[0, 1] == x[0, 0])

@pytest.mark.skipif(
sys.version_info >= (3, 12),
reason="Python 3.12 has immortal refcounts, this test no longer works."
)
@pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts")
def test_structured_arrays_with_objects2(self):
# Ticket #1299 second test
Expand Down
1 change: 1 addition & 0 deletions numpy/lib/tests/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ def test_load_padded_dtype(tmpdir, dt):
assert_array_equal(arr, arr1)


@pytest.mark.skipif(sys.version_info >= (3, 12), reason="see gh-23988")
@pytest.mark.xfail(IS_WASM, reason="Emscripten NODEFS has a buggy dup")
def test_python2_python3_interoperability():
fname = 'win64python2.npy'
Expand Down
14 changes: 6 additions & 8 deletions numpy/tests/test_ctypeslib.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import sys
import pytest
import sysconfig
import weakref
from pathlib import Path

import pytest

import numpy as np
from numpy.ctypeslib import ndpointer, load_library, as_array
from numpy.distutils.misc_util import get_shared_lib_extension
from numpy.testing import assert_, assert_array_equal, assert_raises, assert_equal

try:
Expand Down Expand Up @@ -52,12 +53,9 @@ def test_basic2(self):
# Regression for #801: load_library with a full library name
# (including extension) does not work.
try:
try:
so = get_shared_lib_extension(is_python_ext=True)
# Should succeed
load_library('_multiarray_umath%s' % so, np.core._multiarray_umath.__file__)
except ImportError:
print("No distutils available, skipping test.")
so_ext = sysconfig.get_config_var('EXT_SUFFIX')
load_library('_multiarray_umath%s' % so_ext,
np.core._multiarray_umath.__file__)
except ImportError as e:
msg = ("ctypes is not available on this python: skipping the test"
" (import error was: %s)" % str(e))
Expand Down
171 changes: 98 additions & 73 deletions numpy/tests/test_public_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,6 @@ def test_NPY_NO_EXPORT():
"array_api",
"array_api.linalg",
"ctypeslib",
"distutils",
"distutils.cpuinfo",
"distutils.exec_command",
"distutils.misc_util",
"distutils.log",
"distutils.system_info",
"doc",
"doc.constants",
"doc.ufuncs",
Expand Down Expand Up @@ -165,6 +159,18 @@ def test_NPY_NO_EXPORT():
"typing.mypy_plugin",
"version",
]]
if sys.version_info < (3, 12):
PUBLIC_MODULES += [
'numpy.' + s for s in [
"distutils",
"distutils.cpuinfo",
"distutils.exec_command",
"distutils.misc_util",
"distutils.log",
"distutils.system_info",
]
]



PUBLIC_ALIASED_MODULES = [
Expand Down Expand Up @@ -193,62 +199,6 @@ def test_NPY_NO_EXPORT():
"core.records",
"core.shape_base",
"core.umath",
"core.umath_tests",
"distutils.armccompiler",
"distutils.fujitsuccompiler",
"distutils.ccompiler",
'distutils.ccompiler_opt',
"distutils.command",
"distutils.command.autodist",
"distutils.command.bdist_rpm",
"distutils.command.build",
"distutils.command.build_clib",
"distutils.command.build_ext",
"distutils.command.build_py",
"distutils.command.build_scripts",
"distutils.command.build_src",
"distutils.command.config",
"distutils.command.config_compiler",
"distutils.command.develop",
"distutils.command.egg_info",
"distutils.command.install",
"distutils.command.install_clib",
"distutils.command.install_data",
"distutils.command.install_headers",
"distutils.command.sdist",
"distutils.conv_template",
"distutils.core",
"distutils.extension",
"distutils.fcompiler",
"distutils.fcompiler.absoft",
"distutils.fcompiler.arm",
"distutils.fcompiler.compaq",
"distutils.fcompiler.environment",
"distutils.fcompiler.g95",
"distutils.fcompiler.gnu",
"distutils.fcompiler.hpux",
"distutils.fcompiler.ibm",
"distutils.fcompiler.intel",
"distutils.fcompiler.lahey",
"distutils.fcompiler.mips",
"distutils.fcompiler.nag",
"distutils.fcompiler.none",
"distutils.fcompiler.pathf95",
"distutils.fcompiler.pg",
"distutils.fcompiler.nv",
"distutils.fcompiler.sun",
"distutils.fcompiler.vast",
"distutils.fcompiler.fujitsu",
"distutils.from_template",
"distutils.intelccompiler",
"distutils.lib2def",
"distutils.line_endings",
"distutils.mingw32ccompiler",
"distutils.msvccompiler",
"distutils.npy_pkg_config",
"distutils.numpy_distribution",
"distutils.pathccompiler",
"distutils.unixccompiler",
"f2py.auxfuncs",
"f2py.capi_maps",
"f2py.cb_rules",
Expand Down Expand Up @@ -290,6 +240,66 @@ def test_NPY_NO_EXPORT():
"random.bit_generator",
"testing.print_coercion_tables",
]]
if sys.version_info < (3, 12):
PRIVATE_BUT_PRESENT_MODULES += [
'numpy.' + s for s in [
"distutils.armccompiler",
"distutils.fujitsuccompiler",
"distutils.ccompiler",
'distutils.ccompiler_opt',
"distutils.command",
"distutils.command.autodist",
"distutils.command.bdist_rpm",
"distutils.command.build",
"distutils.command.build_clib",
"distutils.command.build_ext",
"distutils.command.build_py",
"distutils.command.build_scripts",
"distutils.command.build_src",
"distutils.command.config",
"distutils.command.config_compiler",
"distutils.command.develop",
"distutils.command.egg_info",
"distutils.command.install",
"distutils.command.install_clib",
"distutils.command.install_data",
"distutils.command.install_headers",
"distutils.command.sdist",
"distutils.conv_template",
"distutils.core",
"distutils.extension",
"distutils.fcompiler",
"distutils.fcompiler.absoft",
"distutils.fcompiler.arm",
"distutils.fcompiler.compaq",
"distutils.fcompiler.environment",
"distutils.fcompiler.g95",
"distutils.fcompiler.gnu",
"distutils.fcompiler.hpux",
"distutils.fcompiler.ibm",
"distutils.fcompiler.intel",
"distutils.fcompiler.lahey",
"distutils.fcompiler.mips",
"distutils.fcompiler.nag",
"distutils.fcompiler.none",
"distutils.fcompiler.pathf95",
"distutils.fcompiler.pg",
"distutils.fcompiler.nv",
"distutils.fcompiler.sun",
"distutils.fcompiler.vast",
"distutils.fcompiler.fujitsu",
"distutils.from_template",
"distutils.intelccompiler",
"distutils.lib2def",
"distutils.line_endings",
"distutils.mingw32ccompiler",
"distutils.msvccompiler",
"distutils.npy_pkg_config",
"distutils.numpy_distribution",
"distutils.pathccompiler",
"distutils.unixccompiler",
]
]


def is_unexpected(name):
Expand Down Expand Up @@ -323,10 +333,14 @@ def is_unexpected(name):
"numpy.core.code_generators.verify_c_api_version",
"numpy.core.cversions",
"numpy.core.generate_numpy_api",
"numpy.distutils.msvc9compiler",
"numpy.core.umath_tests",
]
if sys.version_info < (3, 12):
SKIP_LIST += ["numpy.distutils.msvc9compiler"]


# suppressing warnings from deprecated modules
@pytest.mark.filterwarnings("ignore:.*np.compat.*:DeprecationWarning")
def test_all_modules_are_expected():
"""
Test that we don't add anything that looks like a new public module by
Expand All @@ -351,9 +365,6 @@ def test_all_modules_are_expected():
# below
SKIP_LIST_2 = [
'numpy.math',
'numpy.distutils.log.sys',
'numpy.distutils.log.logging',
'numpy.distutils.log.warnings',
'numpy.doc.constants.re',
'numpy.doc.constants.textwrap',
'numpy.lib.emath',
Expand All @@ -369,6 +380,12 @@ def test_all_modules_are_expected():
'numpy.matlib.ctypeslib',
'numpy.matlib.ma',
]
if sys.version_info < (3, 12):
SKIP_LIST_2 += [
'numpy.distutils.log.sys',
'numpy.distutils.log.logging',
'numpy.distutils.log.warnings',
]


def test_all_modules_are_expected_2():
Expand Down Expand Up @@ -472,11 +489,7 @@ def check_importable(module_name):


@pytest.mark.xfail(
hasattr(np.__config__, "_built_with_meson"),
reason = "Meson does not yet support entry points via pyproject.toml",
)
@pytest.mark.xfail(
sysconfig.get_config_var("Py_DEBUG") is not None,
sysconfig.get_config_var("Py_DEBUG") not in (None, 0, "0"),
reason=(
"NumPy possibly built with `USE_DEBUG=True ./tools/travis-test.sh`, "
"which does not expose the `array_api` entry point. "
Expand All @@ -488,6 +501,11 @@ def test_array_api_entry_point():
Entry point for Array API implementation can be found with importlib and
returns the numpy.array_api namespace.
"""
# For a development install that did not go through meson-python,
# the entrypoint will not have been installed. So ensure this test fails
# only if numpy is inside site-packages.
numpy_in_sitepackages = sysconfig.get_path('platlib') in np.__file__

eps = importlib.metadata.entry_points()
try:
xp_eps = eps.select(group="array_api")
Expand All @@ -497,12 +515,19 @@ def test_array_api_entry_point():
# Array API entry points so that running this test in <=3.9 will
# still work - see https://github.com/numpy/numpy/pull/19800.
xp_eps = eps.get("array_api", [])
assert len(xp_eps) > 0, "No entry points for 'array_api' found"
if len(xp_eps) == 0:
if numpy_in_sitepackages:
msg = "No entry points for 'array_api' found"
raise AssertionError(msg) from None
return

try:
ep = next(ep for ep in xp_eps if ep.name == "numpy")
except StopIteration:
raise AssertionError("'numpy' not in array_api entry points") from None
if numpy_in_sitepackages:
msg = "'numpy' not in array_api entry points"
raise AssertionError(msg) from None
return

xp = ep.load()
msg = (
Expand Down
4 changes: 3 additions & 1 deletion numpy/typing/tests/test_isfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
from pathlib import Path

import numpy as np
Expand All @@ -10,7 +11,6 @@
ROOT / "__init__.pyi",
ROOT / "ctypeslib.pyi",
ROOT / "core" / "__init__.pyi",
ROOT / "distutils" / "__init__.pyi",
ROOT / "f2py" / "__init__.pyi",
ROOT / "fft" / "__init__.pyi",
ROOT / "lib" / "__init__.pyi",
Expand All @@ -21,6 +21,8 @@
ROOT / "random" / "__init__.pyi",
ROOT / "testing" / "__init__.pyi",
]
if sys.version_info < (3, 12):
FILES += [ROOT / "distutils" / "__init__.pyi"]


class TestIsFile:
Expand Down
Loading