diff options
author | Armin Rigo <arigo@tunes.org> | 2016-04-21 13:14:43 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2016-04-21 13:14:43 +0200 |
commit | 31f484a4719868f32a40ee72cb8b4a8a2f8f7ae3 (patch) | |
tree | c4aadf1f096bea2e1524625257e3d6fcd4be13e0 | |
parent | 79d0a6ae494118eaaeecade49e356ba49ee11a3c (diff) | |
download | cffi-31f484a4719868f32a40ee72cb8b4a8a2f8f7ae3.tar.gz |
Re-add this hack, removed in 51f1337c9b4c; but this time only in tests
-rw-r--r-- | testing/cffi1/test_zdist.py | 8 | ||||
-rw-r--r-- | testing/embedding/test_basic.py | 17 | ||||
-rw-r--r-- | testing/udir.py | 10 |
3 files changed, 33 insertions, 2 deletions
diff --git a/testing/cffi1/test_zdist.py b/testing/cffi1/test_zdist.py index 6e28cf9..c559fbb 100644 --- a/testing/cffi1/test_zdist.py +++ b/testing/cffi1/test_zdist.py @@ -279,6 +279,14 @@ class TestDist(object): pass with open("setup.py", "w") as f: f.write("""if 1: + # https://bugs.python.org/issue23246 + import sys + if sys.platform == 'win32': + try: + import setuptools + except ImportError: + pass + import cffi ffi = cffi.FFI() ffi.set_source("pack1.mymod", "/*code would be here*/") diff --git a/testing/embedding/test_basic.py b/testing/embedding/test_basic.py index 7e88bc1..4b7f3a4 100644 --- a/testing/embedding/test_basic.py +++ b/testing/embedding/test_basic.py @@ -79,8 +79,21 @@ class EmbeddingTests: # find a solution to that: we could hack sys.path inside the # script run here, but we can't hack it in the same way in # execute(). - output = self._run([sys.executable, - os.path.join(local_dir, filename)]) + pathname = os.path.join(path, filename) + with open(pathname, 'w') as g: + g.write(''' +# https://bugs.python.org/issue23246 +import sys +if sys.platform == 'win32': + try: + import setuptools + except ImportError: + pass +''') + with open(os.path.join(local_dir, filename), 'r') as f: + g.write(f.read()) + + output = self._run([sys.executable, pathname]) match = re.compile(r"\bFILENAME: (.+)").search(output) assert match dynamic_lib_name = match.group(1) diff --git a/testing/udir.py b/testing/udir.py index f202dfa..4dd0a11 100644 --- a/testing/udir.py +++ b/testing/udir.py @@ -1,3 +1,13 @@ import py +import sys udir = py.path.local.make_numbered_dir(prefix = 'ffi-') + + +# Windows-only workaround for some configurations: see +# https://bugs.python.org/issue23246 (Python 2.7.9) +if sys.platform == 'win32': + try: + import setuptools + except ImportError: + pass |