summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Kaplounenko <igor.kaplounenko@intel.com>2019-04-11 13:17:37 -0700
committerIgor Kaplounenko <igor.kaplounenko@intel.com>2019-04-11 13:17:37 -0700
commit447bf748195561d808d328964f1bb428e4cf92de (patch)
tree7d6ec9d97065a701fcd38878f5602dab6725c7de
parentcd2a42e2ce0248f0b251902707aba8b11ef7410d (diff)
downloadcython-447bf748195561d808d328964f1bb428e4cf92de.tar.gz
pyimport=True should work now on darwin without having to pre-import distutils directly or via pyxbuild
-rw-r--r--pyximport/pyximport.py3
-rw-r--r--tests/pyximport/pyximport_pyimport_slow.srctree21
2 files changed, 24 insertions, 0 deletions
diff --git a/pyximport/pyximport.py b/pyximport/pyximport.py
index 5628f301b..9e9b37c6b 100644
--- a/pyximport/pyximport.py
+++ b/pyximport/pyximport.py
@@ -351,6 +351,9 @@ class PyImporter(PyxImporter):
self.uncompilable_modules = {}
self.blocked_modules = ['Cython', 'pyxbuild', 'pyximport.pyxbuild',
'distutils.extension', 'distutils.sysconfig']
+ # on OS X, distutils appears to shadow distutils.sysconfig
+ if os.name is 'posix' and os.uname()[0].lower().startswith('darwin'):
+ self.blocked_modules.append('distutils')
def find_module(self, fullname, package_path=None):
if fullname in sys.modules:
diff --git a/tests/pyximport/pyximport_pyimport_slow.srctree b/tests/pyximport/pyximport_pyimport_slow.srctree
new file mode 100644
index 000000000..61df65ce8
--- /dev/null
+++ b/tests/pyximport/pyximport_pyimport_slow.srctree
@@ -0,0 +1,21 @@
+
+PYTHON -c "import pyimport_test; pyimport_test.test()"
+
+######## pyimport_test.py ########
+
+import os.path
+
+import pyximport
+
+
+pyximport.install(pyximport=False, pyimport=True,
+ build_dir=os.path.join(os.path.dirname(__file__), "TEST_TMP"))
+
+def test():
+ import mymodule
+ assert mymodule.test_string == "TEST"
+ assert not mymodule.__file__.rstrip('oc').endswith('.py'), mymodule.__file__
+
+######## mymodule.py ########
+
+test_string = "TEST"