Commit 37ef43ae authored by Robert Bradshaw's avatar Robert Bradshaw

Merge branch 'fix_dependencies_dir' of https://github.com/jdemeyer/cython into fix_dependencies_dir

parents 70ac174e 73d9b84f
...@@ -46,8 +46,7 @@ from distutils.extension import Extension ...@@ -46,8 +46,7 @@ from distutils.extension import Extension
from .. import Utils from .. import Utils
from ..Utils import (cached_function, cached_method, path_exists, from ..Utils import (cached_function, cached_method, path_exists,
safe_makedirs, copy_file_to_dir_if_changed, find_root_package_dir, safe_makedirs, copy_file_to_dir_if_changed, is_package_dir)
is_package_dir)
from ..Compiler.Main import Context, CompilationOptions, default_options from ..Compiler.Main import Context, CompilationOptions, default_options
join_path = cached_function(os.path.join) join_path = cached_function(os.path.join)
...@@ -711,7 +710,7 @@ def create_extension_list(patterns, exclude=None, ctx=None, aliases=None, quiet= ...@@ -711,7 +710,7 @@ def create_extension_list(patterns, exclude=None, ctx=None, aliases=None, quiet=
else: else:
extra_sources = None extra_sources = None
if 'depends' in kwds: if 'depends' in kwds:
depends = resolve_depends(kwds['depends'], (kwds.get('include_dirs') or []) + [find_root_package_dir(file)]) depends = resolve_depends(kwds['depends'], (kwds.get('include_dirs') or []) + ["."])
if template is not None: if template is not None:
# Always include everything from the template. # Always include everything from the template.
depends = set(template.depends).union(depends) depends = set(template.depends).union(depends)
...@@ -790,7 +789,7 @@ def cythonize(module_list, exclude=None, nthreads=0, aliases=None, quiet=False, ...@@ -790,7 +789,7 @@ def cythonize(module_list, exclude=None, nthreads=0, aliases=None, quiet=False,
to_compile = [] to_compile = []
for m in module_list: for m in module_list:
if build_dir: if build_dir:
root = os.path.abspath(find_root_package_dir(m.sources[0])) root = os.getcwd()
def copy_to_build_dir(filepath, root=root): def copy_to_build_dir(filepath, root=root):
filepath_abs = os.path.abspath(filepath) filepath_abs = os.path.abspath(filepath)
if os.path.isabs(filepath): if os.path.isabs(filepath):
......
# Mostly the same test as build_dir.srctree but with everything inside
# a common "src" directory. We don't use --inplace and don't actually
# import the built modules.
PYTHON shutil_copy.py src/subdir src/fake
PYTHON setup.py build_ext
PYTHON check_paths.py
######## shutil_copy.py ########
import shutil, sys
shutil.copytree(sys.argv[1], sys.argv[2])
######## setup.py ########
from Cython.Build.Dependencies import cythonize
from Cython.Distutils.extension import Extension
from distutils.core import setup
ext_modules = cythonize(
Extension("a", ["src/a.pyx"]), build_dir="scratchA")
ext_modules += cythonize(
Extension("pkg.b", ["src/pkg/b.pyx"]), build_dir="scratchB")
setup(ext_modules=ext_modules)
######## src/a.pyx ########
cdef extern from "helper.h":
int value1
cdef extern from "subdir/helper.h":
int value2
cdef extern from "pkg/pkg_helper.h":
int value3
assert value1 == 100
assert value2 == 200
assert value3 == 300
######## src/helper.h ########
int value1 = 100;
######## src/subdir/helper.h ########
int value2 = 200;
######## src/pkg/__init__.py ########
######## src/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
######## src/pkg/pkg_helper.h ########
int value3 = 300;
######## src/pkg/subdir/pkg_helper.h ########
int value4 = 400;
######## check_paths.py ########
import os
assert os.path.exists("scratchA/src/a.c")
assert os.path.exists("scratchA/src/helper.h")
assert os.path.exists("scratchA/src/subdir/helper.h")
assert os.path.exists("scratchA/src/pkg/pkg_helper.h")
assert not os.path.exists("src/a.c")
assert os.path.exists("scratchB/src/pkg/b.c")
assert os.path.exists("scratchB/src/pkg/pkg_helper.h")
assert os.path.exists("scratchB/src/pkg/subdir/pkg_helper.h")
assert os.path.exists("scratchB/src/fake/helper.h")
assert not os.path.exists("src/b.c")
assert not os.path.exists("src/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