2012-04-25 22:36:09 +02:00
|
|
|
|
#!/usr/bin/env python
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
"""
|
2013-10-20 02:04:27 +02:00
|
|
|
|
:copyright: 2012–2013 by OpenSlides team, see AUTHORS.
|
2012-04-25 22:36:09 +02:00
|
|
|
|
:license: GNU GPL, see LICENSE for more details.
|
|
|
|
|
"""
|
|
|
|
|
|
2012-04-15 16:04:08 +02:00
|
|
|
|
import errno
|
|
|
|
|
import glob
|
|
|
|
|
import os
|
|
|
|
|
import re
|
|
|
|
|
import shutil
|
|
|
|
|
import sys
|
|
|
|
|
import zlib
|
|
|
|
|
zlib.Z_DEFAULT_COMPRESSION = zlib.Z_BEST_COMPRESSION
|
|
|
|
|
import zipfile
|
|
|
|
|
|
|
|
|
|
import distutils.ccompiler
|
|
|
|
|
import distutils.sysconfig
|
|
|
|
|
|
|
|
|
|
import pkg_resources
|
|
|
|
|
|
2013-02-09 21:03:00 +01:00
|
|
|
|
import wx
|
|
|
|
|
|
2012-04-15 16:04:08 +02:00
|
|
|
|
sys.path.insert(0, os.getcwd())
|
2013-02-09 21:03:00 +01:00
|
|
|
|
sys.path.insert(1, os.path.join(os.getcwd(), "extras"))
|
2012-04-15 16:04:08 +02:00
|
|
|
|
import openslides
|
2013-02-09 21:03:00 +01:00
|
|
|
|
import openslides_gui
|
2012-04-15 16:04:08 +02:00
|
|
|
|
|
|
|
|
|
COMMON_EXCLUDE = [
|
|
|
|
|
r".pyc$",
|
|
|
|
|
r".pyo$",
|
|
|
|
|
r".po$",
|
|
|
|
|
r".egg-info",
|
2013-04-09 21:13:44 +02:00
|
|
|
|
r"\blocale/(?!de/|en/|fr/)[^/]+/"
|
2012-04-15 16:04:08 +02:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
LIBEXCLUDE = [
|
|
|
|
|
r"^site-packages/",
|
|
|
|
|
r"^test/",
|
|
|
|
|
r"^curses/",
|
|
|
|
|
r"^idlelib/",
|
|
|
|
|
r"^lib2to3/",
|
|
|
|
|
r"^lib-tk/",
|
|
|
|
|
r"^msilib/",
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SITE_PACKAGES = {
|
|
|
|
|
"django": {
|
|
|
|
|
"copy": ["django"],
|
|
|
|
|
"exclude": [
|
2013-04-09 21:13:44 +02:00
|
|
|
|
r"^django/contrib/admindocs/",
|
|
|
|
|
r"^django/contrib/comments/",
|
|
|
|
|
r"^django/contrib/databrowse/",
|
|
|
|
|
r"^django/contrib/flatpages/",
|
|
|
|
|
r"^django/contrib/formtools/",
|
|
|
|
|
r"^django/contrib/gis/",
|
|
|
|
|
r"^django/contrib/localflavor/",
|
|
|
|
|
r"^django/contrib/markup/",
|
|
|
|
|
r"^django/contrib/redirects/",
|
|
|
|
|
r"^django/contrib/sitemaps/",
|
|
|
|
|
r"^django/contrib/syndication/",
|
|
|
|
|
r"^django/contrib/webdesign/",
|
2012-04-15 16:04:08 +02:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"django-mptt": {
|
|
|
|
|
"copy": ["mptt"],
|
|
|
|
|
},
|
|
|
|
|
"reportlab": {
|
|
|
|
|
"copy": [
|
|
|
|
|
"reportlab",
|
|
|
|
|
"_renderPM.pyd",
|
|
|
|
|
"_rl_accel.pyd",
|
|
|
|
|
"pyHnj.pyd",
|
2013-04-09 21:13:44 +02:00
|
|
|
|
"sgmlop.pyd",
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
"pillow": {
|
2013-10-23 20:20:02 +02:00
|
|
|
|
"copy": ["PIL"],
|
2012-04-15 16:04:08 +02:00
|
|
|
|
},
|
2013-04-09 21:13:44 +02:00
|
|
|
|
"tornado": {
|
|
|
|
|
"copy": ["tornado"],
|
|
|
|
|
},
|
2013-04-07 19:46:28 +02:00
|
|
|
|
"beautifulsoup4": {
|
|
|
|
|
"copy": ["bs4"],
|
|
|
|
|
},
|
|
|
|
|
"bleach": {
|
|
|
|
|
"copy": ["bleach"],
|
|
|
|
|
},
|
|
|
|
|
"html5lib": {
|
|
|
|
|
"copy": ["html5lib"],
|
2013-02-09 21:03:00 +01:00
|
|
|
|
},
|
2013-09-08 14:44:41 +02:00
|
|
|
|
"django-haystack": {
|
|
|
|
|
"copy": ["haystack"],
|
|
|
|
|
},
|
|
|
|
|
"whoosh": {
|
|
|
|
|
"copy": ["whoosh"],
|
|
|
|
|
},
|
2013-02-09 21:03:00 +01:00
|
|
|
|
"wx": {
|
|
|
|
|
# NOTE: wxpython is a special case, see copy_wx
|
|
|
|
|
"copy": [],
|
|
|
|
|
"exclude": [
|
|
|
|
|
r"^wx/tools/",
|
|
|
|
|
r"^wx/py/",
|
|
|
|
|
r"^wx/build/",
|
|
|
|
|
r"^wx/lib/",
|
|
|
|
|
r"wx/_activex.pyd",
|
|
|
|
|
r"wx/_animate.pyd",
|
|
|
|
|
r"wx/_aui.pyd",
|
|
|
|
|
r"wx/_calendar.pyd",
|
|
|
|
|
r"wx/_combo.pyd",
|
|
|
|
|
r"wx/_gizmos.pyd",
|
|
|
|
|
r"wx/_glcanvas.pyd",
|
|
|
|
|
r"wx/_grid.pyd",
|
|
|
|
|
r"wx/_html.pyd",
|
|
|
|
|
r"wx/_media.pyd",
|
|
|
|
|
r"wx/_richtext.pyd",
|
|
|
|
|
r"wx/_stc.pyd",
|
|
|
|
|
r"wx/_webkit.pyd",
|
|
|
|
|
r"wx/_wizard.pyd",
|
|
|
|
|
r"wx/_xrc.pyd",
|
|
|
|
|
r"wx/gdiplus.dll",
|
|
|
|
|
r"wx/wxbase28uh_xml_vc.dll",
|
|
|
|
|
r"wx/wxmsw28uh_aui_vc.dll",
|
|
|
|
|
r"wx/wxmsw28uh_gizmos_vc.dll",
|
|
|
|
|
r"wx/wxmsw28uh_gizmos_xrc_vc.dll",
|
|
|
|
|
r"wx/wxmsw28uh_gl_vc.dll",
|
|
|
|
|
r"wx/wxmsw28uh_media_vc.dll",
|
|
|
|
|
r"wx/wxmsw28uh_qa_vc.dll",
|
|
|
|
|
r"wx/wxmsw28uh_richtext_vc.dll",
|
|
|
|
|
r"wx/wxmsw28uh_stc_vc.dll",
|
|
|
|
|
r"wx/wxmsw28uh_xrc_vc.dll",
|
|
|
|
|
],
|
|
|
|
|
},
|
2012-04-15 16:04:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PY_DLLS = [
|
|
|
|
|
"unicodedata.pyd",
|
|
|
|
|
"sqlite3.dll",
|
|
|
|
|
"_sqlite3.pyd",
|
|
|
|
|
"_socket.pyd",
|
|
|
|
|
"select.pyd",
|
2012-11-24 14:53:08 +01:00
|
|
|
|
"_ctypes.pyd",
|
2013-04-09 21:13:44 +02:00
|
|
|
|
"_ssl.pyd",
|
|
|
|
|
"_multiprocessing.pyd",
|
|
|
|
|
"pyexpat.pyd",
|
2012-04-15 16:04:08 +02:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
MSVCR_PUBLIC_KEY = "1fc8b3b9a1e18e3b"
|
|
|
|
|
MSVCR_VERSION = "9.0.21022.8"
|
|
|
|
|
MSVCR_NAME = "Microsoft.VC90.CRT"
|
|
|
|
|
|
2013-02-09 21:03:00 +01:00
|
|
|
|
OPENSLIDES_RC_TMPL = """
|
|
|
|
|
#include <winresrc.h>
|
|
|
|
|
|
|
|
|
|
#define ID_ICO_OPENSLIDES 1
|
|
|
|
|
|
|
|
|
|
ID_ICO_OPENSLIDES ICON "openslides.ico"
|
|
|
|
|
|
|
|
|
|
VS_VERSION_INFO VERSIONINFO
|
|
|
|
|
FILEVERSION {version[0]},{version[1]},{version[2]},{version[4]}
|
|
|
|
|
PRODUCTVERSION {version[0]},{version[1]},{version[2]},{version[4]}
|
|
|
|
|
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
|
|
|
|
FILEFLAGS {file_flags}
|
|
|
|
|
FILEOS VOS__WINDOWS32
|
|
|
|
|
FILETYPE VFT_APP
|
|
|
|
|
FILESUBTYPE VFT2_UNKNOWN
|
|
|
|
|
|
|
|
|
|
BEGIN
|
|
|
|
|
BLOCK "StringFileInfo"
|
|
|
|
|
BEGIN
|
|
|
|
|
BLOCK "040904E4"
|
|
|
|
|
BEGIN
|
|
|
|
|
VALUE "CompanyName", "OpenSlides team\\0"
|
|
|
|
|
VALUE "FileDescription", "OpenSlides\\0"
|
|
|
|
|
VALUE "FileVersion", "{version_str}\\0"
|
|
|
|
|
VALUE "InternalName", "OpenSlides\\0"
|
|
|
|
|
VALUE "LegalCopyright", "Copyright \\251 2011-2013\\0"
|
|
|
|
|
VALUE "OriginalFilename", "openslides.exe\\0"
|
|
|
|
|
VALUE "ProductName", "OpenSlides\\0"
|
|
|
|
|
VALUE "ProductVersion", "{version_str}\\0"
|
|
|
|
|
END
|
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
BLOCK "VarFileInfo"
|
|
|
|
|
BEGIN
|
|
|
|
|
VALUE "Translation", 0x409, 0x4E4
|
|
|
|
|
END
|
|
|
|
|
END
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
2012-04-15 16:04:08 +02:00
|
|
|
|
def compile_re_list(patterns):
|
|
|
|
|
expr = "|".join("(?:{0})".format(x) for x in patterns)
|
|
|
|
|
return re.compile(expr)
|
|
|
|
|
|
2013-02-09 21:03:00 +01:00
|
|
|
|
|
|
|
|
|
def relpath(base, path, addslash=False):
|
2012-04-15 16:04:08 +02:00
|
|
|
|
b = os.path.normpath(os.path.abspath(base))
|
|
|
|
|
p = os.path.normpath(os.path.abspath(path))
|
|
|
|
|
if p == b:
|
|
|
|
|
p = "."
|
|
|
|
|
if addslash:
|
|
|
|
|
p += "/"
|
|
|
|
|
return p
|
|
|
|
|
|
|
|
|
|
b += os.sep
|
|
|
|
|
if not p.startswith(b):
|
|
|
|
|
raise ValueError("{0!r} is not relative to {1!r}".format(path, base))
|
|
|
|
|
p = p[len(b):].replace(os.sep, "/")
|
|
|
|
|
if addslash:
|
|
|
|
|
p += "/"
|
|
|
|
|
|
|
|
|
|
return p
|
|
|
|
|
|
2013-02-09 21:03:00 +01:00
|
|
|
|
|
2012-04-15 16:04:08 +02:00
|
|
|
|
def filter_excluded_dirs(exclude_pattern, basedir, dirpath, dnames):
|
|
|
|
|
i, l = 0, len(dnames)
|
|
|
|
|
while i < l:
|
|
|
|
|
rp = relpath(basedir, os.path.join(dirpath, dnames[i]), True)
|
|
|
|
|
if exclude_pattern.search(rp):
|
|
|
|
|
del dnames[i]
|
|
|
|
|
l -= 1
|
|
|
|
|
else:
|
|
|
|
|
i += 1
|
|
|
|
|
|
2013-02-09 21:03:00 +01:00
|
|
|
|
|
2012-04-15 16:04:08 +02:00
|
|
|
|
def copy_dir_exclude(exclude, basedir, srcdir, destdir):
|
|
|
|
|
for dp, dnames, fnames in os.walk(srcdir):
|
|
|
|
|
filter_excluded_dirs(exclude, basedir, dp, dnames)
|
|
|
|
|
|
|
|
|
|
rp = relpath(basedir, dp)
|
|
|
|
|
target_dir = os.path.join(destdir, rp)
|
|
|
|
|
if not os.path.exists(target_dir):
|
|
|
|
|
os.makedirs(target_dir)
|
|
|
|
|
|
|
|
|
|
for fn in fnames:
|
|
|
|
|
fp = os.path.join(dp, fn)
|
|
|
|
|
rp = relpath(basedir, fp)
|
|
|
|
|
if exclude.search(rp):
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
shutil.copyfile(fp, os.path.join(destdir, rp))
|
|
|
|
|
|
2013-02-09 21:03:00 +01:00
|
|
|
|
|
2012-04-15 16:04:08 +02:00
|
|
|
|
def collect_lib(libdir, odir):
|
|
|
|
|
exclude = compile_re_list(COMMON_EXCLUDE + LIBEXCLUDE)
|
|
|
|
|
copy_dir_exclude(exclude, libdir, libdir, os.path.join(odir, "Lib"))
|
|
|
|
|
|
2013-02-09 21:03:00 +01:00
|
|
|
|
|
|
|
|
|
def get_pkg_exclude(name, extra=()):
|
2012-04-15 16:04:08 +02:00
|
|
|
|
exclude = COMMON_EXCLUDE[:]
|
|
|
|
|
exclude.extend(SITE_PACKAGES.get(name, {}).get("exclude", []))
|
|
|
|
|
exclude.extend(extra)
|
|
|
|
|
return compile_re_list(exclude)
|
|
|
|
|
|
2013-02-09 21:03:00 +01:00
|
|
|
|
|
2012-04-15 16:04:08 +02:00
|
|
|
|
def copy_package(name, info, odir):
|
2013-02-09 21:03:00 +01:00
|
|
|
|
copy_things = info.get("copy", [])
|
|
|
|
|
if not copy_things:
|
|
|
|
|
return
|
|
|
|
|
|
2012-04-15 16:04:08 +02:00
|
|
|
|
dist = pkg_resources.get_distribution(name)
|
|
|
|
|
exclude = get_pkg_exclude(name)
|
|
|
|
|
|
|
|
|
|
site_dir = dist.location
|
2013-02-09 21:03:00 +01:00
|
|
|
|
for thing in copy_things:
|
2012-04-15 16:04:08 +02:00
|
|
|
|
fp = os.path.join(site_dir, thing)
|
|
|
|
|
if not os.path.isdir(fp):
|
|
|
|
|
rp = relpath(site_dir, fp)
|
|
|
|
|
ofp = os.path.join(odir, rp)
|
|
|
|
|
shutil.copyfile(fp, ofp)
|
|
|
|
|
else:
|
|
|
|
|
copy_dir_exclude(exclude, site_dir, fp, odir)
|
|
|
|
|
|
2013-02-09 21:03:00 +01:00
|
|
|
|
|
|
|
|
|
def copy_wx(odir):
|
|
|
|
|
base_dir = os.path.dirname(os.path.dirname(wx.__file__))
|
|
|
|
|
wx_dir = os.path.join(base_dir, "wx")
|
|
|
|
|
exclude = get_pkg_exclude("wx")
|
|
|
|
|
copy_dir_exclude(exclude, base_dir, wx_dir, odir)
|
|
|
|
|
|
|
|
|
|
|
2012-04-15 16:04:08 +02:00
|
|
|
|
def collect_site_packages(sitedir, odir):
|
|
|
|
|
if not os.path.exists(odir):
|
|
|
|
|
os.makedirs(odir)
|
|
|
|
|
|
|
|
|
|
for name, info in SITE_PACKAGES.iteritems():
|
|
|
|
|
copy_package(name, info, odir)
|
|
|
|
|
|
2013-02-09 21:03:00 +01:00
|
|
|
|
assert "wx" in SITE_PACKAGES
|
|
|
|
|
copy_wx(odir)
|
|
|
|
|
|
|
|
|
|
|
2012-04-15 16:04:08 +02:00
|
|
|
|
def compile_openslides_launcher():
|
2012-04-25 20:24:48 +02:00
|
|
|
|
try:
|
|
|
|
|
cc = distutils.ccompiler.new_compiler()
|
|
|
|
|
if not cc.initialized:
|
|
|
|
|
cc.initialize()
|
|
|
|
|
except distutils.errors.DistutilsError:
|
|
|
|
|
return False
|
|
|
|
|
|
2012-04-15 16:04:08 +02:00
|
|
|
|
cc.add_include_dir(distutils.sysconfig.get_python_inc())
|
2013-06-29 14:31:11 +02:00
|
|
|
|
cc.define_macro("_CRT_SECURE_NO_WARNINGS")
|
2012-04-15 16:04:08 +02:00
|
|
|
|
|
2013-02-09 21:03:00 +01:00
|
|
|
|
gui_data_dir = os.path.dirname(openslides_gui.__file__)
|
|
|
|
|
gui_data_dir = os.path.join(gui_data_dir, "data")
|
|
|
|
|
shutil.copyfile(
|
|
|
|
|
os.path.join(gui_data_dir, "openslides.ico"),
|
|
|
|
|
"extras/win32-portable/openslides.ico")
|
|
|
|
|
rcfile = "extras/win32-portable/openslides.rc"
|
|
|
|
|
with open(rcfile, "w") as f:
|
|
|
|
|
if openslides.VERSION[3] == "final":
|
|
|
|
|
file_flags = "0"
|
|
|
|
|
else:
|
|
|
|
|
file_flags = "VS_FF_PRERELEASE"
|
|
|
|
|
|
|
|
|
|
f.write(OPENSLIDES_RC_TMPL.format(
|
|
|
|
|
version=openslides.VERSION,
|
|
|
|
|
version_str=openslides.get_version(),
|
|
|
|
|
file_flags=file_flags))
|
|
|
|
|
|
|
|
|
|
objs = cc.compile([
|
|
|
|
|
"extras/win32-portable/openslides.c",
|
|
|
|
|
rcfile,
|
|
|
|
|
])
|
|
|
|
|
cc.link_executable(
|
|
|
|
|
objs, "extras/win32-portable/openslides",
|
2013-06-29 14:31:11 +02:00
|
|
|
|
extra_preargs=["/subsystem:windows", "/nodefaultlib:python27.lib"],
|
2013-06-29 15:15:32 +02:00
|
|
|
|
libraries=["user32"]
|
2013-02-09 21:03:00 +01:00
|
|
|
|
)
|
2012-04-25 20:24:48 +02:00
|
|
|
|
return True
|
2012-04-15 16:04:08 +02:00
|
|
|
|
|
2013-02-09 21:03:00 +01:00
|
|
|
|
|
2013-06-29 15:15:32 +02:00
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
|
2012-04-15 16:04:08 +02:00
|
|
|
|
def copy_dlls(odir):
|
|
|
|
|
dll_src = os.path.join(sys.exec_prefix, "DLLs")
|
|
|
|
|
dll_dest = os.path.join(odir, "DLLs")
|
|
|
|
|
if not os.path.exists(dll_dest):
|
|
|
|
|
os.makedirs(dll_dest)
|
|
|
|
|
|
|
|
|
|
for dll_name in PY_DLLS:
|
|
|
|
|
src = os.path.join(dll_src, dll_name)
|
|
|
|
|
dest = os.path.join(dll_dest, dll_name)
|
|
|
|
|
shutil.copyfile(src, dest)
|
|
|
|
|
|
|
|
|
|
pydllname = "python{0}{1}.dll".format(*sys.version_info[:2])
|
|
|
|
|
src = os.path.join(os.environ["WINDIR"], "System32", pydllname)
|
2013-06-29 14:31:11 +02:00
|
|
|
|
dest = os.path.join(dll_dest, pydllname)
|
2012-04-15 16:04:08 +02:00
|
|
|
|
shutil.copyfile(src, dest)
|
|
|
|
|
|
2013-02-09 21:03:00 +01:00
|
|
|
|
|
2012-04-15 16:04:08 +02:00
|
|
|
|
def copy_msvcr(odir):
|
|
|
|
|
candidates = glob.glob("{0}/x86_*{1}_{2}*".format(
|
|
|
|
|
os.path.join(os.environ["WINDIR"], "winsxs"),
|
|
|
|
|
MSVCR_NAME, MSVCR_PUBLIC_KEY))
|
|
|
|
|
|
|
|
|
|
msvcr_local_name = None
|
|
|
|
|
msvcr_dll_dir = None
|
|
|
|
|
for dp in candidates:
|
|
|
|
|
bn = os.path.basename(dp)
|
|
|
|
|
if MSVCR_VERSION in bn:
|
|
|
|
|
msvcr_local_name = bn
|
|
|
|
|
msvcr_dll_dir = dp
|
|
|
|
|
break
|
|
|
|
|
else:
|
2013-02-09 21:03:00 +01:00
|
|
|
|
sys.stderr.write(
|
|
|
|
|
"Warning could not determine msvcr runtime location\n"
|
|
|
|
|
"Private asssembly for VC runtime must be added manually\n")
|
2012-04-15 16:04:08 +02:00
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
msvcr_dest_dir = os.path.join(odir, MSVCR_NAME)
|
|
|
|
|
if not os.path.exists(msvcr_dest_dir):
|
|
|
|
|
os.makedirs(msvcr_dest_dir)
|
|
|
|
|
|
|
|
|
|
for fn in os.listdir(msvcr_dll_dir):
|
|
|
|
|
src = os.path.join(msvcr_dll_dir, fn)
|
|
|
|
|
dest = os.path.join(msvcr_dest_dir, fn)
|
|
|
|
|
shutil.copyfile(src, dest)
|
|
|
|
|
|
2013-02-09 21:03:00 +01:00
|
|
|
|
src = os.path.join(
|
|
|
|
|
os.environ["WINDIR"], "winsxs", "Manifests",
|
2012-04-15 16:04:08 +02:00
|
|
|
|
"{0}.manifest".format(msvcr_local_name))
|
|
|
|
|
dest = os.path.join(msvcr_dest_dir, "{0}.manifest".format(MSVCR_NAME))
|
|
|
|
|
shutil.copyfile(src, dest)
|
|
|
|
|
|
2012-04-23 21:36:30 +02:00
|
|
|
|
|
2013-10-20 02:04:27 +02:00
|
|
|
|
def write_package_info_content(outfile):
|
|
|
|
|
"""
|
|
|
|
|
Writes a list of all included packages into outfile.
|
|
|
|
|
"""
|
|
|
|
|
text = ['Included Packages\n', 17 * '=' + '\n', '\n']
|
2012-04-27 23:29:39 +02:00
|
|
|
|
for pkg in sorted(SITE_PACKAGES):
|
2013-02-09 21:03:00 +01:00
|
|
|
|
try:
|
|
|
|
|
dist = pkg_resources.get_distribution(pkg)
|
|
|
|
|
text.append("{0}-{1}\n".format(dist.project_name, dist.version))
|
|
|
|
|
except pkg_resources.DistributionNotFound:
|
|
|
|
|
# FIXME: wxpython comes from an installer and has no distribution
|
|
|
|
|
# see what we can do about that
|
|
|
|
|
text.append("{0}-???\n".format(pkg))
|
2013-10-20 02:04:27 +02:00
|
|
|
|
with open(outfile, "w") as f:
|
|
|
|
|
f.writelines(text)
|
|
|
|
|
|
2012-04-23 21:36:30 +02:00
|
|
|
|
|
2013-10-20 02:04:27 +02:00
|
|
|
|
def write_metadatafile(infile, outfile):
|
|
|
|
|
"""
|
|
|
|
|
Writes content from metadata files like README, AUTHORS and LICENSE into
|
|
|
|
|
outfile.
|
|
|
|
|
"""
|
|
|
|
|
with open(infile, "rU") as f:
|
|
|
|
|
text = [l for l in f]
|
2012-04-23 21:36:30 +02:00
|
|
|
|
with open(outfile, "w") as f:
|
2012-04-27 23:29:39 +02:00
|
|
|
|
f.writelines(text)
|
2012-04-23 21:36:30 +02:00
|
|
|
|
|
|
|
|
|
|
2012-04-15 16:04:08 +02:00
|
|
|
|
def main():
|
|
|
|
|
prefix = os.path.dirname(sys.executable)
|
|
|
|
|
libdir = os.path.join(prefix, "Lib")
|
|
|
|
|
sitedir = os.path.join(libdir, "site-packages")
|
|
|
|
|
odir = "dist/openslides-{0}-portable".format(openslides.get_version())
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
shutil.rmtree(odir)
|
|
|
|
|
except OSError as e:
|
|
|
|
|
if e.errno != errno.ENOENT:
|
|
|
|
|
raise
|
|
|
|
|
|
|
|
|
|
os.makedirs(odir)
|
2013-02-09 21:03:00 +01:00
|
|
|
|
out_site_packages = os.path.join(odir, "Lib", "site-packages")
|
2012-04-15 16:04:08 +02:00
|
|
|
|
|
|
|
|
|
collect_lib(libdir, odir)
|
2012-11-18 14:38:22 +01:00
|
|
|
|
collect_site_packages(sitedir, out_site_packages)
|
2012-04-15 16:04:08 +02:00
|
|
|
|
|
2012-11-18 14:38:22 +01:00
|
|
|
|
exclude = get_pkg_exclude("openslides")
|
|
|
|
|
copy_dir_exclude(exclude, ".", "openslides", out_site_packages)
|
2012-11-18 14:21:11 +01:00
|
|
|
|
|
2012-04-25 20:24:48 +02:00
|
|
|
|
if not compile_openslides_launcher():
|
|
|
|
|
sys.stdout.write("Using prebuild openslides.exe\n")
|
2013-06-29 15:15:32 +02:00
|
|
|
|
openslides_launcher_update_version_resource()
|
2012-04-15 16:04:08 +02:00
|
|
|
|
|
2013-02-09 21:03:00 +01:00
|
|
|
|
shutil.copyfile(
|
|
|
|
|
"extras/win32-portable/openslides.exe",
|
2012-04-15 16:04:08 +02:00
|
|
|
|
os.path.join(odir, "openslides.exe"))
|
|
|
|
|
|
2013-02-09 21:03:00 +01:00
|
|
|
|
shutil.copytree(
|
|
|
|
|
"extras/openslides_gui",
|
|
|
|
|
os.path.join(out_site_packages, "openslides_gui"))
|
|
|
|
|
|
2012-04-15 16:04:08 +02:00
|
|
|
|
copy_dlls(odir)
|
|
|
|
|
copy_msvcr(odir)
|
|
|
|
|
|
2013-10-20 02:04:27 +02:00
|
|
|
|
# Info on included packages
|
2013-02-09 21:03:00 +01:00
|
|
|
|
shutil.copytree(
|
|
|
|
|
"extras/win32-portable/licenses",
|
2013-10-20 02:04:27 +02:00
|
|
|
|
os.path.join(odir, "packages-info"))
|
|
|
|
|
write_package_info_content(os.path.join(odir, 'packages-info', 'PACKAGES.txt'))
|
|
|
|
|
|
|
|
|
|
# AUTHORS, LICENSE, README
|
|
|
|
|
write_metadatafile('AUTHORS', os.path.join(odir, 'AUTHORS.txt'))
|
|
|
|
|
write_metadatafile('LICENSE', os.path.join(odir, 'LICENSE.txt'))
|
|
|
|
|
write_metadatafile('README.rst', os.path.join(odir, 'README.txt'))
|
2012-04-23 21:35:47 +02:00
|
|
|
|
|
2013-02-09 21:03:00 +01:00
|
|
|
|
zip_fp = os.path.join(
|
|
|
|
|
"dist", "openslides-{0}-portable.zip".format(
|
2012-04-15 16:04:08 +02:00
|
|
|
|
openslides.get_version()))
|
|
|
|
|
|
2012-04-23 21:36:30 +02:00
|
|
|
|
|
2012-04-25 20:24:48 +02:00
|
|
|
|
with zipfile.ZipFile(zip_fp, "w", zipfile.ZIP_DEFLATED) as zf:
|
2012-04-15 16:04:08 +02:00
|
|
|
|
for dp, dnames, fnames in os.walk(odir):
|
|
|
|
|
for fn in fnames:
|
|
|
|
|
fp = os.path.join(dp, fn)
|
|
|
|
|
rp = relpath(odir, fp)
|
|
|
|
|
zf.write(fp, rp)
|
|
|
|
|
|
2012-04-25 20:24:48 +02:00
|
|
|
|
print("Successfully build {0}".format(zip_fp))
|
|
|
|
|
|
2012-04-15 16:04:08 +02:00
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|