summaryrefslogtreecommitdiff
path: root/cffi
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2014-12-24 16:52:20 +0100
committerArmin Rigo <arigo@tunes.org>2014-12-24 16:52:20 +0100
commit6702c9e427a6219c9ef435baf8c9e2f7f180e70e (patch)
tree1ebe393e99ab7dc480945245b52fc3651834ace4 /cffi
parentc46d5bc472a4710d116a2b7a7f15d107114e7d3b (diff)
downloadcffi-6702c9e427a6219c9ef435baf8c9e2f7f180e70e.tar.gz
Add the keyword "relative_to=..." to verify(), as per
https://bitbucket.org/cffi/cffi/pull-request/53
Diffstat (limited to 'cffi')
-rw-r--r--cffi/ffiplatform.py3
-rw-r--r--cffi/verifier.py18
2 files changed, 19 insertions, 2 deletions
diff --git a/cffi/ffiplatform.py b/cffi/ffiplatform.py
index 4515d6c..c6e70d3 100644
--- a/cffi/ffiplatform.py
+++ b/cffi/ffiplatform.py
@@ -11,6 +11,9 @@ class VerificationMissing(Exception):
"""
+LIST_OF_FILE_NAMES = ['include_dirs', 'library_dirs',
+ 'extra_objects', 'depends']
+
def get_extension(srcfilename, modname, sources=(), **kwds):
from distutils.core import Extension
allsources = [srcfilename]
diff --git a/cffi/verifier.py b/cffi/verifier.py
index 5d99e12..64fef77 100644
--- a/cffi/verifier.py
+++ b/cffi/verifier.py
@@ -17,7 +17,7 @@ class Verifier(object):
def __init__(self, ffi, preamble, tmpdir=None, modulename=None,
ext_package=None, tag='', force_generic_engine=False,
- source_extension='.c', flags=None, **kwds):
+ source_extension='.c', flags=None, relative_to=None, **kwds):
self.ffi = ffi
self.preamble = preamble
if not modulename:
@@ -26,7 +26,7 @@ class Verifier(object):
self._vengine = vengine_class(self)
self._vengine.patch_extension_kwds(kwds)
self.flags = flags
- self.kwds = kwds
+ self.kwds = self.make_relative_to(kwds, relative_to)
#
if modulename:
if tag:
@@ -109,6 +109,20 @@ class Verifier(object):
def generates_python_module(self):
return self._vengine._gen_python_module
+ def make_relative_to(self, kwds, relative_to):
+ if relative_to and os.path.dirname(relative_to):
+ dirname = os.path.dirname(relative_to)
+ kwds = kwds.copy()
+ for key in ffiplatform.LIST_OF_FILE_NAMES:
+ if key in kwds:
+ lst = kwds[key]
+ if not isinstance(lst, (list, tuple)):
+ raise TypeError("keyword '%s' should be a list or tuple"
+ % (key,))
+ lst = [os.path.join(dirname, fn) for fn in lst]
+ kwds[key] = lst
+ return kwds
+
# ----------
def _locate_module(self):