diff --git a/.gitignore b/.gitignore index ed62891a..9d826720 100644 --- a/.gitignore +++ b/.gitignore @@ -137,6 +137,7 @@ pyston/ pyprover/ bbopt/ coconut-prelude/ +coconut-issue/ index.rst /coconut/icoconut/coconut/ __coconut_cache__/ diff --git a/Makefile b/Makefile index a1959766..5b680636 100644 --- a/Makefile +++ b/Makefile @@ -331,7 +331,7 @@ docs: clean .PHONY: clean-no-tests clean-no-tests: - rm -rf ./docs ./dist ./build ./bbopt ./pyprover ./pyston ./coconut-prelude index.rst ./.mypy_cache + rm -rf ./docs ./dist ./build ./bbopt ./pyprover ./pyston ./coconut-prelude ./coconut-issue index.rst ./.mypy_cache .PHONY: clean clean: clean-no-tests diff --git a/coconut/api.py b/coconut/api.py index 82f2f0bc..7f168a08 100644 --- a/coconut/api.py +++ b/coconut/api.py @@ -202,12 +202,12 @@ class CoconutImporter(object): command = None def __init__(self, *args): - self.use_cache_dir(default_use_cache_dir) self.set_args(args) + self.use_cache_dir(default_use_cache_dir) def use_cache_dir(self, use_cache_dir): """Set the cache directory if any to use for compiled Coconut files.""" - if use_cache_dir: + if use_cache_dir and "--no-cache" not in self.args: if not PY34: raise CoconutException("coconut.api.auto_compilation only supports the usage of a cache directory on Python 3.4+") self.cache_dir = coconut_cache_dir @@ -238,7 +238,10 @@ def compile(self, path, package): if package: self.cmd(path, *extra_args) - return cache_dir or path + if cache_dir: + return os.path.join(cache_dir, "__init__.py") + else: + return path else: destpath, = self.cmd(path, *extra_args) return destpath diff --git a/coconut/root.py b/coconut/root.py index 32166bbf..e6794c6c 100644 --- a/coconut/root.py +++ b/coconut/root.py @@ -26,7 +26,7 @@ VERSION = "3.1.2" VERSION_NAME = None # False for release, int >= 1 for develop -DEVELOP = 5 +DEVELOP = 6 ALPHA = False # for pre releases rather than post releases assert DEVELOP is False or DEVELOP >= 1, "DEVELOP must be False or an int >= 1" diff --git a/coconut/tests/main_test.py b/coconut/tests/main_test.py index 5c347317..8a329238 100644 --- a/coconut/tests/main_test.py +++ b/coconut/tests/main_test.py @@ -136,11 +136,13 @@ def pexpect(p, out): pyprover = os.path.join(os.curdir, "pyprover") prelude = os.path.join(os.curdir, "coconut-prelude") bbopt = os.path.join(os.curdir, "bbopt") +imp_issue_dir = os.path.join(os.curdir, "coconut-issue") pyston_git = "https://github.com/evhub/pyston.git" pyprover_git = "https://github.com/evhub/pyprover.git" prelude_git = "https://github.com/evhub/coconut-prelude" bbopt_git = "https://github.com/evhub/bbopt.git" +imp_issue_git = "https://github.com/evhub/coconut-issue.git" coconut_snip = "msg = ''; pmsg = print$(msg); `pmsg`" target_3_snip = "assert super is py_super; print('')" @@ -1117,6 +1119,13 @@ def test_pyston(self): if PYPY and PY2: run_pyston() + def test_imp_issue(self): + with using_paths(imp_issue_dir): + if not os.path.exists(imp_issue_dir): + call(["git", "clone", imp_issue_git]) + with using_env_vars({"PYTHONPATH": os.pathsep.join([imp_issue_dir, os.environ.get("PYTHONPATH", "")])}): + call_coconut(["-r", os.path.join(imp_issue_dir, "main.coco")]) + # ----------------------------------------------------------------------------------------------------------------------- # MAIN: