Skip to content

Commit

Permalink
MAINT: Python <3.8 related cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
bsipocz committed May 23, 2022
1 parent 53379cd commit d4d5771
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 65 deletions.
28 changes: 0 additions & 28 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,31 +299,3 @@ stages:
testResultsFiles: '**/test-*.xml'
failTaskOnFailedTests: true
testRunTitle: 'Publish test results for conda installation'


#- job: Linux_gcc48
#pool:
## ubuntu-20.04 does not provide a gcc-4.8 package
#vmImage: 'ubuntu-18.04'
#steps:
#- script: |
#sudo apt update
#sudo apt install python3.7
#sudo apt install python3.7-dev
#if ! `gcc-4.8 2>/dev/null`; then
#sudo apt install gcc-4.8
#fi
#displayName: 'add gcc 4.8'
#- script: |
## python3 has no setuptools, so install one to get us going
#python3.7 -m pip install --user --upgrade pip 'setuptools<49.2.0'
#python3.7 -m pip install --user -r test_requirements.txt
#CPPFLAGS='' CC=gcc-4.8 F77=gfortran-5 F90=gfortran-5 \
#python3.7 runtests.py --debug-info --mode=full -- -rsx --junitxml=junit/test-results.xml
#displayName: 'Run gcc4.8 Build / Tests'
#- task: PublishTestResults@2
#condition: succeededOrFailed()
#inputs:
#testResultsFiles: '**/test-*.xml'
#failTaskOnFailedTests: true
#testRunTitle: 'Publish test results for gcc 4.8'
4 changes: 2 additions & 2 deletions doc/source/dev/development_environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ That also takes extra arguments, like ``--pdb`` which drops you into the Python
debugger when a test fails or an exception is raised.

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

$ tox -e py37
$ tox -e py39

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

Expand Down
4 changes: 2 additions & 2 deletions doc/source/f2py/code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
)
endif()

