add fix for in-tree symlinks, with updated test
authorR. Andrew Ohana <andrew.ohana@gmail.com>
Tue, 14 May 2013 01:49:12 +0000 (18:49 -0700)
committerR. Andrew Ohana <andrew.ohana@gmail.com>
Tue, 14 May 2013 03:21:21 +0000 (20:21 -0700)
Cython/Build/Dependencies.py
tests/build/build_dir.srctree

index 5e73782..2032318 100644 (file)
@@ -671,8 +671,10 @@ def cythonize(module_list, exclude=[], nthreads=0, aliases=None, quiet=False, fo
         if build_dir:
             root = os.path.realpath(os.path.abspath(find_root_package_dir(m.sources[0])))
             def copy_to_build_dir(filepath, root=root):
-                filepath = os.path.realpath(os.path.abspath(filepath))
-                if filepath.startswith(root):
+                filepath_abs = os.path.realpath(os.path.abspath(filepath))
+                if os.path.isabs(filepath):
+                    filepath = filepath_abs
+                if filepath_abs.startswith(root):
                     mod_dir = os.path.join(build_dir,
                             os.path.dirname(_relpath(filepath, root)))
                     if not os.path.isdir(mod_dir):
index 016407e..ad53eb5 100644 (file)
@@ -1,3 +1,4 @@
+PYTHON -c "import os; os.symlink('subdir', 'fake')"
 PYTHON setup.py build_ext --inplace
 PYTHON -c "import a"
 PYTHON -c "import pkg.b"
@@ -43,12 +44,16 @@ int value2 = 200;
 
 ######## pkg/b.pyx ########
 
+cdef extern from "../fake/helper.h":
+    int value2
+
 cdef extern from "pkg_helper.h":
     int value3
 
 cdef extern from "subdir/pkg_helper.h":
     int value4
 
+assert value2 == 200
 assert value3 == 300
 assert value4 == 400
 
@@ -72,5 +77,6 @@ assert not os.path.exists("a.c")
 assert os.path.exists("scratchB/pkg/b.c")
 assert os.path.exists("scratchB/pkg/pkg_helper.h")
 assert os.path.exists("scratchB/pkg/subdir/pkg_helper.h")
+assert os.path.exists("scratchB/fake/helper.h")
 assert not os.path.exists("b.c")
 assert not os.path.exists("pkg/b.c")