forked from openlp/openlp
Removed some code not compatible with python 3 to help with the migration
bzr-revno: 2251
This commit is contained in:
commit
df493947e7
@ -1 +1 @@
|
|||||||
2.1.0-bzr2141
|
2.1.0-bzr2234
|
||||||
|
@ -101,46 +101,38 @@ def get_application_version():
|
|||||||
if APPLICATION_VERSION:
|
if APPLICATION_VERSION:
|
||||||
return APPLICATION_VERSION
|
return APPLICATION_VERSION
|
||||||
if u'--dev-version' in sys.argv or u'-d' in sys.argv:
|
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.
|
# NOTE: The following code is a duplicate of the code in setup.py. Any fix applied here should also be applied
|
||||||
try:
|
# there.
|
||||||
# If bzrlib is available, use it.
|
|
||||||
from bzrlib.branch import Branch
|
# Get the revision of this tree.
|
||||||
b = Branch.open_containing('.')[0]
|
bzr = Popen((u'bzr', u'revno'), stdout=PIPE)
|
||||||
b.lock_read()
|
tree_revision, error = bzr.communicate()
|
||||||
try:
|
code = bzr.wait()
|
||||||
# Get the branch's latest revision number.
|
if code != 0:
|
||||||
revno = b.revno()
|
raise Exception(u'Error running bzr log')
|
||||||
# Convert said revision number into a bzr revision id.
|
|
||||||
revision_id = b.dotted_revno_to_revision_id((revno,))
|
# Get all tags.
|
||||||
# Get a dict of tags, with the revision id as the key.
|
bzr = Popen((u'bzr', u'tags'), stdout=PIPE)
|
||||||
tags = b.tags.get_reverse_tag_dict()
|
output, error = bzr.communicate()
|
||||||
# Check if the latest
|
code = bzr.wait()
|
||||||
if revision_id in tags:
|
if code != 0:
|
||||||
full_version = u'%s' % tags[revision_id][0]
|
raise Exception(u'Error running bzr tags')
|
||||||
else:
|
tags = output.splitlines()
|
||||||
full_version = '%s-bzr%s' % (sorted(b.tags.get_tag_dict().keys())[-1], revno)
|
if not tags:
|
||||||
finally:
|
tag_version = u'0.0.0'
|
||||||
b.unlock()
|
tag_revision = u'0'
|
||||||
except:
|
else:
|
||||||
# Otherwise run the command line bzr client.
|
# Remove any tag that has "?" as revision number. A "?" as revision number indicates, that this tag is from
|
||||||
bzr = Popen((u'bzr', u'tags', u'--sort', u'time'), stdout=PIPE)
|
# another series.
|
||||||
output, error = bzr.communicate()
|
tags = [tag for tag in tags if tag.split()[-1].strip() != u'?']
|
||||||
code = bzr.wait()
|
# Get the last tag and split it in a revision and tag name.
|
||||||
if code != 0:
|
tag_version, tag_revision = tags[-1].split()
|
||||||
raise Exception(u'Error running bzr tags')
|
# If they are equal, then this tree is tarball with the source for the release. We do not want the revision
|
||||||
lines = output.splitlines()
|
# number in the full version.
|
||||||
if not lines:
|
if tree_revision == tag_revision:
|
||||||
tag = u'0.0.0'
|
full_version = tag_version
|
||||||
revision = u'0'
|
else:
|
||||||
else:
|
full_version = u'%s-bzr%s' % (tag_version, tree_revision)
|
||||||
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)
|
|
||||||
else:
|
else:
|
||||||
# We're not running the development version, let's use the file.
|
# We're not running the development version, let's use the file.
|
||||||
filepath = AppLocation.get_directory(AppLocation.VersionDir)
|
filepath = AppLocation.get_directory(AppLocation.VersionDir)
|
||||||
|
68
setup.py
68
setup.py
@ -27,12 +27,15 @@
|
|||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
from setuptools import setup, find_packages
|
|
||||||
import re
|
import re
|
||||||
|
from setuptools import setup, find_packages
|
||||||
|
from subprocess import Popen, PIPE
|
||||||
|
|
||||||
|
|
||||||
VERSION_FILE = 'openlp/.version'
|
VERSION_FILE = 'openlp/.version'
|
||||||
SPLIT_ALPHA_DIGITS = re.compile(r'(\d+|\D+)')
|
SPLIT_ALPHA_DIGITS = re.compile(r'(\d+|\D+)')
|
||||||
|
|
||||||
|
|
||||||
def try_int(s):
|
def try_int(s):
|
||||||
"""
|
"""
|
||||||
Convert string s to an integer if possible. Fail silently and return
|
Convert string s to an integer if possible. Fail silently and return
|
||||||
@ -46,6 +49,7 @@ def try_int(s):
|
|||||||
except Exception:
|
except Exception:
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
def natural_sort_key(s):
|
def natural_sort_key(s):
|
||||||
"""
|
"""
|
||||||
Return a tuple by which s is sorted.
|
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))
|
return map(try_int, SPLIT_ALPHA_DIGITS.findall(s))
|
||||||
|
|
||||||
|
|
||||||
def natural_compare(a, b):
|
def natural_compare(a, b):
|
||||||
"""
|
"""
|
||||||
Compare two strings naturally and return the result.
|
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))
|
return cmp(natural_sort_key(a), natural_sort_key(b))
|
||||||
|
|
||||||
|
|
||||||
def natural_sort(seq, compare=natural_compare):
|
def natural_sort(seq, compare=natural_compare):
|
||||||
"""
|
"""
|
||||||
Returns a copy of seq, sorted by natural string sort.
|
Returns a copy of seq, sorted by natural string sort.
|
||||||
@ -76,38 +82,50 @@ def natural_sort(seq, compare=natural_compare):
|
|||||||
temp.sort(compare)
|
temp.sort(compare)
|
||||||
return temp
|
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:
|
try:
|
||||||
# Try to import Bazaar
|
# Get the revision of this tree.
|
||||||
from bzrlib.branch import Branch
|
bzr = Popen((u'bzr', u'revno'), stdout=PIPE)
|
||||||
b = Branch.open_containing('.')[0]
|
tree_revision, error = bzr.communicate()
|
||||||
b.lock_read()
|
code = bzr.wait()
|
||||||
try:
|
if code != 0:
|
||||||
# Get the branch's latest revision number.
|
raise Exception(u'Error running bzr log')
|
||||||
revno = b.revno()
|
|
||||||
# Convert said revision number into a bzr revision id.
|
# Get all tags.
|
||||||
revision_id = b.dotted_revno_to_revision_id((revno,))
|
bzr = Popen((u'bzr', u'tags'), stdout=PIPE)
|
||||||
# Get a dict of tags, with the revision id as the key.
|
output, error = bzr.communicate()
|
||||||
tags = b.tags.get_reverse_tag_dict()
|
code = bzr.wait()
|
||||||
# Check if the latest
|
if code != 0:
|
||||||
if revision_id in tags:
|
raise Exception(u'Error running bzr tags')
|
||||||
version = u'%s' % tags[revision_id][0]
|
tags = output.splitlines()
|
||||||
else:
|
if not tags:
|
||||||
version = '%s-bzr%s' % \
|
tag_version = u'0.0.0'
|
||||||
(natural_sort(b.tags.get_tag_dict().keys())[-1], revno)
|
tag_revision = u'0'
|
||||||
ver_file = open(VERSION_FILE, u'w')
|
else:
|
||||||
ver_file.write(version)
|
# Remove any tag that has "?" as revision number. A "?" as revision number indicates, that this tag is from
|
||||||
ver_file.close()
|
# another series.
|
||||||
finally:
|
tags = [tag for tag in tags if tag.split()[-1].strip() != u'?']
|
||||||
b.unlock()
|
# 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_string)
|
||||||
except:
|
except:
|
||||||
ver_file = open(VERSION_FILE, u'r')
|
ver_file = open(VERSION_FILE, u'r')
|
||||||
version = ver_file.read().strip()
|
version_string = ver_file.read().strip()
|
||||||
|
finally:
|
||||||
ver_file.close()
|
ver_file.close()
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='OpenLP',
|
name='OpenLP',
|
||||||
version=version,
|
version=version_string,
|
||||||
description="Open source Church presentation and lyrics projection application.",
|
description="Open source Church presentation and lyrics projection application.",
|
||||||
long_description="""\
|
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.""",
|
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.""",
|
||||||
|
Loading…
Reference in New Issue
Block a user