Skip to content

Commit 41b6ac0

Browse files
authored
Merge pull request numpy#21558 from bsipocz/python36_37_cleanup
MAINT: Python <3.8 related cleanups
2 parents 4a2751c + 22afd8c commit 41b6ac0

22 files changed

+62
-145
lines changed

INSTALL.rst.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ Prerequisites
1414

1515
Building NumPy requires the following installed software:
1616

17-
1) Python__ 3.7.x or newer.
17+
1) Python__ 3.8.x or newer.
1818

1919
Please note that the Python development headers also need to be installed,
2020
e.g., on Debian/Ubuntu one needs to install both `python3` and
2121
`python3-dev`. On Windows and macOS this is normally not an issue.
2222

23-
2) Cython >= 0.29.30
23+
2) Cython >= 0.29.30 but < 3.0
2424

25-
3) pytest__ (optional) 1.15 or later
25+
3) pytest__ (optional)
2626

2727
This is required for testing NumPy, but not for using it.
2828

azure-pipelines.yml

-28
Original file line numberDiff line numberDiff line change
@@ -299,31 +299,3 @@ stages:
299299
testResultsFiles: '**/test-*.xml'
300300
failTaskOnFailedTests: true
301301
testRunTitle: 'Publish test results for conda installation'
302-
303-
304-
#- job: Linux_gcc48
305-
#pool:
306-
## ubuntu-20.04 does not provide a gcc-4.8 package
307-
#vmImage: 'ubuntu-18.04'
308-
#steps:
309-
#- script: |
310-
#sudo apt update
311-
#sudo apt install python3.7
312-
#sudo apt install python3.7-dev
313-
#if ! `gcc-4.8 2>/dev/null`; then
314-
#sudo apt install gcc-4.8
315-
#fi
316-
#displayName: 'add gcc 4.8'
317-
#- script: |
318-
## python3 has no setuptools, so install one to get us going
319-
#python3.7 -m pip install --user --upgrade pip 'setuptools<49.2.0'
320-
#python3.7 -m pip install --user -r test_requirements.txt
321-
#CPPFLAGS='' CC=gcc-4.8 F77=gfortran-5 F90=gfortran-5 \
322-
#python3.7 runtests.py --debug-info --mode=full -- -rsx --junitxml=junit/test-results.xml
323-
#displayName: 'Run gcc4.8 Build / Tests'
324-
#- task: PublishTestResults@2
325-
#condition: succeededOrFailed()
326-
#inputs:
327-
#testResultsFiles: '**/test-*.xml'
328-
#failTaskOnFailedTests: true
329-
#testRunTitle: 'Publish test results for gcc 4.8'

azure-steps-windows.yml

-11
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,6 @@ steps:
7272
}
7373
displayName: 'Build NumPy'
7474

