source: sasview/sansview/setup_exe.py @ 762984a

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 762984a was 762984a, checked in by Mathieu Doucet <doucetm@…>, 12 years ago

Re #5 Tune setup_exe.py for 64bit.

  • Property mode set to 100644
File size: 9.4 KB
Line 
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
16import os, sys
17import platform
18
19if len(sys.argv) == 1:
20    sys.argv.append('py2exe')
21# When using the SansView build script, we need to be able to pass
22# an extra path to be added to the python path. The extra arguments
23# should be removed from the list so that the setup processing doesn't
24# fail.
25try:
26    if sys.argv.count('--extrapath'):
27        path_flag_idx = sys.argv.index('--extrapath')
28        extra_path = sys.argv[path_flag_idx+1]
29        sys.path.insert(0, extra_path)
30        del sys.argv[path_flag_idx+1]
31        sys.argv.remove('--extrapath')
32except:
33    print "Error processing extra python path needed to build SansView\n  %s" % sys.exc_value
34
35from distutils.core import setup
36from distutils.filelist import findall
37import matplotlib
38import py2exe
39import shutil
40# Remove the build folder
41shutil.rmtree("build", ignore_errors=True)
42# do the same for dist folder
43shutil.rmtree("dist", ignore_errors=True)
44
45if sys.version_info < (2, 6):
46    origIsSystemDLL = py2exe.build_exe.isSystemDLL
47    def isSystemDLL(pathname):
48            if os.path.basename(pathname).lower() in ("msvcp71.dll", "comctl32.dll"):
49                    return 0
50            return origIsSystemDLL(pathname)
51    py2exe.build_exe.isSystemDLL = isSystemDLL
52
53is_64bits = sys.maxsize > 2**32
54if is_64bits and sys.version_info >= (2, 6):
55    manifest = """
56       <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
57       <assembly xmlns="urn:schemas-microsoft-com:asm.v1"
58       manifestVersion="1.0">
59       <assemblyIdentity
60           version="0.64.1.0"
61           processorArchitecture="amd64"
62           name="Controls"
63           type="win32"
64       />
65       <description>SansView</description>
66       <dependency>
67           <dependentAssembly>
68               <assemblyIdentity
69                   type="win32"
70                   name="Microsoft.Windows.Common-Controls"
71                   version="6.0.0.0"
72                   processorArchitecture="amd64"
73                   publicKeyToken="6595b64144ccf1df"
74                   language="*"
75               />
76           </dependentAssembly>
77       </dependency>
78       </assembly>
79      """
80else:
81    manifest_for_python26 = """
82        <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
83        <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
84          <assemblyIdentity
85            version="5.0.0.0"
86            processorArchitecture="x86"
87            name="SansView"
88            type="win32">
89          </assemblyIdentity>
90          <description>SansView</description>
91          <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
92            <security>
93              <requestedPrivileges>
94                <requestedExecutionLevel
95                  level="asInvoker"
96                  uiAccess="false">
97                </requestedExecutionLevel>
98              </requestedPrivileges>
99            </security>
100          </trustInfo>
101          <dependency>
102            <dependentAssembly>
103              <assemblyIdentity
104                type="win32"
105                name="Microsoft.VC90.CRT"
106                version="9.0.21022.8"
107                processorArchitecture="x86"
108                publicKeyToken="1fc8b3b9a1e18e3b">
109              </assemblyIdentity>
110            </dependentAssembly>
111          </dependency>
112          <dependency>
113            <dependentAssembly>
114              <assemblyIdentity
115                type="win32"
116                name="Microsoft.Windows.Common-Controls"
117                version="6.0.0.0"
118                processorArchitecture="x86"
119                publicKeyToken="6595b64144ccf1df"
120                language="*">
121              </assemblyIdentity>
122            </dependentAssembly>
123          </dependency>
124        </assembly>
125        """
126    manifest_for_python25 = """
127       <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
128       <assembly xmlns="urn:schemas-microsoft-com:asm.v1"
129       manifestVersion="1.0">
130       <assemblyIdentity
131           version="0.64.1.0"
132           processorArchitecture="x86"
133           name="Controls"
134           type="win32"
135       />
136       <description>SansView</description>
137       <dependency>
138           <dependentAssembly>
139               <assemblyIdentity
140                   type="win32"
141                   name="Microsoft.Windows.Common-Controls"
142                   version="6.0.0.0"
143                   processorArchitecture="X86"
144                   publicKeyToken="6595b64144ccf1df"
145                   language="*"
146               />
147           </dependentAssembly>
148       </dependency>
149       </assembly>
150      """
151
152# Select the appropriate manifest to use.
153if sys.version_info >= (3, 0) or sys.version_info < (2, 5):
154    print "*** This script only works with Python 2.5, 2.6, or 2.7."
155    sys.exit()
156elif sys.version_info >= (2, 6):
157    manifest = manifest_for_python26
158    from glob import glob
159    py26MSdll = glob(r"C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*")
160elif sys.version_info >= (2, 5):
161    manifest = manifest_for_python25
162    py26MSdll = None
163   
164class Target:
165    def __init__(self, **kw):
166        self.__dict__.update(kw)
167        # for the versioninfo resources
168        self.version = "2.0.1"
169        self.company_name = "U Tennessee"
170        self.copyright = "copyright 2009 - 2011"
171        self.name = "SansView"
172       
173#
174# Adapted from http://www.py2exe.org/index.cgi/MatPlotLib
175# to use the MatPlotLib.
176#
177path = os.getcwd()
178
179plugins_dir = os.path.join(path, "plugins")
180media_dir = os.path.join(path, "media")
181images_dir = os.path.join(path, "images")
182test_dir = os.path.join(path, "test")
183
184matplotlibdatadir = matplotlib.get_data_path()
185matplotlibdata = findall(matplotlibdatadir)
186data_files = []
187# Copying SLD data
188import periodictable
189import logging
190data_files += periodictable.data_files()
191
192import sans.perspectives.fitting as fitting
193data_files += fitting.data_files()
194
195import sans.perspectives.calculator as calculator
196data_files += calculator.data_files()
197
198import sans.perspectives.invariant as invariant
199data_files += invariant.data_files()
200
201import sans.guiframe as guiframe
202data_files += guiframe.data_files()
203
204import sans.models as models
205data_files += models.data_files()
206
207for f in matplotlibdata:
208    dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:])
209    data_files.append((os.path.split(dirname)[0], [f]))
210
211# Copy the settings file for the sans.dataloader file extension associations
212import sans.dataloader.readers
213f = os.path.join(sans.dataloader.readers.get_data_path(),'defaults.xml')
214if os.path.isfile(f):
215    data_files.append(('.', [f]))
216f = 'custom_config.py'
217if os.path.isfile(f):
218    data_files.append(('.', [f]))
219f = 'local_config.py'
220if os.path.isfile(f):
221    data_files.append(('.', [f]))
222# Copying the images directory to the distribution directory.
223for f in findall(images_dir):
224    if os.path.split(f)[0].count('.svn')==0:
225        data_files.append(("images", [f]))
226
227# Copying the HTML help docs
228for f in findall(media_dir):
229    if os.path.split(f)[0].count('.svn')==0:
230        data_files.append(("media", [f]))
231
232# Copying the sample data user data
233for f in findall(test_dir):
234    if os.path.split(f)[0].count('.svn')==0:
235        data_files.append(("test", [f]))
236       
237# Copying the sample data user data
238for f in findall(plugins_dir):
239    if os.path.split(f)[0].count('.svn')==0:
240        data_files.append(('plugins', [f]))
241       
242if py26MSdll != None:
243    # install the MSVC 9 runtime dll's into the application folder
244    data_files.append(("Microsoft.VC90.CRT", py26MSdll))
245
246# packages
247#
248packages = ['matplotlib', 'scipy', 'pytz', 'encodings']
249includes = ['site']
250
251# Exclude packages that are not needed but are often found on build systems
252excludes = ['Tkinter', 'PyQt4', '_ssl', '_tkagg', 'sip']
253
254dll_excludes = ['libgdk_pixbuf-2.0-0.dll',
255                'libgobject-2.0-0.dll',
256                'libgdk-win32-2.0-0.dll',
257                'tcl84.dll',
258                'tk84.dll',
259                'QtGui4.dll',
260                'QtCore4.dll',
261                'msvcp90.dll',
262                'w9xpopen.exe',
263                'cygwin1.dll']
264
265target_wx_client = Target(
266    description = 'SansView',
267    script = 'sansview.py',
268    icon_resources = [(1, os.path.join(images_dir, "ball.ico"))],
269    other_resources = [(24,1,manifest)],
270    dest_base = "SansView"
271    )
272
273bundle_option = 2
274if is_64bits:
275    bundle_option = 3
276
277setup(
278    windows=[target_wx_client],
279    console=[],
280   
281    options={
282        'py2exe': {
283            'dll_excludes': dll_excludes,
284            'packages' : packages,
285            'includes':includes,
286            'excludes':excludes,
287            "compressed": 1,
288            "optimize": 0,
289            "bundle_files":bundle_option,
290            },
291    },
292    data_files=data_files,
293   
294)
295
296
Note: See TracBrowser for help on using the repository browser.