From 2b4602068b1fad9e6aaf52d2b21452e0b41ed086 Mon Sep 17 00:00:00 2001 From: Andy Kittner Date: Sat, 29 Jun 2013 15:15:32 +0200 Subject: [PATCH] Update version resource with pywin32 when no compiler is available --- extras/win32-portable/create_portable.txt | 11 ++++-- extras/win32-portable/prepare_portable.py | 43 ++++++++++++++++++++++- 2 files changed, 51 insertions(+), 3 deletions(-) mode change 100644 => 100755 extras/win32-portable/prepare_portable.py diff --git a/extras/win32-portable/create_portable.txt b/extras/win32-portable/create_portable.txt index 4cad67913..dda2949a4 100644 --- a/extras/win32-portable/create_portable.txt +++ b/extras/win32-portable/create_portable.txt @@ -6,11 +6,18 @@ How to create a new portable Windows distribution of OpenSlides: easy_install -Z django django-mptt beautifulsoup4 bleach pillow qrcode reportlab tornado -2.) Run in the main directory of the OpenSlides checkout: +2.) To update the version resource of the prebuild openslides.exe + pywin32 should be installed (it is not strictly required but at + least for releases that are to be published it is highly advisable) + + To install it just grab the binary installer from: + http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32-218.win32-py2.7.exe/download + +3.) Run in the main directory of the OpenSlides checkout: python extras\win32-portable\prepare_portable.py -3.) The portable OpenSlides distribution is now ready as a zip archive +4.) The portable OpenSlides distribution is now ready as a zip archive in the 'dist' directory diff --git a/extras/win32-portable/prepare_portable.py b/extras/win32-portable/prepare_portable.py old mode 100644 new mode 100755 index 41d81c9e1..593e5b051 --- a/extras/win32-portable/prepare_portable.py +++ b/extras/win32-portable/prepare_portable.py @@ -344,11 +344,51 @@ def compile_openslides_launcher(): cc.link_executable( objs, "extras/win32-portable/openslides", extra_preargs=["/subsystem:windows", "/nodefaultlib:python27.lib"], - libraries = ["user32"] + libraries=["user32"] ) return True +def openslides_launcher_update_version_resource(): + try: + import win32api + import win32verstamp + except ImportError: + sys.stderr.write( + "Using precompiled executable and pywin32 is not available - " + "version resource may be out of date!\n") + return False + import struct + + sys.stdout.write("Updating version resource") + # code based on win32verstamp.stamp() with some minor differences in + # version handling + major, minor, sub = openslides.VERSION[:3] + build = openslides.VERSION[4] + pre_release = openslides.VERSION[3] != "final" + version_str = openslides.get_version() + + sdata = { + "CompanyName": "OpenSlides team", + "FileDescription": "OpenSlides", + "FileVersion": version_str, + "InternalName": "OpenSlides", + "LegalCopyright": u"Copyright \xa9 2011-2013", + "OriginalFilename": "openslides.exe", + "ProductName": "OpenSlides", + "ProductVersion": version_str, + } + vdata = { + "Translation": struct.pack("hh", 0x409, 0x4e4), + } + + vs = win32verstamp.VS_VERSION_INFO( + major, minor, sub, build, sdata, vdata, pre_release, False) + h = win32api.BeginUpdateResource("extras/win32-portable/openslides.exe", 0) + win32api.UpdateResource(h, 16, 1, vs) + win32api.EndUpdateResource(h, 0) + + def copy_dlls(odir): dll_src = os.path.join(sys.exec_prefix, "DLLs") dll_dest = os.path.join(odir, "DLLs") @@ -443,6 +483,7 @@ def main(): if not compile_openslides_launcher(): sys.stdout.write("Using prebuild openslides.exe\n") + openslides_launcher_update_version_resource() shutil.copyfile( "extras/win32-portable/openslides.exe",