Commit 65fb9d79 authored by Prakhar Goel's avatar Prakhar Goel

Fix importing of namespace packages. Add in a regtest for the same.

parent 8cab7b0a
......@@ -249,6 +249,10 @@ class PyxImporter(object):
def find_module(self, fullname, package_path=None):
if fullname in sys.modules and not pyxargs.reload_support:
return None # only here when reload()
# package_path might be a _NamespacePath. Convert that into a list...
if package_path is not None and not isinstance(package_path, list):
package_path = list(package_path)
try:
fp, pathname, (ext,mode,ty) = imp.find_module(fullname,package_path)
if fp: fp.close() # Python should offer a Default-Loader to avoid this double find/open!
......
PYTHON -c "import basic_test; basic_test.test()"
######## basic_test.py ########
import os.path
import pyximport
pyximport.install(build_dir=os.path.join(os.path.dirname(__file__), "TEST_TMP"))
def test():
import nsmod.mymodule
assert nsmod.mymodule.test_string == "TEST"
assert not nsmod.mymodule.__file__.rstrip('oc').endswith('.py'), nsmod.mymodule.__file__
######## nsmod/mymodule.pyx ########
test_string = "TEST"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment