Skip to content
Browse files

Merge pull request #42 from mesutcank/development

Development
  • Loading branch information...
2 parents a4d6f17 + b17c9ff commit 85f93bf6ea53847facff223a26c2845f14b1ad67 @totycro totycro committed
Showing with 31 additions and 15 deletions.
  1. +19 −14 horizons/constants.py
  2. +12 −1 setup.py
View
33 horizons/constants.py
@@ -35,29 +35,34 @@
##Versioning
class VERSION:
- def _set_version():
+ def _get_git_version():
"""Function gets latest revision of the working copy.
It only works in git repositories, and is actually a hack.
"""
try:
from run_uh import find_uh_position
+
+ uh_path = find_uh_position()
+ git_head_path = os.path.join(uh_path, '.git', 'HEAD')
+ if os.path.exists(git_head_path):
+ head = open(git_head_path).readline().strip().partition(' ')
+ if head[2]:
+ head_file = os.path.join(uh_path, '.git', head[2])
+ else:
+ head_file = git_head_path
+ if os.path.exists(head_file):
+ return unicode(open(head_file).readline().strip()[0:7])
+ #if there is no .git directory then check for gitversion.txt
except ImportError:
- return u"<unknown>"
-
- uh_path = find_uh_position()
- git_head_path = os.path.join(uh_path, '.git', 'HEAD')
- if os.path.exists(git_head_path):
- head = open(git_head_path).readline().strip().partition(' ')
- if head[2]:
- head_file = os.path.join(uh_path, '.git', head[2])
- else:
- head_file = git_head_path
- if os.path.exists(head_file):
- return unicode(open(head_file).readline().strip()[0:7])
+ try:
+ return unicode(open(os.path.join("content", "gitversion.txt")).read())
+ except IOError:
+ return u"<unknown>"
+
return u"<unknown>"
RELEASE_NAME = "Unknown Horizons %s"
- RELEASE_VERSION = _set_version()
+ RELEASE_VERSION = _get_git_version()
# change for release:
IS_DEV_VERSION = True
#RELEASE_VERSION = u'2011.3'
View
13 setup.py
@@ -24,6 +24,13 @@
else:
executable_path = 'bin'
+
+#this trick is for setting RELEASE_VERSION if the code is cloned from git repository
+if os.path.exists('.git'):
+ f = open('content/gitversion.txt', 'w')
+ f.write(VERSION.RELEASE_VERSION)
+ f.close()
+
data = [
(executable_path, ('unknown-horizons', )),
('share/pixmaps', ('content/unknown-horizons.xpm', )),
@@ -196,4 +203,8 @@ def run(self):
packages=packages,
package_data=package_data,
data_files=data,
- cmdclass=cmdclass)
+ cmdclass=cmdclass)
+
+#after installation remove gitversion.txt
+if os.path.exists('.git'):
+ os.unlink('content/gitversion.txt')

0 comments on commit 85f93bf

Please sign in to comment.
Something went wrong with that request. Please try again.