Update version resource with pywin32 when no compiler is available

This commit is contained in:
Andy Kittner 2013-06-29 15:15:32 +02:00
parent 5ba09ddb93
commit 2b4602068b
2 changed files with 51 additions and 3 deletions

View File

@ -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 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 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 in the 'dist' directory

41
extras/win32-portable/prepare_portable.py Normal file → Executable file
View File

@ -349,6 +349,46 @@ def compile_openslides_launcher():
return True 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): def copy_dlls(odir):
dll_src = os.path.join(sys.exec_prefix, "DLLs") dll_src = os.path.join(sys.exec_prefix, "DLLs")
dll_dest = os.path.join(odir, "DLLs") dll_dest = os.path.join(odir, "DLLs")
@ -443,6 +483,7 @@ def main():
if not compile_openslides_launcher(): if not compile_openslides_launcher():
sys.stdout.write("Using prebuild openslides.exe\n") sys.stdout.write("Using prebuild openslides.exe\n")
openslides_launcher_update_version_resource()
shutil.copyfile( shutil.copyfile(
"extras/win32-portable/openslides.exe", "extras/win32-portable/openslides.exe",