Semantic Version support: py2exe & WinSparkle

* py2exe only supports Major.Minor.Patch(.Revision), so pass only
Major.Minor.Patch to it.  'File version' of generated EXEs will have
a `.0` appended as .Revision.

* Set 'product_version' in py2exe with the full version string.  This
ends up in the EXE 'Product version' property.

* WinSparkle accidentally suppoorts semver -prerelease correctly, but
not +buildmetadata.  So trim the latter off and set that as the version
for checks.
This commit is contained in:
Athanasius committed 2020-07-19 11:45:06 +01:00
1 parent 5961bb25e4
commit 560ac5f81a
3 files changed
+26 -9

No files matched your search

+1 -1
View File
@@ -8,7 +8,7 @@ from sys import platform
appname = 'EDMarketConnector'
applongname = 'E:D Market Connector'
appcmdname = 'EDMC'
appversion = '4.0.2.0'
appversion = '4.0.2'
copyright = u'© 2015-2019 Jonathan Harris, 2020 EDCD'
update_feed = 'https://raw.githubusercontent.com/EDCD/EDMarketConnector/releases/edmarketconnector.xml'
+11 -6
View File
@@ -16,6 +16,7 @@ import re
import shutil
import sys
from tempfile import gettempdir
import semantic_version
from config import appname as APPNAME, applongname as APPLONGNAME, appcmdname as APPCMDNAME, appversion as VERSION, copyright as COPYRIGHT
from config import update_feed, update_interval
@@ -30,6 +31,10 @@ elif sys.platform=='darwin':
else:
assert False, 'Unsupported platform %s' % sys.platform
# Split version, as py2exe wants the 'base' for version
semver = semantic_version.Version.coerce(VERSION)
BASEVERSION = str(semver.truncate('patch'))
if dist_dir and len(dist_dir)>1 and isdir(dist_dir):
shutil.rmtree(dist_dir)
@@ -150,13 +155,13 @@ elif sys.platform=='win32':
setup(
name = APPLONGNAME,
version = VERSION,
app = [APP],
windows = [ {'dest_base': APPNAME,
'script': APP,
'icon_resources': [(0, '%s.ico' % APPNAME)],
'company_name': 'EDCD', # WinSparkle
'product_name': APPNAME, # WinSparkle
'version': VERSION,
'company_name': 'EDCD', # WinSparkle
'product_name': APPNAME, # WinSparkle
'version': BASEVERSION,
'product_version': VERSION,
'copyright': COPYRIGHT,
'other_resources': [(24, 1, open(APPNAME+'.manifest').read())],
} ],
@@ -164,12 +169,12 @@ setup(
'script': APPCMD,
'company_name': 'EDCD',
'product_name': APPNAME,
'version': VERSION,
'version': BASEVERSION,
'product_version': VERSION,
'copyright': COPYRIGHT,
} ],
data_files = DATA_FILES,
options = OPTIONS,
setup_requires = [sys.platform=='darwin' and 'py2app' or 'py2exe'],
)
PKG = None
+14 -2
View File
@@ -91,7 +91,17 @@ elif sys.platform=='win32':
try:
sys.frozen # don't want to try updating python.exe
self.updater = ctypes.cdll.WinSparkle
self.updater.win_sparkle_set_appcast_url(update_feed.encode()) # py2exe won't let us embed this in resources
# Set the appcast URL
self.updater.win_sparkle_set_appcast_url(update_feed.encode())
# Set the appversion *without* build metadata, as WinSparkle
# doesn't do proper Semantic Version checks.
# NB: It 'accidentally' supports pre-release due to how it
# splits and compares strings:
# <https://github.com/vslavik/winsparkle/issues/214>
appversion_nobuildmetadata = appversion.split(sep='+')[0]
self.updater.win_sparkle_set_app_build_version(appversion_nobuildmetadata)
# set up shutdown callback
global root
@@ -99,9 +109,11 @@ elif sys.platform=='win32':
self.callback_t = ctypes.CFUNCTYPE(None) # keep reference
self.callback_fn = self.callback_t(shutdown_request)
self.updater.win_sparkle_set_shutdown_request_callback(self.callback_fn)
# Get WinSparkle running
self.updater.win_sparkle_init()
except:
except Exception as ex:
print_exc()
self.updater = None