diff options
author | malthe <devnull@localhost> | 2014-09-02 14:07:23 +0200 |
---|---|---|
committer | malthe <devnull@localhost> | 2014-09-02 14:07:23 +0200 |
commit | 29ae2bc486154245ebc2fb640b76e8eb24de72bb (patch) | |
tree | e690d6c7d016a6198bdbf6dac1a8637a2ddef83a | |
parent | 42a5c090fb54f8d29e8bad918bef18934672d3cd (diff) | |
download | cffi-29ae2bc486154245ebc2fb640b76e8eb24de72bb.tar.gz |
Add support for 'CFFI_TMPDIR' environment variable
If set, the value is used as the 'tmpdir' instead of the caller directory's
'__pycache__'.
This allows correct run-time operation when the package source is read-only.
-rw-r--r-- | cffi/verifier.py | 2 | ||||
-rw-r--r-- | doc/source/index.rst | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/cffi/verifier.py b/cffi/verifier.py index ae674de..cb4e0bb 100644 --- a/cffi/verifier.py +++ b/cffi/verifier.py @@ -42,7 +42,7 @@ class Verifier(object): modulename = '_cffi_%s_%s%s%s' % (tag, self._vengine._class_key, k1, k2) suffix = _get_so_suffixes()[0] - self.tmpdir = tmpdir or _caller_dir_pycache() + self.tmpdir = tmpdir or os.environ.get('CFFI_TMPDIR') or _caller_dir_pycache() self.sourcefilename = os.path.join(self.tmpdir, modulename + '.c') self.modulefilename = os.path.join(self.tmpdir, modulename + suffix) self.ext_package = ext_package diff --git a/doc/source/index.rst b/doc/source/index.rst index 4bce8ec..ce05f3d 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -381,7 +381,10 @@ your test suite, a call to ``cffi.verifier.cleanup_tmpdir()``. Alternatively, you can just completely remove the ``__pycache__`` directory. - +An alternative cache directory can be given as the ``tmpdir`` argument +to ``verify()``, via the environment variable ``CFFI_TMPDIR``, or by +calling ``cffi.verifier.set_tmpdir(path)`` prior to calling +``verify``. ======================================================= |