# Grab Python, 3.7 or newer
find_package(Python 3.7 REQUIRED
# Grab Python, 3.8 or newer
find_package(Python 3.8 REQUIRED
COMPONENTS Interpreter Development.Module NumPy)

# Grab the variables from a local Python installation
Expand Down
2 changes: 1 addition & 1 deletion doc/source/f2py/code/CMakeLists_skbuild.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ endif()

# Ensure scikit-build modules
if (NOT SKBUILD)
find_package(PythonInterp 3.7 REQUIRED)
find_package(PythonInterp 3.8 REQUIRED)
# Kanged --> https://github.com/Kitware/torch_liberator/blob/master/CMakeLists.txt
# If skbuild is not the driver; include its utilities in CMAKE_MODULE_PATH
execute_process(
Expand Down
2 changes: 1 addition & 1 deletion doc/source/user/absolute_beginners.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ followed by the docstring of ``ndarray`` of which ``a`` is an instance):
Type: ndarray
String form: [1 2 3 4 5 6]
Length: 6
File: ~/anaconda3/lib/python3.7/site-packages/numpy/__init__.py
File: ~/anaconda3/lib/python3.9/site-packages/numpy/__init__.py
Docstring: <no docstring>
Class docstring:
ndarray(shape, dtype=float, buffer=None, offset=0,
Expand Down
2 changes: 0 additions & 2 deletions numpy/core/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -2480,8 +2480,6 @@ def __len__(self):
assert arr.shape == (1, 0, 0)

@pytest.mark.skipif(sys.maxsize < 2 ** 31 + 1, reason='overflows 32-bit python')
@pytest.mark.skipif(sys.platform == 'win32' and sys.version_info[:2] < (3, 8),
reason='overflows on windows, fixed in bpo-16865')
def test_to_ctypes(self):
#gh-14214
arr = np.zeros((2 ** 31 + 1,), 'b')
Expand Down
7 changes: 1 addition & 6 deletions numpy/distutils/misc_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2348,11 +2348,7 @@ def generate_config_py(target):
extra_dll_dir = os.path.join(os.path.dirname(__file__), '.libs')
if sys.platform == 'win32' and os.path.isdir(extra_dll_dir):
if sys.version_info >= (3, 8):
os.add_dll_directory(extra_dll_dir)
else:
os.environ.setdefault('PATH', '')
os.environ['PATH'] += os.pathsep + extra_dll_dir
os.add_dll_directory(extra_dll_dir)
"""))

Expand Down Expand Up @@ -2495,4 +2491,3 @@ def exec_mod_from_location(modname, modfile):
foo = importlib.util.module_from_spec(spec)
spec.loader.exec_module(foo)
return foo

20 changes: 9 additions & 11 deletions numpy/testing/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ def test_regex(self):
lambda: assert_string_equal("aaa", "a+b"))


def assert_warn_len_equal(mod, n_in_context, py37=None):
def assert_warn_len_equal(mod, n_in_context):
try:
mod_warns = mod.__warningregistry__
except AttributeError:
Expand All @@ -1245,6 +1245,7 @@ def assert_warn_len_equal(mod, n_in_context, py37=None):

assert_equal(num_warns, n_in_context)


def test_warn_len_equal_call_scenarios():
# assert_warn_len_equal is called under
# varying circumstances depending on serial
Expand Down Expand Up @@ -1294,22 +1295,20 @@ def test_clear_and_catch_warnings():
warnings.warn('Some warning')
assert_equal(my_mod.__warningregistry__, {})
# Without specified modules, don't clear warnings during context
# Python 3.7 catch_warnings doesn't make an entry for 'ignore'.
with clear_and_catch_warnings():
warnings.simplefilter('ignore')
warnings.warn('Some warning')
assert_warn_len_equal(my_mod, 1, py37=0)
assert_warn_len_equal(my_mod, 1)
# Confirm that specifying module keeps old warning, does not add new
with clear_and_catch_warnings(modules=[my_mod]):
warnings.simplefilter('ignore')
warnings.warn('Another warning')
assert_warn_len_equal(my_mod, 1, py37=0)
assert_warn_len_equal(my_mod, 1)
# Another warning, no module spec does add to warnings dict, except on
# Python 3.7 catch_warnings doesn't make an entry for 'ignore'.
with clear_and_catch_warnings():
warnings.simplefilter('ignore')
warnings.warn('Another warning')
assert_warn_len_equal(my_mod, 2, py37=0)
assert_warn_len_equal(my_mod, 2)


def test_suppress_warnings_module():
Expand Down Expand Up @@ -1338,7 +1337,7 @@ def warn(arr):
# got filtered)
assert_equal(len(sup.log), 1)
assert_equal(sup.log[0].message.args[0], "Some warning")
assert_warn_len_equal(my_mod, 0, py37=0)
assert_warn_len_equal(my_mod, 0)
sup = suppress_warnings()
# Will have to be changed if apply_along_axis is moved:
sup.filter(module=my_mod)
Expand All @@ -1352,11 +1351,11 @@ def warn(arr):
assert_warn_len_equal(my_mod, 0)

# Without specified modules, don't clear warnings during context
# Python 3.7 does not add ignored warnings.
with suppress_warnings():
warnings.simplefilter('ignore')
warnings.warn('Some warning')
assert_warn_len_equal(my_mod, 1, py37=0)
assert_warn_len_equal(my_mod, 1)


def test_suppress_warnings_type():
# Initial state of module, no warnings
Expand All @@ -1380,11 +1379,10 @@ def test_suppress_warnings_type():
assert_warn_len_equal(my_mod, 0)

# Without specified modules, don't clear warnings during context
# Python 3.7 does not add ignored warnings.
with suppress_warnings():
warnings.simplefilter('ignore')
warnings.warn('Some warning')
assert_warn_len_equal(my_mod, 1, py37=0)
assert_warn_len_equal(my_mod, 1)


def test_suppress_warnings_decorate_no_record():
Expand Down
4 changes: 2 additions & 2 deletions numpy/tests/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def find_f2py_commands():
else:
# Three scripts are installed in Unix-like systems:
# 'f2py', 'f2py{major}', and 'f2py{major.minor}'. For example,
# if installed with python3.7 the scripts would be named
# 'f2py', 'f2py3', and 'f2py3.7'.
# if installed with python3.9 the scripts would be named
# 'f2py', 'f2py3', and 'f2py3.9'.
version = sys.version_info
major = str(version.major)
minor = str(version.minor)
Expand Down
5 changes: 2 additions & 3 deletions numpy/typing/tests/data/pass/array_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ def func(i: int, j: int, **kwargs: Any) -> SubClass:
B_stack = np.array([[1], [1]]).view(SubClass)
C = [1]

if sys.version_info >= (3, 8):
np.ndarray(Index())
np.ndarray([Index()])
np.ndarray(Index())
np.ndarray([Index()])

np.array(1, dtype=float)
np.array(1, copy=False)
Expand Down
7 changes: 3 additions & 4 deletions numpy/typing/tests/data/pass/scalars.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@ def __float__(self) -> float:
np.float32("1")
np.float16(b"2.5")

if sys.version_info >= (3, 8):
np.uint64(D())
np.float32(D())
np.complex64(D())
np.uint64(D())
np.float32(D())
np.complex64(D())

np.bytes_(b"hello")
np.bytes_("hello", 'utf-8')
Expand Down
2 changes: 1 addition & 1 deletion tools/find_deprecated_escaped_characters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
be written as '\\(' or r'\('.
"""
import sys


def main(root):
"""Find deprecated escape sequences.
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# - Use pip to install the numpy sdist into the virtualenv
# - Run the numpy tests
# To run against a specific subset of Python versions, use:
# tox -e py37
# tox -e py39

# Extra arguments will be passed to runtests.py. To run
# the full testsuite:
Expand All @@ -26,7 +26,7 @@

[tox]
envlist =
py37,py38,py39
py38,py39

[testenv]
deps= -Ur{toxinidir}/test_requirements.txt
Expand Down

0 comments on commit d4d5771

Please sign in to comment.