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