From 7ade896ea8d695b32b82b423c01dfef2a98216ac Mon Sep 17 00:00:00 2001 From: marload Date: Tue, 14 Jul 2020 20:22:34 +0900 Subject: DEP: Remove deprecated python function 'file()' --- numpy/distutils/misc_util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/distutils/misc_util.py') diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py index 9f9e9f1ac..d2a3149f7 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -1900,7 +1900,7 @@ class Configuration: revision0 = f.read().strip() branch_map = {} - for line in file(branch_cache_fn, 'r'): + for line in open(branch_cache_fn, 'r'): branch1, revision1 = line.split()[:2] if revision1==revision0: branch0 = branch1 -- cgit v1.2.1 From 25fa87a92d39c4a7de72f79263c9048d657b1226 Mon Sep 17 00:00:00 2001 From: jakobjakobson13 <43045863+jakobjakobson13@users.noreply.github.com> Date: Tue, 11 Aug 2020 18:34:40 +0200 Subject: MAINT: change "for line in open()" to "with open() as f: ..." in numpy/distutils/misc_util.py (gh-#17051) see #17012 item 13 Co-authored-by: Jakob --- numpy/distutils/misc_util.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'numpy/distutils/misc_util.py') diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py index d2a3149f7..aa649a23f 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -1900,15 +1900,16 @@ class Configuration: revision0 = f.read().strip() branch_map = {} - for line in open(branch_cache_fn, 'r'): - branch1, revision1 = line.split()[:2] - if revision1==revision0: - branch0 = branch1 - try: - revision1 = int(revision1) - except ValueError: - continue - branch_map[branch1] = revision1 + with open(branch_cache_fn, 'r') as f: + for line in f: + branch1, revision1 = line.split()[:2] + if revision1==revision0: + branch0 = branch1 + try: + revision1 = int(revision1) + except ValueError: + continue + branch_map[branch1] = revision1 return branch_map.get(branch0) -- cgit v1.2.1 From 2dcbc560320cb70c2664ed442b9083f80b23840b Mon Sep 17 00:00:00 2001 From: Hassan Kibirige Date: Mon, 26 Oct 2020 19:23:40 +0300 Subject: MAINT: valid doctest for config_py function show() (#17621) numpy.distutils generates a function `__config__.show`. This change makes the docstring of that function complete (with the required imports) and runnable. This prevents numpy.distutils from adding doctests that will fail -- if picked-up by the test runner. --- numpy/distutils/misc_util.py | 1 + 1 file changed, 1 insertion(+) (limited to 'numpy/distutils/misc_util.py') diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py index aa649a23f..778723bfe 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -2356,6 +2356,7 @@ def generate_config_py(target): Examples -------- + >>> import numpy as np >>> np.show_config() blas_opt_info: language = c -- cgit v1.2.1 From 761641f4ce8e17ee53fd6964dcac90c8c7eebdf6 Mon Sep 17 00:00:00 2001 From: Dustin Spicuzza Date: Sun, 25 Oct 2020 02:47:06 -0400 Subject: BLD: Use importlib to find numpy root directory in distutils Part of changes for #17620 to prevent importing numpy during builds to support cross compilation. --- numpy/distutils/misc_util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'numpy/distutils/misc_util.py') diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py index 778723bfe..a8e19d52c 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -9,6 +9,7 @@ import subprocess import shutil import multiprocessing import textwrap +import importlib.util import distutils from distutils.errors import DistutilsError @@ -2122,12 +2123,11 @@ def get_npy_pkg_dir(): environment, and using them when cross-compiling. """ - # XXX: import here for bootstrapping reasons - import numpy d = os.environ.get('NPY_PKG_CONFIG_PATH') if d is not None: return d - d = os.path.join(os.path.dirname(numpy.__file__), + spec = importlib.util.find_spec('numpy') + d = os.path.join(os.path.dirname(spec.origin), 'core', 'lib', 'npy-pkg-config') return d -- cgit v1.2.1 From 40fd17e3a2418d54284b53dbcf2ba72dbfbb58ad Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Wed, 2 Dec 2020 13:06:51 -0700 Subject: ENH: Use versioneer to manage numpy versions. The new tags look like '1.21.0.dev0+98.gaa0453721f', where '98' is the number of commits since the 1.21.0 branch was started and 'aa0453721f'. The chosen form may be specified in the 'setup.cfg' file. This PR adds two new files 'numpy/_version.py' and 'numpy/version.py'. The latter is kept because it is part of the public API and is actually used by some downstream projects, but it is no longer dynamically created. See https://github.com/python-versioneer/python-versioneer/ for more information. --- numpy/distutils/misc_util.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'numpy/distutils/misc_util.py') diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py index a8e19d52c..d3073ab2d 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -1968,6 +1968,13 @@ class Configuration: version = getattr(version_module, a, None) if version is not None: break + + # Try if versioneer module + try: + version = version_module.get_versions()['version'] + except AttributeError: + version = None + if version is not None: break -- cgit v1.2.1