| 1 | # Copyright (C) 2005-2006 Insecure.Com LLC. |
|---|
| 2 | # Copyright (C) 2007-2008 Adriano Monteiro Marques |
|---|
| 3 | # |
|---|
| 4 | # Authors: Adriano Monteiro Marques <adriano@umitproject.org> |
|---|
| 5 | # Guilherme Polo <ggpolo@gmail.com> |
|---|
| 6 | # |
|---|
| 7 | # This program is free software; you can redistribute it and/or modify |
|---|
| 8 | # it under the terms of the GNU General Public License as published by |
|---|
| 9 | # the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | # (at your option) any later version. |
|---|
| 11 | # |
|---|
| 12 | # This program is distributed in the hope that it will be useful, |
|---|
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | # GNU General Public License for more details. |
|---|
| 16 | # |
|---|
| 17 | # You should have received a copy of the GNU General Public License |
|---|
| 18 | # along with this program; if not, write to the Free Software |
|---|
| 19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 20 | |
|---|
| 21 | __all__ = ['py2exe_cmdclass', 'py2exe_options'] |
|---|
| 22 | |
|---|
| 23 | import os |
|---|
| 24 | import sys |
|---|
| 25 | |
|---|
| 26 | from py2exe.build_exe import py2exe as build_exe |
|---|
| 27 | |
|---|
| 28 | from umit.core.Version import VERSION |
|---|
| 29 | from install_scripts import common |
|---|
| 30 | |
|---|
| 31 | # Add the bin dir to the sys.path so we can indicate that the umit_scheduler |
|---|
| 32 | # module is a service. |
|---|
| 33 | umit_top_dir = os.path.abspath(os.path.join( |
|---|
| 34 | os.path.dirname(__file__), os.path.pardir, os.path.pardir)) |
|---|
| 35 | sys.path.append(os.path.join(umit_top_dir, common.BIN_DIRNAME)) |
|---|
| 36 | |
|---|
| 37 | # win32com changes its __path__ to be able to do imports from |
|---|
| 38 | # win32comext (which is not a python package), but the modulefinder |
|---|
| 39 | # does not handle such situtation and thus win32com.shell (which is |
|---|
| 40 | # really win32comext.shell) cannot be found. Let's fix this here so |
|---|
| 41 | # umit.core.BasePaths still works after we run py2exe over it. |
|---|
| 42 | try: |
|---|
| 43 | import py2exe.mf as modulefinder |
|---|
| 44 | except ImportError: |
|---|
| 45 | # This py2exe is too old, will use the standard modulefinder |
|---|
| 46 | import modulefinder |
|---|
| 47 | import win32com |
|---|
| 48 | for path in win32com.__path__[1:]: |
|---|
| 49 | modulefinder.AddPackagePath("win32com", path) |
|---|
| 50 | |
|---|
| 51 | class umit_py2exe(build_exe): |
|---|
| 52 | def run(self): |
|---|
| 53 | build_exe.run(self) |
|---|
| 54 | self.finish_banner() |
|---|
| 55 | |
|---|
| 56 | def finish_banner(self): |
|---|
| 57 | print |
|---|
| 58 | print "%s The compiled version of Umit %s is in ./dist %s" % \ |
|---|
| 59 | ("#"*10, VERSION, "#"*10) |
|---|
| 60 | print |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | py2exe_cmdclass = {"py2exe": umit_py2exe} |
|---|
| 64 | |
|---|
| 65 | py2exe_options = dict( |
|---|
| 66 | zipfile = None, |
|---|
| 67 | service = [{'modules': ['umit_scheduler'], 'cmdline_style': 'custom'}], |
|---|
| 68 | windows = [{ |
|---|
| 69 | "script": common.UMIT_MAIN, |
|---|
| 70 | "dest_base": "umit", |
|---|
| 71 | "uac_info": "requireAdministrator", |
|---|
| 72 | "icon_resources": [ |
|---|
| 73 | (1, os.path.join(common.ICONS_DIR, "umit_48.ico"))] |
|---|
| 74 | }], |
|---|
| 75 | options = {"py2exe": { |
|---|
| 76 | "compressed": 1, |
|---|
| 77 | "optimize": 2, |
|---|
| 78 | "packages": "encodings", |
|---|
| 79 | "includes": [ |
|---|
| 80 | 'pango', 'atk', 'gobject', 'pickle', 'bz2', 'gio', |
|---|
| 81 | 'encodings', 'encodings.*', 'cairo', 'pangocairo'], |
|---|
| 82 | # Ignore psyco if it is not installed |
|---|
| 83 | "ignores": ['psyco'], |
|---|
| 84 | "excludes": ['Tkinter', 'pdb']} |
|---|
| 85 | } |
|---|
| 86 | ) |
|---|