diff options
author | Donald Stufft <donald@stufft.io> | 2013-10-06 16:34:07 -0400 |
---|---|---|
committer | Donald Stufft <donald@stufft.io> | 2013-10-06 16:34:07 -0400 |
commit | b5db81cb68bca487418f6d280f767b5e171dd434 (patch) | |
tree | a1cda3bd6ce26e16f306117f6656872b2eed9dfc /cffi/verifier.py | |
parent | f95a62857097a67c0ce080b5282ca60d806d65d1 (diff) | |
download | cffi-b5db81cb68bca487418f6d280f767b5e171dd434.tar.gz |
Fixes #110 - Support different so suffixes
Diffstat (limited to 'cffi/verifier.py')
-rw-r--r-- | cffi/verifier.py | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/cffi/verifier.py b/cffi/verifier.py index 65d9a37..0b941d4 100644 --- a/cffi/verifier.py +++ b/cffi/verifier.py @@ -31,7 +31,7 @@ class Verifier(object): k2 = k2.lstrip('0').rstrip('L') modulename = '_cffi_%s_%s%s%s' % (tag, self._vengine._class_key, k1, k2) - suffix = _get_so_suffix() + suffix = _get_so_suffixes()[0] self.tmpdir = tmpdir or _caller_dir_pycache() self.sourcefilename = os.path.join(self.tmpdir, modulename + '.c') self.modulefilename = os.path.join(self.tmpdir, modulename + suffix) @@ -103,7 +103,7 @@ class Verifier(object): else: path = None filename = self._vengine.find_module(self.get_module_name(), path, - _get_so_suffix()) + _get_so_suffixes()) if filename is None: return self.modulefilename = filename @@ -193,7 +193,7 @@ def cleanup_tmpdir(tmpdir=None, keep_so=False): if keep_so: suffix = '.c' # only remove .c files else: - suffix = _get_so_suffix().lower() + suffix = _get_so_suffixes()[0].lower() for fn in filelist: if fn.lower().startswith('_cffi_') and ( fn.lower().endswith(suffix) or fn.lower().endswith('.c')): @@ -213,15 +213,20 @@ def cleanup_tmpdir(tmpdir=None, keep_so=False): except OSError: pass -def _get_so_suffix(): +def _get_so_suffixes(): + suffixes = [] for suffix, mode, type in imp.get_suffixes(): if type == imp.C_EXTENSION: - return suffix - # bah, no C_EXTENSION available. Occurs on pypy without cpyext - if sys.platform == 'win32': - return ".pyd" - else: - return ".so" + suffixes.append(suffix) + + if not suffixes: + # bah, no C_EXTENSION available. Occurs on pypy without cpyext + if sys.platform == 'win32': + suffixes = [".pyd"] + else: + suffixes = [".so"] + + return suffixes def _ensure_dir(filename): try: |