diff --git a/doc/conf.py b/doc/conf.py
index f98186ba02b95fcb2ba3cdcc0ae4d1f183b10c5e..a2807b076f562abf8b9250f64e4ea7c16073a7b8 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -11,7 +11,8 @@
 # All configuration values have a default; values that are commented out
 # serve to show the default.
 
-#import sys, os
+#import sys
+import os
 
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
@@ -58,10 +59,12 @@ _version_source = "../loopy/version.py"
 with open(_version_source) as vpy_file:
     version_py = vpy_file.read()
 
+os.environ["AKPYTHON_EXEC_IMPORT_UNAVAILABLE"] = "1"
 exec(compile(version_py, _version_source, 'exec'), ver_dic)
 version = ".".join(str(x) for x in ver_dic["VERSION"])
 # The full version, including alpha/beta/rc tags.
 release = ver_dic["VERSION_TEXT"]
+del os.environ["AKPYTHON_EXEC_IMPORT_UNAVAILABLE"]
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/loopy/version.py b/loopy/version.py
index ee54ae05abe3e0bb4a2b95e3db7df3ffe83c9df6..2f29e806edd571fc2fc59f603337eefdfc1b2dd4 100644
--- a/loopy/version.py
+++ b/loopy/version.py
@@ -24,7 +24,7 @@ THE SOFTWARE.
 # {{{ find install- or run-time git revision
 
 import os
-if os.environ.get("AKPYTHON_EXEC_FROM_WITHIN_WITHIN_SETUP_PY") is not None:
+if os.environ.get("AKPYTHON_EXEC_IMPORT_UNAVAILABLE") is not None:
     # We're just being exec'd by setup.py. We can't import anything.
     _git_rev = None
 
diff --git a/setup.py b/setup.py
index e69fea128a82542442cde64d4860bb3f66a098b5..6c684f546041965e01eff5d283aaa20ace6e321a 100644
--- a/setup.py
+++ b/setup.py
@@ -11,7 +11,7 @@ try:
 finally:
     version_file.close()
 
-os.environ["AKPYTHON_EXEC_FROM_WITHIN_WITHIN_SETUP_PY"] = "1"
+os.environ["AKPYTHON_EXEC_IMPORT_UNAVAILABLE"] = "1"
 exec(compile(version_file_contents, "loopy/version.py", 'exec'), ver_dic)