75-
- bash: |
76-
pushd . && cd .. && target=$(python -c "import numpy, os; print(os.path.abspath(os.path.join(os.path.dirname(numpy.__file__), '.libs')))") && popd
77-
python -m pip download -d destination --only-binary :all: --no-deps numpy==1.14
78-
cd destination && unzip numpy*.whl && cp numpy/.libs/*.dll $target
79-
ls $target
80-
displayName: 'Add extraneous & older DLL to numpy/.libs to probe DLL handling robustness'
81-
condition: eq(variables['PYTHON_VERSION'], '3.6')
82-
- script: pushd . && cd .. && python -c "from ctypes import windll; windll.kernel32.SetDefaultDllDirectories(0x00000800); import numpy" && popd
83-
displayName: 'For gh-12667; Windows DLL resolution'
84-
condition: eq(variables['PYTHON_VERSION'], '3.6')
85-
8675
- script: python runtests.py -n --show-build-log --mode=$(TEST_MODE) -- -rsx --junitxml=junit/test-results.xml
8776
displayName: 'Run NumPy Test Suite'
8877

doc/HOWTO_RELEASE.rst.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ What is released
153153

154154
Wheels
155155
------
156-
We currently support Python 3.6-3.8 on Windows, OSX, and Linux
156+
We currently support Python 3.8-3.10 on Windows, OSX, and Linux
157157

158158
* Windows: 32-bit and 64-bit wheels built using Appveyor;
159159
* OSX: x64_86 OSX wheels built using travis-ci;

doc/source/dev/development_environment.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ That also takes extra arguments, like ``--pdb`` which drops you into the Python
194194
debugger when a test fails or an exception is raised.
195195

196196
Running tests with `tox`_ is also supported. For example, to build NumPy and
197-
run the test suite with Python 3.7, use::
197+
run the test suite with Python 3.9, use::
198198

199-
$ tox -e py37
199+
$ tox -e py39
200200

201201
For more extensive information, see :ref:`testing-guidelines`
202202

doc/source/f2py/code/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
1414
)
1515
endif()
1616

17-
# Grab Python, 3.7 or newer
18-
find_package(Python 3.7 REQUIRED
17+
# Grab Python, 3.8 or newer
18+
find_package(Python 3.8 REQUIRED
1919
COMPONENTS Interpreter Development.Module NumPy)
2020

2121
# Grab the variables from a local Python installation

doc/source/f2py/code/CMakeLists_skbuild.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ endif()
1717

1818
# Ensure scikit-build modules
1919
if (NOT SKBUILD)
20-
find_package(PythonInterp 3.7 REQUIRED)
20+
find_package(PythonInterp 3.8 REQUIRED)
2121
# Kanged --> https://github.com/Kitware/torch_liberator/blob/master/CMakeLists.txt
2222
# If skbuild is not the driver; include its utilities in CMAKE_MODULE_PATH
2323
execute_process(

doc/source/user/absolute_beginners.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,7 @@ followed by the docstring of ``ndarray`` of which ``a`` is an instance):
13441344
Type: ndarray
13451345
String form: [1 2 3 4 5 6]
13461346
Length: 6
1347-
File: ~/anaconda3/lib/python3.7/site-packages/numpy/__init__.py
1347+
File: ~/anaconda3/lib/python3.9/site-packages/numpy/__init__.py
13481348
Docstring: <no docstring>
13491349
Class docstring:
13501350
ndarray(shape, dtype=float, buffer=None, offset=0,

doc/source/user/basics.rec.rst

+4-6
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,14 @@ summary they are:
146146

147147
4. A dictionary of field names
148148

149-
The use of this form of specification is discouraged, but documented here
150-
because older numpy code may use it. The keys of the dictionary are the
151-
field names and the values are tuples specifying type and offset::
149+
The keys of the dictionary are the field names and the values are tuples
150+
specifying type and offset::
152151

153152
>>> np.dtype({'col1': ('i1', 0), 'col2': ('f4', 1)})
154153
dtype([('col1', 'i1'), ('col2', '<f4')])
155154

156-
This form is discouraged because Python dictionaries do not preserve order
157-
in Python versions before Python 3.6, and the order of the fields in a
158-
structured dtype has meaning. :ref:`Field Titles <titles>` may be
155+
This form was discouraged because Python dictionaries did not preserve order
156+
in Python versions before Python 3.6. :ref:`Field Titles <titles>` may be
159157
specified by using a 3-tuple, see below.
160158

161159
Manipulating and Displaying Structured Datatypes

numpy/core/tests/test_deprecations.py

-3
Original file line numberDiff line numberDiff line change
@@ -613,9 +613,6 @@ def test_non_exact_match(self):
613613

614614
class TestDeprecatedGlobals(_DeprecationTestCase):
615615
# 2020-06-06
616-
@pytest.mark.skipif(
617-
sys.version_info < (3, 7),
618-
reason='module-level __getattr__ not supported')
619616
def test_type_aliases(self):
620617
# from builtins
621618
self.assert_deprecated(lambda: np.bool(True))

numpy/core/tests/test_multiarray.py

+3-11
Original file line numberDiff line numberDiff line change
@@ -4135,13 +4135,6 @@ class TestPickling:
41354135
def test_correct_protocol5_error_message(self):
41364136
array = np.arange(10)
41374137

4138-
if sys.version_info[:2] in ((3, 6), (3, 7)):
4139-
# For the specific case of python3.6 and 3.7, raise a clear import
4140-
# error about the pickle5 backport when trying to use protocol=5
4141-
# without the pickle5 package
4142-
with pytest.raises(ImportError):
4143-
array.__reduce_ex__(5)
4144-
41454138
def test_record_array_with_object_dtype(self):
41464139
my_object = object()
41474140

@@ -8569,10 +8562,9 @@ def __bool__(self):
85698562

85708563
self_containing = np.array([None])
85718564
self_containing[0] = self_containing
8572-
try:
8573-
Error = RecursionError
8574-
except NameError:
8575-
Error = RuntimeError # python < 3.5
8565+
8566+
Error = RecursionError
8567+
85768568
assert_raises(Error, bool, self_containing) # previously stack overflow
85778569
self_containing[0] = None # resolve circular reference
85788570

numpy/core/tests/test_regression.py

-8
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717
from numpy.testing._private.utils import _no_tracing, requires_memory
1818
from numpy.compat import asbytes, asunicode, pickle
1919

20-
try:
21-
RecursionError
22-
except NameError:
23-
RecursionError = RuntimeError # python < 3.5
24-
25-
2620

2721
class TestRegression:
2822
def test_invalid_round(self):
@@ -2486,8 +2480,6 @@ def __len__(self):
24862480
assert arr.shape == (1, 0, 0)
24872481

24882482
@pytest.mark.skipif(sys.maxsize < 2 ** 31 + 1, reason='overflows 32-bit python')
2489-
@pytest.mark.skipif(sys.platform == 'win32' and sys.version_info[:2] < (3, 8),
2490-
reason='overflows on windows, fixed in bpo-16865')
24912483
def test_to_ctypes(self):
24922484
#gh-14214
24932485
arr = np.zeros((2 ** 31 + 1,), 'b')

numpy/distutils/misc_util.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,7 @@ def get_shared_lib_extension(is_python_ext=False):
694694
-----
695695
For Python shared libs, `so_ext` will typically be '.so' on Linux and OS X,
696696
and '.pyd' on Windows. For Python >= 3.2 `so_ext` has a tag prepended on
697-
POSIX systems according to PEP 3149. For Python 3.2 this is implemented on
698-
Linux, but not on OS X.
697+
POSIX systems according to PEP 3149.
699698
700699
"""
701700
confvars = distutils.sysconfig.get_config_vars()
@@ -2349,11 +2348,7 @@ def generate_config_py(target):
23492348
extra_dll_dir = os.path.join(os.path.dirname(__file__), '.libs')
23502349
23512350
if sys.platform == 'win32' and os.path.isdir(extra_dll_dir):
2352-
if sys.version_info >= (3, 8):
2353-
os.add_dll_directory(extra_dll_dir)
2354-
else:
2355-
os.environ.setdefault('PATH', '')
2356-
os.environ['PATH'] += os.pathsep + extra_dll_dir
2351+
os.add_dll_directory(extra_dll_dir)
23572352
23582353
"""))
23592354

@@ -2496,4 +2491,3 @@ def exec_mod_from_location(modname, modfile):
24962491
foo = importlib.util.module_from_spec(spec)
24972492
spec.loader.exec_module(foo)
24982493
return foo
2499-

numpy/f2py/__init__.py

+13-18
Original file line numberDiff line numberDiff line change
@@ -169,24 +169,19 @@ def get_include():
169169
return os.path.join(os.path.dirname(__file__), 'src')
170170

171171

172-
if sys.version_info[:2] >= (3, 7):
173-
# module level getattr is only supported in 3.7 onwards
174-
# https://www.python.org/dev/peps/pep-0562/
175-
def __getattr__(attr):
176-
177-
# Avoid importing things that aren't needed for building
178-
# which might import the main numpy module
179-
if attr == "test":
180-
from numpy._pytesttester import PytestTester
181-
test = PytestTester(__name__)
182-
return test
172+
def __getattr__(attr):
183173

184-
else:
185-
raise AttributeError("module {!r} has no attribute "
186-
"{!r}".format(__name__, attr))
174+
# Avoid importing things that aren't needed for building
175+
# which might import the main numpy module
176+
if attr == "test":
177+
from numpy._pytesttester import PytestTester
178+
test = PytestTester(__name__)
179+
return test
180+
181+
else:
182+
raise AttributeError("module {!r} has no attribute "
183+
"{!r}".format(__name__, attr))
187184

188-
def __dir__():
189-
return list(globals().keys() | {"test"})
190185

191-
else:
192-
raise NotImplementedError("F2PY needs Python 3.7")
186+
def __dir__():
187+
return list(globals().keys() | {"test"})

numpy/lib/tests/test_financial_expired.py

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import numpy as np
44

55

6-
@pytest.mark.skipif(sys.version_info[:2] < (3, 7),
7-
reason="requires python 3.7 or higher")
86
def test_financial_expired():
97
match = 'NEP 32'
108
with pytest.warns(DeprecationWarning, match=match):

numpy/testing/tests/test_utils.py

+20-22
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ def test_regex(self):
12231223
lambda: assert_string_equal("aaa", "a+b"))
12241224

12251225

1226-
def assert_warn_len_equal(mod, n_in_context, py37=None):
1226+
def assert_warn_len_equal(mod, n_in_context):
12271227
try:
12281228
mod_warns = mod.__warningregistry__
12291229
except AttributeError:
@@ -1243,15 +1243,9 @@ def assert_warn_len_equal(mod, n_in_context, py37=None):
12431243
# do not count it.
12441244
num_warns -= 1
12451245

1246-
# Behavior of warnings is Python version dependent. Adjust the
1247-
# expected result to compensate. In particular, Python 3.7 does
1248-
# not make an entry for ignored warnings.
1249-
if sys.version_info[:2] >= (3, 7):
1250-
if py37 is not None:
1251-
n_in_context = py37
1252-
12531246
assert_equal(num_warns, n_in_context)
12541247

1248+
12551249
def test_warn_len_equal_call_scenarios():
12561250
# assert_warn_len_equal is called under
12571251
# varying circumstances depending on serial
@@ -1300,23 +1294,28 @@ def test_clear_and_catch_warnings():
13001294
warnings.simplefilter('ignore')
13011295
warnings.warn('Some warning')
13021296
assert_equal(my_mod.__warningregistry__, {})
1303-
# Without specified modules, don't clear warnings during context
1304-
# Python 3.7 catch_warnings doesn't make an entry for 'ignore'.
1297+
# Without specified modules, don't clear warnings during context.
1298+
# catch_warnings doesn't make an entry for 'ignore'.
13051299
with clear_and_catch_warnings():
13061300
warnings.simplefilter('ignore')
13071301
warnings.warn('Some warning')
1308-
assert_warn_len_equal(my_mod, 1, py37=0)
1302+
assert_warn_len_equal(my_mod, 0)
1303+
1304+
# Manually adding two warnings to the registry:
1305+
my_mod.__warningregistry__ = {'warning1': 1,
1306+
'warning2': 2}
1307+
13091308
# Confirm that specifying module keeps old warning, does not add new
13101309
with clear_and_catch_warnings(modules=[my_mod]):
13111310
warnings.simplefilter('ignore')
13121311
warnings.warn('Another warning')
1313-
assert_warn_len_equal(my_mod, 1, py37=0)
1314-
# Another warning, no module spec does add to warnings dict, except on
1315-
# Python 3.7 catch_warnings doesn't make an entry for 'ignore'.
1312+
assert_warn_len_equal(my_mod, 2)
1313+
1314+
# Another warning, no module spec it clears up registry
13161315
with clear_and_catch_warnings():
13171316
warnings.simplefilter('ignore')
13181317
warnings.warn('Another warning')
1319-
assert_warn_len_equal(my_mod, 2, py37=0)
1318+
assert_warn_len_equal(my_mod, 0)
13201319

13211320

13221321
def test_suppress_warnings_module():
@@ -1345,7 +1344,7 @@ def warn(arr):
13451344
# got filtered)
13461345
assert_equal(len(sup.log), 1)
13471346
assert_equal(sup.log[0].message.args[0], "Some warning")
1348-
assert_warn_len_equal(my_mod, 0, py37=0)
1347+
assert_warn_len_equal(my_mod, 0)
13491348
sup = suppress_warnings()
13501349
# Will have to be changed if apply_along_axis is moved:
13511350
sup.filter(module=my_mod)
@@ -1358,12 +1357,12 @@ def warn(arr):
13581357
warnings.warn('Some warning')
13591358
assert_warn_len_equal(my_mod, 0)
13601359

1361-
# Without specified modules, don't clear warnings during context
1362-
# Python 3.7 does not add ignored warnings.
1360+
# Without specified modules
13631361
with suppress_warnings():
13641362
warnings.simplefilter('ignore')
13651363
warnings.warn('Some warning')
1366-
assert_warn_len_equal(my_mod, 1, py37=0)
1364+
assert_warn_len_equal(my_mod, 0)
1365+
13671366

13681367
def test_suppress_warnings_type():
13691368
# Initial state of module, no warnings
@@ -1386,12 +1385,11 @@ def test_suppress_warnings_type():
13861385
warnings.warn('Some warning')
13871386
assert_warn_len_equal(my_mod, 0)
13881387

1389-
# Without specified modules, don't clear warnings during context
1390-
# Python 3.7 does not add ignored warnings.
1388+
# Without specified modules
13911389
with suppress_warnings():
13921390
warnings.simplefilter('ignore')
13931391
warnings.warn('Some warning')
1394-
assert_warn_len_equal(my_mod, 1, py37=0)
1392+
assert_warn_len_equal(my_mod, 0)
13951393

13961394

13971395
def test_suppress_warnings_decorate_no_record():

numpy/tests/test_scripts.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def find_f2py_commands():
2424
else:
2525
# Three scripts are installed in Unix-like systems:
2626
# 'f2py', 'f2py{major}', and 'f2py{major.minor}'. For example,
27-
# if installed with python3.7 the scripts would be named
28-
# 'f2py', 'f2py3', and 'f2py3.7'.
27+
# if installed with python3.9 the scripts would be named
28+
# 'f2py', 'f2py3', and 'f2py3.9'.
2929
version = sys.version_info
3030
major = str(version.major)
3131
minor = str(version.minor)

numpy/typing/tests/data/pass/array_constructors.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ def func(i: int, j: int, **kwargs: Any) -> SubClass:
2323
B_stack = np.array([[1], [1]]).view(SubClass)
2424
C = [1]
2525

26-
if sys.version_info >= (3, 8):
27-
np.ndarray(Index())
28-
np.ndarray([Index()])
26+
np.ndarray(Index())
27+
np.ndarray([Index()])
2928

3029
np.array(1, dtype=float)
3130
np.array(1, copy=False)

0 commit comments

Comments
 (0)