Write last commit information into version.py by sdist setuptools command
to use it even if bitmessageqt runs from dist tarball.
This commit is contained in:
parent
ba846be6c1
commit
f215edc4c8
16
setup.py
16
setup.py
|
@ -5,6 +5,7 @@ import shutil
|
|||
|
||||
from setuptools import setup, Extension
|
||||
from setuptools.command.install import install
|
||||
from setuptools.command.sdist import sdist
|
||||
|
||||
from src.version import softwareVersion
|
||||
|
||||
|
@ -45,6 +46,16 @@ class InstallCmd(install):
|
|||
return install.run(self)
|
||||
|
||||
|
||||
class SdistCmd(sdist):
|
||||
def run(self):
|
||||
"""Write last commit into version.py"""
|
||||
from src.paths import lastCommit
|
||||
last_commit = lastCommit()
|
||||
with open('src/version.py', 'ab') as out:
|
||||
out.write('commit = %s' % last_commit)
|
||||
return sdist.run(self)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
with open(os.path.join(here, 'README.md')) as f:
|
||||
|
@ -146,5 +157,8 @@ if __name__ == "__main__":
|
|||
# ]
|
||||
},
|
||||
scripts=['src/pybitmessage'],
|
||||
cmdclass={'install': InstallCmd}
|
||||
cmdclass={
|
||||
'install': InstallCmd,
|
||||
'sdist': SdistCmd
|
||||
}
|
||||
)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import paths
|
||||
from datetime import datetime
|
||||
|
||||
import version
|
||||
import widgets
|
||||
from address_dialogs import (
|
||||
AddAddressDialog, NewAddressDialog, NewSubscriptionDialog,
|
||||
|
@ -8,7 +10,6 @@ from newchandialog import NewChanDialog
|
|||
from PyQt4 import QtGui
|
||||
from retranslateui import RetranslateMixin
|
||||
from tr import _translate
|
||||
from version import softwareVersion
|
||||
|
||||
|
||||
__all__ = [
|
||||
|
@ -22,22 +23,29 @@ class AboutDialog(QtGui.QDialog, RetranslateMixin):
|
|||
def __init__(self, parent=None):
|
||||
super(AboutDialog, self).__init__(parent)
|
||||
widgets.load('about.ui', self)
|
||||
last_commit = paths.lastCommit()
|
||||
version = softwareVersion
|
||||
|
||||
# Adjusting version, commit and year info
|
||||
full_version = version.softwareVersion
|
||||
try: # commit written by sdist setuptools command
|
||||
last_commit = version.commit
|
||||
except AttributeError:
|
||||
import paths
|
||||
last_commit = paths.lastCommit()
|
||||
commit = last_commit.get('commit')
|
||||
if commit:
|
||||
version += '-' + commit[:7]
|
||||
full_version += '-' + commit[:7]
|
||||
self.labelVersion.setText(
|
||||
self.labelVersion.text().replace(
|
||||
':version:', version
|
||||
).replace(':branch:', commit or 'v%s' % version)
|
||||
':version:', full_version
|
||||
).replace(':branch:', commit or 'v%s' % full_version)
|
||||
)
|
||||
self.labelVersion.setOpenExternalLinks(True)
|
||||
|
||||
try:
|
||||
try: # last copyright year from last commit
|
||||
self.label_2.setText(
|
||||
self.label_2.text().replace(
|
||||
'2017', str(last_commit.get('time').year)
|
||||
'2017',
|
||||
str(datetime.fromtimestamp(last_commit.get('time')).year)
|
||||
))
|
||||
except AttributeError:
|
||||
pass
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import os
|
||||
import re
|
||||
import sys
|
||||
from datetime import datetime
|
||||
|
||||
# When using py2exe or py2app, the variable frozen is added to the sys
|
||||
# namespace. This can be used to setup a different code path for
|
||||
|
@ -126,9 +125,9 @@ def lastCommit():
|
|||
try:
|
||||
with open(githeadfile, 'rt') as githead:
|
||||
line = tail(githead, 1)
|
||||
result['commit'] = line.split()[1]
|
||||
result['time'] = datetime.fromtimestamp(
|
||||
float(re.search(r'>\s*(.*?)\s', line).group(1))
|
||||
result.update(
|
||||
commit=line.split()[1],
|
||||
time=float(re.search(r'>\s*(.*?)\s', line).group(1))
|
||||
)
|
||||
except (IOError, AttributeError, TypeError):
|
||||
pass
|
||||
|
|
Reference in New Issue
Block a user