From d0b95c496df3e8d667b00c453dcb36db2c762285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 10 Apr 2011 21:12:02 +0200 Subject: [PATCH] Allow py2exe to work with Python >= 2.6 and with pygtk all-in-one for issue1350 --- Microsoft.VC90.CRT.manifest | 43 +++++++++++++++++++++++++++++ bin/tryton | 6 ++++ setup.py | 55 +++++++++++++++++++++++-------------- 3 files changed, 83 insertions(+), 21 deletions(-) create mode 100644 Microsoft.VC90.CRT.manifest diff --git a/Microsoft.VC90.CRT.manifest b/Microsoft.VC90.CRT.manifest new file mode 100644 index 0000000000..4b85b0626e --- /dev/null +++ b/Microsoft.VC90.CRT.manifest @@ -0,0 +1,43 @@ + + + + Tryton client + + + + + + + + + + + + + + + + + + + + diff --git a/bin/tryton b/bin/tryton index 85eedaf0d8..9451640f8b 100755 --- a/bin/tryton +++ b/bin/tryton @@ -12,6 +12,12 @@ except Exception: if os.name == 'nt' and hasattr(sys, "frozen"): sys.stdout = open(os.devnull, 'w') sys.stderr = open(os.devnull, 'w') + etc = os.path.join(os.path.dirname(sys.executable), 'etc') + os.environ['GTK2_RC_FILES'] = os.path.join(etc, 'gtk-2.0', 'gtkrc') + os.environ['GDK_PIXBUF_MODULE_FILE'] = os.path.join(etc, 'gtk-2.0', + 'gdk-pixbuf.loaders') + os.environ['GTK_IM_MODULE_FILE'] = os.path.join(etc, 'gtk-2.0', + 'gtk.immodules') if os.name == 'mac' or \ (hasattr(os, 'uname') and os.uname()[0] == 'Darwin'): diff --git a/setup.py b/setup.py index 57b775afbc..c38fbd4e43 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,9 @@ import os import glob import sys +def read(fname): + return open(os.path.join(os.path.dirname(__file__), fname)).read() + args = {} try: @@ -28,14 +31,29 @@ try: except ImportError: pass +data_files=[ + ('share/pixmaps/tryton', glob.glob('share/pixmaps/tryton/*.png') + \ + glob.glob('share/pixmaps/tryton/*.svg')), + ('share/locale/bg_BG/LC_MESSAGES', + glob.glob('share/locale/bg_BG/LC_MESSAGES/*.mo')), + ('share/locale/cs_CZ/LC_MESSAGES', + glob.glob('share/locale/cs_CZ/LC_MESSAGES/*.mo')), + ('share/locale/de_DE/LC_MESSAGES', + glob.glob('share/locale/de_DE/LC_MESSAGES/*.mo')), + ('share/locale/es_CO/LC_MESSAGES', + glob.glob('share/locale/es_CO/LC_MESSAGES/*.mo')), + ('share/locale/es_ES/LC_MESSAGES', + glob.glob('share/locale/es_ES/LC_MESSAGES/*.mo')), + ('share/locale/fr_FR/LC_MESSAGES', + glob.glob('share/locale/fr_FR/LC_MESSAGES/*.mo')), + ('share/locale/ru_RU/LC_MESSAGES', + glob.glob('share/locale/ru_RU/LC_MESSAGES/*.mo')), + ('share/locale/ja_JP/LC_MESSAGES', + glob.glob('share/locale/ja_JP/LC_MESSAGES/*.mo')), +] + if os.name == 'nt': import py2exe - origIsSystemDLL = py2exe.build_exe.isSystemDLL - def isSystemDLL(pathname): - if os.path.basename(pathname).lower() in ("msvcp71.dll", "dwmapi.dll"): - return 0 - return origIsSystemDLL(pathname) - py2exe.build_exe.isSystemDLL = isSystemDLL args['windows'] = [{ 'script': os.path.join('bin', 'tryton'), @@ -57,6 +75,15 @@ if os.name == 'nt': } } args['zipfile'] = 'library.zip' + + if sys.version_info < (2, 6): + data_files.append(('', ['msvcp71.dll'])) + else: + data_files.append(('', ['msvcr90.dll', 'msvcp90.dll', 'msvcm90.dll'])) + manifest = read('Microsoft.VC90.CRT.manifest') + args['windows'][0]['other_resources'] = [(24, 1, manifest)] + + elif os.name == 'mac' \ or (hasattr(os, 'uname') and os.uname()[0] == 'Darwin'): import py2app @@ -89,9 +116,6 @@ if sys.version_info < (2, 6): SIMPLEJSON = ['simplejson'] EXTRAS['ssl'] = ['ssl'] -def read(fname): - return open(os.path.join(os.path.dirname(__file__), fname)).read() - dist = setup(name=PACKAGE, version=VERSION, description='Tryton client', @@ -102,18 +126,7 @@ dist = setup(name=PACKAGE, download_url="http://downloads.tryton.org/" + \ VERSION.rsplit('.', 1)[0] + '/', packages=find_packages(), - data_files=[ - ('share/pixmaps/tryton', glob.glob('share/pixmaps/tryton/*.png') + \ - glob.glob('share/pixmaps/tryton/*.svg')), - ('share/locale/bg_BG/LC_MESSAGES', glob.glob('share/locale/bg_BG/LC_MESSAGES/*.mo')), - ('share/locale/cs_CZ/LC_MESSAGES', glob.glob('share/locale/cs_CZ/LC_MESSAGES/*.mo')), - ('share/locale/de_DE/LC_MESSAGES', glob.glob('share/locale/de_DE/LC_MESSAGES/*.mo')), - ('share/locale/es_CO/LC_MESSAGES', glob.glob('share/locale/es_CO/LC_MESSAGES/*.mo')), - ('share/locale/es_ES/LC_MESSAGES', glob.glob('share/locale/es_ES/LC_MESSAGES/*.mo')), - ('share/locale/fr_FR/LC_MESSAGES', glob.glob('share/locale/fr_FR/LC_MESSAGES/*.mo')), - ('share/locale/ru_RU/LC_MESSAGES', glob.glob('share/locale/ru_RU/LC_MESSAGES/*.mo')), - ('share/locale/ja_JP/LC_MESSAGES', glob.glob('share/locale/ja_JP/LC_MESSAGES/*.mo')), - ], + data_files=data_files, scripts=['bin/tryton'], classifiers=[ 'Development Status :: 5 - Production/Stable',