From 1f2701333fcbb5a7d4e9adffc4f1a34be04c6a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 30 May 2009 18:29:04 +0200 Subject: [PATCH] Let py2exe packages the gtk dll and copy in dist_dir gtk configuration --- bin/tryton | 12 -------- setup-single.nsi | 33 ---------------------- setup.nsi | 33 ---------------------- setup.py | 72 +++++++++++++++++++++++++++++++----------------- 4 files changed, 46 insertions(+), 104 deletions(-) diff --git a/bin/tryton b/bin/tryton index 8df63bfacc..ec224ed56c 100755 --- a/bin/tryton +++ b/bin/tryton @@ -8,18 +8,6 @@ try: except: pass -if os.name == 'nt' \ - and os.path.isdir(os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), - 'GTK')): - sys.path.insert(0, os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), - 'GTK\\bin')) - sys.path.insert(0, os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), - 'GTK\\lib')) - os.environ['PATH'] = os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), - 'GTK\\bin') + ';' + os.environ['PATH'] - os.environ['PATH'] = os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), - 'GTK\\lib') + ';' + os.environ['PATH'] - if os.name == 'mac' or \ (hasattr(os, 'uname') and os.uname()[0] == 'Darwin'): resources = os.path.join(os.path.dirname(sys.argv[0]), '..', 'Resources') diff --git a/setup-single.nsi b/setup-single.nsi index 53e9578a79..63fc6448ea 100644 --- a/setup-single.nsi +++ b/setup-single.nsi @@ -5,9 +5,6 @@ !ifndef VERSION !error "Missing VERSION! Specify it with '/DVERSION='" !endif -!ifndef GTKDIR - !error "Missing GTKDIR! Specify it with '/DGTKDIR='" -!endif ;General Name "Tryton ${VERSION}" @@ -32,39 +29,9 @@ Section File "TODO" File "CHANGELOG" - SetOutPath "$PLUGINSDIR\GTK\bin" - File /r "${GTKDIR}\bin\*" - - SetOutPath "$PLUGINSDIR\GTK\etc" - File /r "${GTKDIR}\etc\*" - - SetOutPath "$PLUGINSDIR\GTK\lib" - File /r "${GTKDIR}\lib\*" - - SetOutPath "$PLUGINSDIR\GTK\share\gtk-2.0" - File /r "${GTKDIR}\share\gtk-2.0\*" - - SetOutPath "$PLUGINSDIR\GTK\share\gtkthemeselector" - File /r "${GTKDIR}\share\gtkthemeselector\*" - - SetOutPath "$PLUGINSDIR\GTK\share\locale\de" - File /r "${GTKDIR}\share\locale\de\*" - - SetOutPath "$PLUGINSDIR\GTK\share\locale\es" - File /r "${GTKDIR}\share\locale\es\*" - - SetOutPath "$PLUGINSDIR\GTK\share\locale\fr" - File /r "${GTKDIR}\share\locale\fr\*" - - SetOutPath "$PLUGINSDIR\GTK\share\themes" - File /r "${GTKDIR}\share\themes\*" - SetOutPath "$PLUGINSDIR\doc" File /r "doc\*" - SetOutPath "$PLUGINSDIR\plugins" - File /r "tryton\plugins\*" - ;Run the exe SetOutPath '$EXEDIR' nsExec::Exec $PLUGINSDIR\tryton.exe diff --git a/setup.nsi b/setup.nsi index 8a33193242..3920e70c0b 100644 --- a/setup.nsi +++ b/setup.nsi @@ -5,9 +5,6 @@ !ifndef VERSION !error "Missing VERSION! Specify it with '/DVERSION='" !endif -!ifndef GTKDIR - !error "Missing GTKDIR! Specify it with '/DGTKDIR='" -!endif ;Include Modern UI !include "MUI.nsh" @@ -98,39 +95,9 @@ SectionIn 1 2 RO File "TODO" File "CHANGELOG" - SetOutPath "$INSTDIR\GTK\bin" - File /r "${GTKDIR}\bin\*" - - SetOutPath "$INSTDIR\GTK\etc" - File /r "${GTKDIR}\etc\*" - - SetOutPath "$INSTDIR\GTK\lib" - File /r "${GTKDIR}\lib\*" - - SetOutPath "$INSTDIR\GTK\share\gtk-2.0" - File /r "${GTKDIR}\share\gtk-2.0\*" - - SetOutPath "$INSTDIR\GTK\share\gtkthemeselector" - File /r "${GTKDIR}\share\gtkthemeselector\*" - - SetOutPath "$INSTDIR\GTK\share\locale\de" - File /r "${GTKDIR}\share\locale\de\*" - - SetOutPath "$INSTDIR\GTK\share\locale\es" - File /r "${GTKDIR}\share\locale\es\*" - - SetOutPath "$INSTDIR\GTK\share\locale\fr" - File /r "${GTKDIR}\share\locale\fr\*" - - SetOutPath "$INSTDIR\GTK\share\themes" - File /r "${GTKDIR}\share\themes\*" - SetOutPath "$INSTDIR\doc" File /r "doc\*" - SetOutPath "$INSTDIR\plugins" - File /r "tryton\plugins\*" - ;Write the installation path into the registry WriteRegStr HKCU "Software\tryton-${VERSION}" "" $INSTDIR WriteRegStr HKLM "Software\tryton-${VERSION}" "" $INSTDIR diff --git a/setup.py b/setup.py index b68899914c..647057d694 100644 --- a/setup.py +++ b/setup.py @@ -49,31 +49,9 @@ if os.name == 'nt': 'encodings', 'gtk', 'pytz', - ], - 'includes': 'pango,atk,gobject,cairo,pangocairo', - 'dll_excludes': [ - 'iconv.dll', - 'intl.dll', - 'libatk-1.0-0.dll', - 'libgdk_pixbuf-2.0-0.dll', - 'libgdk-win32-2.0-0.dll', - 'libglib-2.0-0.dll', - 'libgmodule-2.0-0.dll', - 'libgobject-2.0-0.dll', - 'libgthread-2.0-0.dll', - 'libgtk-win32-2.0-0.dll', - 'libpango-1.0-0.dll', - 'libpangowin32-1.0-0.dll', - 'libcairo-2.dll', - 'libfontconfig-1.dll', - 'libfreetype-6.dll', - 'libgdkglext-win32-1.0.0.dll', - 'libglade-2.0-0.dll', - 'libgtkglext-win32-1.0-0.dll', - 'libpangocairo-1.0-0.dll', - 'libpangoft2-1.0-0.dll', - 'libxml2.dll', - 'zlib1.dll', + 'atk', + 'pango', + 'pangocairo', ], } } @@ -101,7 +79,7 @@ elif os.name == 'mac' \ execfile(os.path.join('tryton', 'version.py')) -setup(name=PACKAGE, +dist = setup(name=PACKAGE, version=VERSION, description='Tryton client', author='B2CK', @@ -144,3 +122,45 @@ setup(name=PACKAGE, }, **args ) + +if os.name == 'nt': + def find_gtk_dir(): + for directory in os.environ['PATH'].split(';'): + if not os.path.isdir(directory): + continue + for file in ('gtk-demo.exe',): + if os.path.isfile(os.path.join(directory, file)): + return os.path.dirname(directory) + return None + + if 'py2exe' in dist.commands: + import shutil + gtk_dir = find_gtk_dir() + + dist_dir = dist.command_obj['py2exe'].dist_dir + + if os.path.isdir(os.path.join(dist_dir, 'plugins')): + shutil.rmtree(os.path.join(dist_dir, 'plugins')) + shutil.copytree(os.path.join(os.path.dirname(__file__), 'tryton', 'plugins'), + os.path.join(dist_dir, 'plugins')) + + if os.path.isdir(os.path.join(dist_dir, 'etc')): + shutil.rmtree(os.path.join(dist_dir, 'etc')) + shutil.copytree(os.path.join(gtk_dir, 'etc'), + os.path.join(dist_dir, 'etc')) + + if os.path.isdir(os.path.join(dist_dir, 'lib')): + shutil.rmtree(os.path.join(dist_dir, 'lib')) + shutil.copytree(os.path.join(gtk_dir, 'lib'), + os.path.join(dist_dir, 'lib')) + + for lang in ('de', 'es', 'fr'): + if os.path.isdir(os.path.join(dist_dir, 'share', 'locale', lang)): + shutil.rmtree(os.path.join(dist_dir, 'share', 'locale', lang)) + shutil.copytree(os.path.join(gtk_dir, 'share', 'locale', lang), + os.path.join(dist_dir, 'share', 'locale', lang)) + + if os.path.isdir(os.path.join(dist_dir, 'share', 'themes', 'MS-Windows')): + shutil.rmtree(os.path.join(dist_dir, 'share', 'themes', 'MS-Windows')) + shutil.copytree(os.path.join(gtk_dir, 'share', 'themes', 'MS-Windows'), + os.path.join(dist_dir, 'share', 'themes', 'MS-Windows'))