1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | # |
---|
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. |
---|
7 | # |
---|
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. |
---|
15 | |
---|
16 | import os, sys |
---|
17 | if len(sys.argv) == 1: |
---|
18 | sys.argv.append('py2exe') |
---|
19 | # When using the SansView build script, we need to be able to pass |
---|
20 | # an extra path to be added to the python path. The extra arguments |
---|
21 | # should be removed from the list so that the setup processing doesn't |
---|
22 | # fail. |
---|
23 | try: |
---|
24 | if sys.argv.count('--extrapath'): |
---|
25 | path_flag_idx = sys.argv.index('--extrapath') |
---|
26 | extra_path = sys.argv[path_flag_idx+1] |
---|
27 | sys.path.insert(0, extra_path) |
---|
28 | del sys.argv[path_flag_idx+1] |
---|
29 | sys.argv.remove('--extrapath') |
---|
30 | except: |
---|
31 | print "Error processing extra python path needed to build SansView\n %s" % sys.exc_value |
---|
32 | |
---|
33 | from distutils.core import setup |
---|
34 | from distutils.filelist import findall |
---|
35 | import matplotlib |
---|
36 | import py2exe |
---|
37 | |
---|
38 | manifest = """ |
---|
39 | <?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
---|
40 | <assembly xmlns="urn:schemas-microsoft-com:asm.v1" |
---|
41 | manifestVersion="1.0"> |
---|
42 | <assemblyIdentity |
---|
43 | version="0.64.1.0" |
---|
44 | processorArchitecture="x86" |
---|
45 | name="Controls" |
---|
46 | type="win32" |
---|
47 | /> |
---|
48 | <description>SansView</description> |
---|
49 | <dependency> |
---|
50 | <dependentAssembly> |
---|
51 | <assemblyIdentity |
---|
52 | type="win32" |
---|
53 | name="Microsoft.VC90.CRT" |
---|
54 | version="9.0.21022.8" |
---|
55 | processorArchitecture="x86" |
---|
56 | publicKeyToken="1fc8b3b9a1e18e3b"> |
---|
57 | </assemblyIdentity> |
---|
58 | </dependentAssembly> |
---|
59 | </dependency> |
---|
60 | </assembly> |
---|
61 | """ |
---|
62 | |
---|
63 | |
---|
64 | class Target: |
---|
65 | def __init__(self, **kw): |
---|
66 | self.__dict__.update(kw) |
---|
67 | # for the versioninfo resources |
---|
68 | self.version = "1.0" |
---|
69 | self.company_name = "U Tennessee" |
---|
70 | self.copyright = "copyright 2009" |
---|
71 | self.name = "SansViewTool" |
---|
72 | |
---|
73 | # |
---|
74 | # Adapted from http://www.py2exe.org/index.cgi/MatPlotLib |
---|
75 | # to use the MatPlotLib. |
---|
76 | # |
---|
77 | matplotlibdatadir = matplotlib.get_data_path() |
---|
78 | matplotlibdata = findall(matplotlibdatadir) |
---|
79 | data_files = [] |
---|
80 | # Copying SLD data |
---|
81 | import periodictable |
---|
82 | import logging |
---|
83 | data_files += periodictable.data_files() |
---|
84 | |
---|
85 | import sans.perspectives.calculator as calculator |
---|
86 | data_files += calculator.data_files() |
---|
87 | |
---|
88 | for f in matplotlibdata: |
---|
89 | dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:]) |
---|
90 | data_files.append((os.path.split(dirname)[0], [f])) |
---|
91 | |
---|
92 | # Copying the images directory to the distribution directory. |
---|
93 | import sans.perspectives.calculator as cal |
---|
94 | path = cal.get_data_path('images') |
---|
95 | for f in findall(path): |
---|
96 | if os.path.split(f)[0].count('.svn')==0: |
---|
97 | data_files.append(('images', [f])) |
---|
98 | import sans.guiframe as guiframe |
---|
99 | data_files += guiframe.data_files() |
---|
100 | # Copy the settings file for the DataLoader file extension associations |
---|
101 | import sans.dataloader.readers |
---|
102 | f = os.path.join(sans.dataloader.readers.get_data_path(),'defaults.xml') |
---|
103 | if os.path.isfile(f): |
---|
104 | data_files.append(('.', [f])) |
---|
105 | f = 'custom_config.py' |
---|
106 | if os.path.isfile(f): |
---|
107 | data_files.append(('.', [f])) |
---|
108 | f = 'local_config.py' |
---|
109 | if os.path.isfile(f): |
---|
110 | data_files.append(('.', [f])) |
---|
111 | # Copying the HTML help docs |
---|
112 | path = cal.get_data_path('media') |
---|
113 | for f in findall(path): |
---|
114 | if os.path.split(f)[0].count('.svn')==0: |
---|
115 | data_files.append((os.path.split(f)[0], [f])) |
---|
116 | |
---|
117 | from glob import glob |
---|
118 | py26MSdll = glob(r"C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*") |
---|
119 | # install the MSVC 9 runtime dll's into the application folder |
---|
120 | #data_files += [("", py26MSdll),] |
---|
121 | data_files.append(("Microsoft.VC90.CRT", py26MSdll)) |
---|
122 | # ("lib\Microsoft.VC90.CRT", py26MSdll)] |
---|
123 | #sys.path.append("Microsoft.VC90.CRT") |
---|
124 | |
---|
125 | mfcdir = "C:\Python27\Lib\site-packages\pythonwin" |
---|
126 | mfcfiles = [os.path.join(mfcdir, i) for i in ["mfc90.dll", "mfc90u.dll", "mfcm90.dll", "mfcm90u.dll", "Microsoft.VC90.MFC.manifest"]] |
---|
127 | data_files.append(("Microsoft.VC90.MFC", mfcfiles)) |
---|
128 | |
---|
129 | |
---|
130 | # |
---|
131 | # packages |
---|
132 | # |
---|
133 | packages = ['matplotlib', 'pytz','encodings', 'scipy'] |
---|
134 | includes = ['site'] |
---|
135 | |
---|
136 | excludes = ['Tkinter', 'PyQt4', '_ssl', '_tkagg'] |
---|
137 | |
---|
138 | dll_excludes = ['libgdk_pixbuf-2.0-0.dll', |
---|
139 | 'libgobject-2.0-0.dll', |
---|
140 | 'libgdk-win32-2.0-0.dll', |
---|
141 | 'tcl84.dll', |
---|
142 | 'tk84.dll', |
---|
143 | 'QtGui4.dll', |
---|
144 | 'QtCore4.dll', |
---|
145 | 'w9xpopen.exe', |
---|
146 | 'cygwin1.dll'] |
---|
147 | |
---|
148 | target_wx_client = Target( |
---|
149 | description = 'SansViewTool', |
---|
150 | script = 'sansviewtool.py', |
---|
151 | #icon_resources = [(1, "images/ball.ico")], |
---|
152 | other_resources = [(24,1,manifest)], |
---|
153 | dest_base = "SansViewTool" |
---|
154 | ) |
---|
155 | |
---|
156 | |
---|
157 | |
---|
158 | setup( |
---|
159 | windows=[target_wx_client], |
---|
160 | console=[], |
---|
161 | |
---|
162 | options={ |
---|
163 | 'py2exe': { |
---|
164 | 'dll_excludes': dll_excludes, |
---|
165 | 'packages' : packages, |
---|
166 | 'includes':includes, |
---|
167 | 'excludes':excludes, |
---|
168 | "compressed": 1, |
---|
169 | "optimize": 0, |
---|
170 | "bundle_files":2, |
---|
171 | }, |
---|
172 | }, |
---|
173 | data_files=data_files, |
---|
174 | |
---|
175 | ) |
---|
176 | |
---|
177 | |
---|