From d0a6060b975540dedc0f455f49ea4357da479eec Mon Sep 17 00:00:00 2001
From: Dilawar Singh <dilawars@ncbs.res.in>
Date: Mon, 14 Nov 2016 18:31:10 +0530
Subject: [PATCH] Squashed 'moose-core/' changes from 9eeca0c..6a6bcc1

6a6bcc1 Python module can also use VERSION file generated by CMAKE. Copy to build directory for not-in-source builds. BhallaLab/moose#200.
7805364 Failsafe mechanism in VERSION reading script.

git-subtree-dir: moose-core
git-subtree-split: 6a6bcc15556a58e08c24203599c3c84837eb65bd
---
 CMakeLists.txt         | 1 +
 VERSION                | 2 +-
 pymoose/CMakeLists.txt | 8 +++++---
 python/setup.py        | 9 +++++++--
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51a2009e..93810552 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -474,6 +474,7 @@ install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/moose
     DESTINATION bin
     )
 
+# This target is built by pymoose/CMakeLists.txt file.
 if(WITH_PYTHON)
     install(CODE 
         "
diff --git a/VERSION b/VERSION
index 264e8628..819720a6 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.1.0-121-g14cf2df
\ No newline at end of file
+3.1.0-123-g7805364
\ No newline at end of file
diff --git a/pymoose/CMakeLists.txt b/pymoose/CMakeLists.txt
index bb369b44..83397de4 100644
--- a/pymoose/CMakeLists.txt
+++ b/pymoose/CMakeLists.txt
@@ -82,9 +82,11 @@ endif(MACOSX)
 # Make this target dependant on all python files in python folder.
 add_custom_target(copy_python_files ALL
     COMMAND ${CMAKE_COMMAND} -E copy_directory
-    ${CMAKE_SOURCE_DIR}/python
-    ${CMAKE_BINARY_DIR}/python
-    COMMENT "Copying python files to build directory"
+        ${CMAKE_SOURCE_DIR}/python ${CMAKE_BINARY_DIR}/python
+    COMMAND ${CMAKE_COMMAND} -E copy 
+        ${CMAKE_SOURCE_DIR}/VERSION ${CMAKE_BINARY_DIR}/VERSION 
+    COMMENT "Copying required python files and other files to build directory"
     VERBATIM
     )
+
 add_dependencies(_moose copy_python_files)
diff --git a/python/setup.py b/python/setup.py
index 58250433..47b5f3aa 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -33,8 +33,13 @@ from distutils.core import setup
 
 script_dir = os.path.dirname( os.path.abspath( __file__ ) )
 
-with open( os.path.join( script_dir, '../../VERSION'), 'r' ) as f:
-    version = f.read( )
+version = '3.1'
+try:
+    with open( os.path.join( script_dir, '..', 'VERSION'), 'r' ) as f:
+        version = f.read( )
+except Exception as e:
+    print( 'Failed to read VERSION %s' % e )
+    print( 'Using default 3.1' )
 
 try:
     import importlib.machinery
-- 
GitLab