← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~mgorven/openlp/version-file into lp:openlp

 

Michael Gorven has proposed merging lp:~mgorven/openlp/version-file into lp:openlp.

    Requested reviews:
    OpenLP Core (openlp-core)


Extracts code version and revision from Bazaar and stores it in openlp/.version when setup.py is run.
-- 
https://code.launchpad.net/~mgorven/openlp/version-file/+merge/15361
Your team OpenLP Core is subscribed to branch lp:openlp.
=== added file 'MANIFEST.in'
--- MANIFEST.in	1970-01-01 00:00:00 +0000
+++ MANIFEST.in	2009-11-29 07:40:25 +0000
@@ -0,0 +1,5 @@
+recursive-include openlp *.py
+recursive-include documentation *
+include openlp/.version
+include copyright.txt
+include LICENSE

=== modified file 'openlp.pyw'
--- openlp.pyw	2009-11-13 18:29:38 +0000
+++ openlp.pyw	2009-11-29 07:40:25 +0000
@@ -73,7 +73,7 @@
         """
         #Load and store current Application Version
         filepath = os.path.split(os.path.abspath(__file__))[0]
-        filepath = os.path.abspath(os.path.join(filepath, u'version.txt'))
+        filepath = os.path.abspath(os.path.join(filepath, u'openlp', u'.version'))
         fversion = None
         try:
             fversion = open(filepath, 'r')

=== modified file 'setup.py' (properties changed: -x to +x)
--- setup.py	2009-09-08 19:58:05 +0000
+++ setup.py	2009-11-29 07:40:25 +0000
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
 
@@ -22,16 +23,65 @@
 # Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
 ###############################################################################
 
+import os
+from subprocess import Popen, PIPE
+
 from setuptools import setup
 
+VERSION_FILE = 'openlp/.version'
+
+def bzr_revision():
+    try:
+        bzr = Popen(('bzr', 'tags', '--sort', 'time'), stdout=PIPE)
+    except OSError:
+        return open(VERSION_FILE).read().strip()
+
+    output, error = bzr.communicate()
+    code = bzr.wait()
+
+    if code != 0:
+        return open(VERSION_FILE).read().strip()
+
+    lines = output.splitlines()
+    if len(lines) == 0:
+        tag = '0.0.0'
+        revision = '0'
+    else:
+        tag, revision = lines[-1].split()
+
+    bzr = Popen(('bzr', 'log', '--line', '-r', '-1'), stdout=PIPE)
+    output, error = bzr.communicate()
+    code = bzr.wait()
+
+    if code != 0:
+        raise Exception(u"Error running bzr log")
+
+    latest = output.split(':')[0]
+
+    versionstring = latest == revision and tag or '%s-bzr%s' % (tag, latest)
+
+    f = open(VERSION_FILE, 'w')
+    f.write(versionstring)
+    f.close()
+
+    return versionstring
+
 APP = ['openlp.pyw']
 OPTIONS = {'argv_emulation': True, 'includes': ['sip', 'PyQt4']}
 
+setup_requires = []
+
+if os.name == 'mac':
+    setup_requires.append('py2app')
+
 setup(
     name='openlp.org',
-    version='1.9.0',
+    version=bzr_revision(),
     url='http://www.openlp.org/',
+    packages=['openlp'],
+    include_package_data=True,
     app=APP,
     options={'py2app': OPTIONS},
-    setup_requires=['py2app'],
+    setup_requires=setup_requires,
+    scripts=['openlp.pyw', 'openlp-1to2-converter.py'],
 )

=== removed file 'version.txt'
--- version.txt	2009-11-22 14:09:26 +0000
+++ version.txt	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-1.9.0-675


Follow ups