From 9593416237d0f4e821d42a6102242e4a70e3b16d Mon Sep 17 00:00:00 2001
From: Martin Bauer <martin.bauer@fau.de>
Date: Thu, 11 Jul 2019 17:19:33 +0200
Subject: [PATCH] Fixes in setup.py

- version has to be obtained from file when no git repo is available
  like in tar-ball distributed by pypi
---
 MANIFEST.in |  1 +
 setup.py    | 16 ++++++++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/MANIFEST.in b/MANIFEST.in
index ff301d683..f32d4f3d1 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,2 +1,3 @@
 include README.md
 include COPYING.txt
+include RELEASE-VERSION
diff --git a/setup.py b/setup.py
index 313f8f77f..be7f9bfa5 100644
--- a/setup.py
+++ b/setup.py
@@ -6,8 +6,6 @@ import distutils
 from distutils.extension import Extension
 from contextlib import redirect_stdout
 from importlib import import_module
-sys.path.insert(0, os.path.abspath('doc'))
-from version_from_git import version_number_from_git
 
 if '--use-cython' in sys.argv:
     USE_CYTHON = True
@@ -68,9 +66,19 @@ def cython_extensions(*extensions):
     return result
 
 
+try:
+    sys.path.insert(0, os.path.abspath('doc'))
+    from version_from_git import version_number_from_git
+    version=version_number_from_git()
+    with open("RELEASE-VERSION", "w") as f:
+        f.write(version)
+except ImportError:
+    version = open('RELEASE-VERSION', 'r').read()
+
+
 setup(name='pystencils',
-      version=version_number_from_git(),
       description='Speeding up stencil computations on CPUs and GPUs',
+      version=version,
       long_description=readme(),
       long_description_content_type="text/markdown",
       author='Martin Bauer',
@@ -107,5 +115,5 @@ setup(name='pystencils',
       python_requires=">=3.6",
       cmdclass={
           'quicktest': SimpleTestRunner
-      }
+      },
       )
-- 
GitLab