diff --git a/setup.py b/setup.py
index 4165915e46..d1471b87f2 100644
--- a/setup.py
+++ b/setup.py
@@ -27,9 +27,10 @@ def choose_requirement(primary, secondary):
 
 
 def get_version():
+    version_dict = {}
     with open(version_file) as f:
-        exec(compile(f.read(), version_file, 'exec'))
-    return locals()['__version__']
+        exec(compile(f.read(), version_file, 'exec'), version_dict)
+    return version_dict['__version__']
 
 
 def parse_requirements(fname='requirements/runtime.txt', with_version=True):