From 01a0ad3618916401aa3d581492a12e4aaebac0a1 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 16 Apr 2013 19:48:42 +0200 Subject: [PATCH 1/4] added whitespace to avoid conflict --- openlp/core/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index f1c150989..20163ae64 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -386,7 +386,7 @@ def get_natural_key(string): # Python 3 does not support comparision of different types anymore. So make sure, that we do not compare str and int. #if string[0].isdigit(): # return [''] + key - return key + return key from applocation import AppLocation From 1b447c45904ad5e731e500e6b81c3d63d21581c6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 16 Apr 2013 19:54:40 +0200 Subject: [PATCH 2/4] reoved whitespace --- openlp/core/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 20163ae64..f1c150989 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -386,7 +386,7 @@ def get_natural_key(string): # Python 3 does not support comparision of different types anymore. So make sure, that we do not compare str and int. #if string[0].isdigit(): # return [''] + key - return key + return key from applocation import AppLocation From 1e8ad4ab7e9f628be8e58610d43fc11c77b6da41 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 16 Apr 2013 19:56:06 +0200 Subject: [PATCH 3/4] fixed setup.py --- openlp/.version | 2 +- setup.py | 51 +++++++++++++++++++++++++++---------------------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/openlp/.version b/openlp/.version index d41002840..b6e0556c1 100644 --- a/openlp/.version +++ b/openlp/.version @@ -1 +1 @@ -2.1.0-bzr2141 +2.0.1-bzr2233 \ No newline at end of file diff --git a/setup.py b/setup.py index a96259380..3bd3007b7 100755 --- a/setup.py +++ b/setup.py @@ -27,12 +27,15 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from setuptools import setup, find_packages import re +from setuptools import setup, find_packages +from subprocess import Popen, PIPE + VERSION_FILE = 'openlp/.version' SPLIT_ALPHA_DIGITS = re.compile(r'(\d+|\D+)') + def try_int(s): """ Convert string s to an integer if possible. Fail silently and return @@ -46,6 +49,7 @@ def try_int(s): except Exception: return s + def natural_sort_key(s): """ Return a tuple by which s is sorted. @@ -55,6 +59,7 @@ def natural_sort_key(s): """ return map(try_int, SPLIT_ALPHA_DIGITS.findall(s)) + def natural_compare(a, b): """ Compare two strings naturally and return the result. @@ -67,6 +72,7 @@ def natural_compare(a, b): """ return cmp(natural_sort_key(a), natural_sort_key(b)) + def natural_sort(seq, compare=natural_compare): """ Returns a copy of seq, sorted by natural string sort. @@ -77,28 +83,27 @@ def natural_sort(seq, compare=natural_compare): return temp try: - # Try to import Bazaar - from bzrlib.branch import Branch - b = Branch.open_containing('.')[0] - b.lock_read() - try: - # Get the branch's latest revision number. - revno = b.revno() - # Convert said revision number into a bzr revision id. - revision_id = b.dotted_revno_to_revision_id((revno,)) - # Get a dict of tags, with the revision id as the key. - tags = b.tags.get_reverse_tag_dict() - # Check if the latest - if revision_id in tags: - version = u'%s' % tags[revision_id][0] - else: - version = '%s-bzr%s' % \ - (natural_sort(b.tags.get_tag_dict().keys())[-1], revno) - ver_file = open(VERSION_FILE, u'w') - ver_file.write(version) - ver_file.close() - finally: - b.unlock() + bzr = Popen((u'bzr', u'tags', u'--sort', u'time'), stdout=PIPE) + output, error = bzr.communicate() + code = bzr.wait() + if code != 0: + raise Exception(u'Error running bzr tags') + lines = output.splitlines() + if not lines: + tag = u'0.0.0' + revision = u'0' + else: + tag, revision = lines[-1].split() + bzr = Popen((u'bzr', u'log', u'--line', u'-r', u'-1'), stdout=PIPE) + output, error = bzr.communicate() + code = bzr.wait() + if code != 0: + raise Exception(u'Error running bzr log') + latest = output.split(u':')[0] + version = latest == revision and tag or u'%s-bzr%s' % (tag, latest) + ver_file = open(VERSION_FILE, u'w') + ver_file.write(version) + ver_file.close() except: ver_file = open(VERSION_FILE, u'r') version = ver_file.read().strip() From 43326c5781d2f829286961d37d3c37219e806006 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 6 Jun 2013 08:40:10 +0200 Subject: [PATCH 4/4] fixed code --- openlp/.version | 2 +- openlp/core/utils/__init__.py | 41 +++++++++++++++++++----------- setup.py | 47 ++++++++++++++++++++++------------- 3 files changed, 58 insertions(+), 32 deletions(-) diff --git a/openlp/.version b/openlp/.version index b6e0556c1..3245d0c77 100644 --- a/openlp/.version +++ b/openlp/.version @@ -1 +1 @@ -2.0.1-bzr2233 \ No newline at end of file +2.1.0-bzr2234 diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index f1c150989..5c4a4466c 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -101,25 +101,38 @@ def get_application_version(): if APPLICATION_VERSION: return APPLICATION_VERSION if u'--dev-version' in sys.argv or u'-d' in sys.argv: - # If we're running the dev version, let's use bzr to get the version. - bzr = Popen((u'bzr', u'tags', u'--sort', u'time'), stdout=PIPE) + # NOTE: The following code is a duplicate of the code in setup.py. Any fix applied here should also be applied + # there. + + # Get the revision of this tree. + bzr = Popen((u'bzr', u'revno'), stdout=PIPE) + tree_revision, error = bzr.communicate() + code = bzr.wait() + if code != 0: + raise Exception(u'Error running bzr log') + + # Get all tags. + bzr = Popen((u'bzr', u'tags'), stdout=PIPE) output, error = bzr.communicate() code = bzr.wait() if code != 0: raise Exception(u'Error running bzr tags') - lines = output.splitlines() - if not lines: - tag = u'0.0.0' - revision = u'0' + tags = output.splitlines() + if not tags: + tag_version = u'0.0.0' + tag_revision = u'0' else: - tag, revision = lines[-1].split() - bzr = Popen((u'bzr', u'log', u'--line', u'-r', u'-1'), stdout=PIPE) - output, error = bzr.communicate() - code = bzr.wait() - if code != 0: - raise Exception(u'Error running bzr log') - latest = output.split(u':')[0] - full_version = latest == revision and tag or u'%s-bzr%s' % (tag, latest) + # Remove any tag that has "?" as revision number. A "?" as revision number indicates, that this tag is from + # another series. + tags = [tag for tag in tags if tag.split()[-1].strip() != u'?'] + # Get the last tag and split it in a revision and tag name. + tag_version, tag_revision = tags[-1].split() + # If they are equal, then this tree is tarball with the source for the release. We do not want the revision + # number in the full version. + if tree_revision == tag_revision: + full_version = tag_version + else: + full_version = u'%s-bzr%s' % (tag_version, tree_revision) else: # We're not running the development version, let's use the file. filepath = AppLocation.get_directory(AppLocation.VersionDir) diff --git a/setup.py b/setup.py index 3bd3007b7..c9a192591 100755 --- a/setup.py +++ b/setup.py @@ -82,37 +82,50 @@ def natural_sort(seq, compare=natural_compare): temp.sort(compare) return temp +# NOTE: The following code is a duplicate of the code in openlp/core/utils/__init__.py. Any fix applied here should also +# be applied there. try: - bzr = Popen((u'bzr', u'tags', u'--sort', u'time'), stdout=PIPE) + # Get the revision of this tree. + bzr = Popen((u'bzr', u'revno'), stdout=PIPE) + tree_revision, error = bzr.communicate() + code = bzr.wait() + if code != 0: + raise Exception(u'Error running bzr log') + + # Get all tags. + bzr = Popen((u'bzr', u'tags'), stdout=PIPE) output, error = bzr.communicate() code = bzr.wait() if code != 0: raise Exception(u'Error running bzr tags') - lines = output.splitlines() - if not lines: - tag = u'0.0.0' - revision = u'0' + tags = output.splitlines() + if not tags: + tag_version = u'0.0.0' + tag_revision = u'0' else: - tag, revision = lines[-1].split() - bzr = Popen((u'bzr', u'log', u'--line', u'-r', u'-1'), stdout=PIPE) - output, error = bzr.communicate() - code = bzr.wait() - if code != 0: - raise Exception(u'Error running bzr log') - latest = output.split(u':')[0] - version = latest == revision and tag or u'%s-bzr%s' % (tag, latest) + # Remove any tag that has "?" as revision number. A "?" as revision number indicates, that this tag is from + # another series. + tags = [tag for tag in tags if tag.split()[-1].strip() != u'?'] + # Get the last tag and split it in a revision and tag name. + tag_version, tag_revision = tags[-1].split() + # If they are equal, then this tree is tarball with the source for the release. We do not want the revision number + # in the version string. + if tree_revision == tag_revision: + version_string = tag_version + else: + version_string = u'%s-bzr%s' % (tag_version, tree_revision) ver_file = open(VERSION_FILE, u'w') - ver_file.write(version) - ver_file.close() + ver_file.write(version_string) except: ver_file = open(VERSION_FILE, u'r') - version = ver_file.read().strip() + version_string = ver_file.read().strip() +finally: ver_file.close() setup( name='OpenLP', - version=version, + version=version_string, description="Open source Church presentation and lyrics projection application.", long_description="""\ OpenLP (previously openlp.org) is free church presentation software, or lyrics projection software, used to display slides of songs, Bible verses, videos, images, and even presentations (if PowerPoint is installed) for church worship using a computer and a data projector.""",