diff options
author | Matti Picus <matti.picus@gmail.com> | 2017-04-20 20:45:44 +0300 |
---|---|---|
committer | Matti Picus <matti.picus@gmail.com> | 2017-04-20 20:45:44 +0300 |
commit | 255710744f50377af9418dc17e5cc2844542fc5f (patch) | |
tree | 313d6008b97d5e52789a7add2bb63f2e4883b4ec | |
parent | 2d77c72582447cff2b0eed26c0c660ba378dd285 (diff) | |
download | cffi-255710744f50377af9418dc17e5cc2844542fc5f.tar.gz |
fix for importing setuptools on win32
-rw-r--r-- | cffi/ffiplatform.py | 13 | ||||
-rw-r--r-- | cffi/verifier.py | 12 |
2 files changed, 14 insertions, 11 deletions
diff --git a/cffi/ffiplatform.py b/cffi/ffiplatform.py index 27cdde0..8a4a1d1 100644 --- a/cffi/ffiplatform.py +++ b/cffi/ffiplatform.py @@ -113,3 +113,16 @@ def flatten(x): f = cStringIO.StringIO() _flatten(x, f) return f.getvalue() + +def _hack_at_distutils(): + # Windows-only workaround for some configurations: see + # https://bugs.python.org/issue23246 (Python 2.7 with + # a specific MS compiler suite download) + if sys.platform == "win32": + try: + import setuptools # for side-effects, patches distutils + except ImportError: + pass + +# this must be done before get_extension() and before compile() +_hack_at_distutils() diff --git a/cffi/verifier.py b/cffi/verifier.py index 22eb6dc..3cfeecb 100644 --- a/cffi/verifier.py +++ b/cffi/verifier.py @@ -26,16 +26,6 @@ else: s = s.encode('ascii') super(NativeIO, self).write(s) -def _hack_at_distutils(): - # Windows-only workaround for some configurations: see - # https://bugs.python.org/issue23246 (Python 2.7 with - # a specific MS compiler suite download) - if sys.platform == "win32": - try: - import setuptools # for side-effects, patches distutils - except ImportError: - pass - class Verifier(object): @@ -126,7 +116,7 @@ class Verifier(object): return basename def get_extension(self): - _hack_at_distutils() # backward compatibility hack + ffiplatform._hack_at_distutils() # backward compatibility hack if not self._has_source: with self.ffi._lock: if not self._has_source: |