summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorRalf Gommers <ralf.gommers@googlemail.com>2016-06-12 21:31:08 +0200
committerRalf Gommers <ralf.gommers@googlemail.com>2016-06-12 21:31:08 +0200
commita52d2fa765096f1afd6c477e0f51ec3d6cb55814 (patch)
treeec24c278a0e32c6ad85669c877e24211c7c89ce0 /numpy
parent76c27b5d2a28657062b2dcebba062f1941e4955f (diff)
downloadnumpy-a52d2fa765096f1afd6c477e0f51ec3d6cb55814.tar.gz
BUG: fix issue on OS X with Python 3.x where npymath.ini was not installed.
Closes gh-7707. Happened for `pip install .` or another location (including a remote git repo).
Diffstat (limited to 'numpy')
-rw-r--r--numpy/distutils/misc_util.py12
-rw-r--r--numpy/distutils/tests/test_misc_util.py9
2 files changed, 14 insertions, 7 deletions
diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py
index 79b6f25f3..8136f8f4f 100644
--- a/numpy/distutils/misc_util.py
+++ b/numpy/distutils/misc_util.py
@@ -126,13 +126,13 @@ def allpath(name):
return os.path.join(*splitted)
def rel_path(path, parent_path):
- """Return path relative to parent_path.
- """
- pd = os.path.abspath(parent_path)
- apath = os.path.abspath(path)
- if len(apath)<len(pd):
+ """Return path relative to parent_path."""
+ # Use realpath to avoid issues with symlinked dirs (see gh-7707)
+ pd = os.path.realpath(os.path.abspath(parent_path))
+ apath = os.path.realpath(os.path.abspath(path))
+ if len(apath) < len(pd):
return path
- if apath==pd:
+ if apath == pd:
return ''
if pd == apath[:len(pd)]:
assert apath[len(pd)] in [os.sep], repr((path, apath[len(pd)]))
diff --git a/numpy/distutils/tests/test_misc_util.py b/numpy/distutils/tests/test_misc_util.py
index c50b9480b..3e97b6fe2 100644
--- a/numpy/distutils/tests/test_misc_util.py
+++ b/numpy/distutils/tests/test_misc_util.py
@@ -4,7 +4,7 @@ from __future__ import division, absolute_import, print_function
from os.path import join, sep, dirname
from numpy.distutils.misc_util import (
- appendpath, minrelpath, gpaths, get_shared_lib_extension
+ appendpath, minrelpath, gpaths, get_shared_lib_extension, get_info
)
from numpy.testing import (
TestCase, run_module_suite, assert_, assert_equal
@@ -75,5 +75,12 @@ class TestSharedExtension(TestCase):
# just check for no crash
assert_(get_shared_lib_extension(is_python_ext=True))
+
+def test_installed_npymath_ini():
+ # Regression test for gh-7707. If npymath.ini wasn't installed, then this
+ # will give an error.
+ info = get_info('npymath')
+
+
if __name__ == "__main__":
run_module_suite()