[b30f001] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
| 3 | # |
---|
[365a17f6] | 4 | # The setup to create a Windows executable. |
---|
| 5 | # Inno Setup can then be used with the installer.iss file |
---|
| 6 | # in the top source directory to create an installer. |
---|
[b30f001] | 7 | # |
---|
[365a17f6] | 8 | # Setuptools clashes with py2exe 0.6.8 (and probably later too). |
---|
| 9 | # For that reason, most of the code needs to have direct imports |
---|
| 10 | # that are not going through pkg_resources. |
---|
| 11 | # |
---|
| 12 | # Attention should be paid to dynamic imports. Data files can |
---|
| 13 | # be added to the distribution directory for that purpose. |
---|
| 14 | # See for example the 'images' directory below. |
---|
[b30f001] | 15 | |
---|
| 16 | import os, sys |
---|
| 17 | from distutils.core import setup |
---|
| 18 | from distutils.filelist import findall |
---|
| 19 | import matplotlib |
---|
| 20 | import py2exe |
---|
| 21 | |
---|
[ead38a7] | 22 | if len(sys.argv) == 1: |
---|
| 23 | sys.argv.append('py2exe') |
---|
| 24 | |
---|
[b30f001] | 25 | manifest = """ |
---|
| 26 | <?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
---|
| 27 | <assembly xmlns="urn:schemas-microsoft-com:asm.v1" |
---|
| 28 | manifestVersion="1.0"> |
---|
| 29 | <assemblyIdentity |
---|
| 30 | version="0.64.1.0" |
---|
| 31 | processorArchitecture="x86" |
---|
| 32 | name="Controls" |
---|
| 33 | type="win32" |
---|
| 34 | /> |
---|
[365a17f6] | 35 | <description>SansView</description> |
---|
[b30f001] | 36 | <dependency> |
---|
| 37 | <dependentAssembly> |
---|
| 38 | <assemblyIdentity |
---|
| 39 | type="win32" |
---|
| 40 | name="Microsoft.Windows.Common-Controls" |
---|
| 41 | version="6.0.0.0" |
---|
| 42 | processorArchitecture="X86" |
---|
| 43 | publicKeyToken="6595b64144ccf1df" |
---|
| 44 | language="*" |
---|
| 45 | /> |
---|
| 46 | </dependentAssembly> |
---|
| 47 | </dependency> |
---|
| 48 | </assembly> |
---|
| 49 | """ |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | class Target: |
---|
| 53 | def __init__(self, **kw): |
---|
| 54 | self.__dict__.update(kw) |
---|
| 55 | # for the versioninfo resources |
---|
[add37d0] | 56 | self.version = "0.1" |
---|
[b30f001] | 57 | self.company_name = "U Tennessee" |
---|
| 58 | self.copyright = "copyright 2008" |
---|
[365a17f6] | 59 | self.name = "SansView" |
---|
[b30f001] | 60 | |
---|
| 61 | # |
---|
| 62 | # Adapted from http://www.py2exe.org/index.cgi/MatPlotLib |
---|
| 63 | # to use the MatPlotLib. |
---|
| 64 | # |
---|
| 65 | matplotlibdatadir = matplotlib.get_data_path() |
---|
| 66 | matplotlibdata = findall(matplotlibdatadir) |
---|
[365a17f6] | 67 | data_files = [] |
---|
[b30f001] | 68 | |
---|
| 69 | for f in matplotlibdata: |
---|
[365a17f6] | 70 | dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:]) |
---|
| 71 | data_files.append((os.path.split(dirname)[0], [f])) |
---|
[b30f001] | 72 | |
---|
[365a17f6] | 73 | # Copying the images directory to the distribution directory. |
---|
| 74 | for f in findall('images'): |
---|
| 75 | if os.path.split(f)[0].count('.svn')==0: |
---|
| 76 | data_files.append((os.path.split(f)[0], [f])) |
---|
[d35420d] | 77 | |
---|
| 78 | # Copying the HTML help docs |
---|
| 79 | for f in findall('doc'): |
---|
| 80 | if os.path.split(f)[0].count('.svn')==0: |
---|
| 81 | data_files.append((os.path.split(f)[0], [f])) |
---|
[365a17f6] | 82 | |
---|
[b30f001] | 83 | # |
---|
| 84 | # packages |
---|
| 85 | # |
---|
[365a17f6] | 86 | packages = ['matplotlib', 'pytz'] |
---|
[b30f001] | 87 | includes = [] |
---|
[365a17f6] | 88 | excludes = [] |
---|
[b30f001] | 89 | |
---|
| 90 | dll_excludes = [ |
---|
| 91 | 'libgdk_pixbuf-2.0-0.dll', |
---|
| 92 | 'libgobject-2.0-0.dll', |
---|
| 93 | 'libgdk-win32-2.0-0.dll', |
---|
| 94 | ] |
---|
| 95 | |
---|
| 96 | target_wx_client = Target( |
---|
[365a17f6] | 97 | description = 'SanView', |
---|
[b30f001] | 98 | script = 'sansview.py', |
---|
| 99 | icon_resources = [(1, "images/ball.ico")], |
---|
| 100 | other_resources = [(24,1,manifest)], |
---|
[365a17f6] | 101 | dest_base = "SansView" |
---|
[b30f001] | 102 | ) |
---|
| 103 | |
---|
| 104 | |
---|
| 105 | |
---|
| 106 | setup( |
---|
| 107 | windows=[target_wx_client], |
---|
| 108 | console=[], |
---|
| 109 | |
---|
| 110 | options={ |
---|
| 111 | 'py2exe': { |
---|
| 112 | 'dll_excludes': dll_excludes, |
---|
| 113 | 'packages' : packages, |
---|
| 114 | 'includes':includes, |
---|
| 115 | 'excludes':excludes, |
---|
| 116 | "compressed": 1, |
---|
| 117 | "optimize": 0, |
---|
| 118 | "bundle_files":2, |
---|
| 119 | }, |
---|
| 120 | }, |
---|
[365a17f6] | 121 | data_files=data_files |
---|
[b30f001] | 122 | |
---|
| 123 | ) |
---|
| 124 | |
---|
| 125 | |
---|