Commit e9194f7f authored by Stefan Behnel's avatar Stefan Behnel

get rid of some absolute file paths in the source files

parent 7d61c778
...@@ -32,6 +32,9 @@ Bugs fixed ...@@ -32,6 +32,9 @@ Bugs fixed
* Bazel integration failed to compile ``.py`` files. * Bazel integration failed to compile ``.py`` files.
Patch by Guro Bokum (Github issue #1784). Patch by Guro Bokum (Github issue #1784).
* Some include directories and dependencies were referenced with their absolute paths
in the generated files despite lying within the project directory.
0.26 (2017-07-19) 0.26 (2017-07-19)
================= =================
......
...@@ -76,6 +76,15 @@ else: ...@@ -76,6 +76,15 @@ else:
basestring = str basestring = str
def _make_relative(file_paths, base=None):
if not base:
base = os.getcwd()
if base[-1] != os.path.sep:
base += os.path.sep
return [_relpath(path, base) if path.startswith(base) else path
for path in file_paths]
def extended_iglob(pattern): def extended_iglob(pattern):
if '{' in pattern: if '{' in pattern:
m = re.match('(.*){([^}]+)}(.*)', pattern) m = re.match('(.*){([^}]+)}(.*)', pattern)
...@@ -617,8 +626,10 @@ class DependencyTree(object): ...@@ -617,8 +626,10 @@ class DependencyTree(object):
info = self.parse_dependencies(filename)[3] info = self.parse_dependencies(filename)[3]
kwds = info.values kwds = info.values
cimports, externs, incdirs = self.cimports_externs_incdirs(filename) cimports, externs, incdirs = self.cimports_externs_incdirs(filename)
basedir = os.getcwd()
# Add dependencies on "cdef extern from ..." files # Add dependencies on "cdef extern from ..." files
if externs: if externs:
externs = _make_relative(externs, basedir)
if 'depends' in kwds: if 'depends' in kwds:
kwds['depends'] = list(set(kwds['depends']).union(externs)) kwds['depends'] = list(set(kwds['depends']).union(externs))
else: else:
...@@ -627,7 +638,7 @@ class DependencyTree(object): ...@@ -627,7 +638,7 @@ class DependencyTree(object):
# "cdef extern from ..." files # "cdef extern from ..." files
if incdirs: if incdirs:
include_dirs = list(kwds.get('include_dirs', [])) include_dirs = list(kwds.get('include_dirs', []))
for inc in incdirs: for inc in _make_relative(incdirs, basedir):
if inc not in include_dirs: if inc not in include_dirs:
include_dirs.append(inc) include_dirs.append(inc)
kwds['include_dirs'] = include_dirs kwds['include_dirs'] = include_dirs
......
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