Commit 7a98c70e authored by Robert Bradshaw's avatar Robert Bradshaw

Merge pull request #226 from ohanar/build_dir

fix build_dir copying
parents b2bd583d 657de8b7
......@@ -671,10 +671,12 @@ 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.abspath(filepath)
if os.path.realpath(filepath).startswith(root):
mod_dir = os.path.join(
build_dir, os.path.dirname(_relpath(filepath)))
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):
os.makedirs(mod_dir)
shutil.copy(filepath, mod_dir)
......
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")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment