source: sasview/sansview/setup_exe.py @ 8bac371

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 8bac371 was a613fe0, checked in by Mathieu Doucet <doucetm@…>, 13 years ago

Re #5 fixing installer build on windows

  • Property mode set to 100644
File size: 6.7 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
39
40
41origIsSystemDLL = py2exe.build_exe.isSystemDLL
42def isSystemDLL(pathname):
43        if os.path.basename(pathname).lower() in ("msvcp71.dll", "comctl32.dll", "msvcr90.dll", "dwmapi.dll"):
44                return 0
45        return origIsSystemDLL(pathname)
46py2exe.build_exe.isSystemDLL = isSystemDLL
47
48if platform.architecture()[0] == '64bit':
49    manifest = """
50       <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
51       <assembly xmlns="urn:schemas-microsoft-com:asm.v1"
52       manifestVersion="1.0">
53       <assemblyIdentity
54           version="0.64.1.0"
55           processorArchitecture="amd64"
56           name="Controls"
57           type="win32"
58       />
59       <description>SansView</description>
60       <dependency>
61           <dependentAssembly>
62               <assemblyIdentity
63                   type="win32"
64                   name="Microsoft.Windows.Common-Controls"
65                   version="6.0.0.0"
66                   processorArchitecture="amd64"
67                   publicKeyToken="6595b64144ccf1df"
68                   language="*"
69               />
70           </dependentAssembly>
71       </dependency>
72       </assembly>
73      """
74else:
75    manifest = """
76       <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
77       <assembly xmlns="urn:schemas-microsoft-com:asm.v1"
78       manifestVersion="1.0">
79       <assemblyIdentity
80           version="0.64.1.0"
81           processorArchitecture="x86"
82           name="Controls"
83           type="win32"
84       />
85       <description>SansView</description>
86       <dependency>
87           <dependentAssembly>
88               <assemblyIdentity
89                   type="win32"
90                   name="Microsoft.Windows.Common-Controls"
91                   version="6.0.0.0"
92                   processorArchitecture="X86"
93                   publicKeyToken="6595b64144ccf1df"
94                   language="*"
95               />
96           </dependentAssembly>
97       </dependency>
98       </assembly>
99      """
100
101   
102class Target:
103    def __init__(self, **kw):
104        self.__dict__.update(kw)
105        # for the versioninfo resources
106        self.version = "2.0.1"
107        self.company_name = "U Tennessee"
108        self.copyright = "copyright 2009 - 2011"
109        self.name = "SansView"
110       
111#
112# Adapted from http://www.py2exe.org/index.cgi/MatPlotLib
113# to use the MatPlotLib.
114#
115path = os.getcwd()
116
117plugins_dir = os.path.join(path, "plugins")
118media_dir = os.path.join(path, "media")
119images_dir = os.path.join(path, "images")
120test_dir = os.path.join(path, "test")
121
122matplotlibdatadir = matplotlib.get_data_path()
123matplotlibdata = findall(matplotlibdatadir)
124data_files = []
125# Copying SLD data
126import periodictable
127import logging
128data_files += periodictable.data_files()
129
130import sans.perspectives.fitting as fitting
131data_files += fitting.data_files()
132
133import sans.perspectives.calculator as calculator
134data_files += calculator.data_files()
135
136import sans.perspectives.invariant as invariant
137data_files += invariant.data_files()
138
139import sans.guiframe as guiframe
140data_files += guiframe.data_files()
141
142import sans.models as models
143data_files += models.data_files()
144
145for f in matplotlibdata:
146    dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:])
147    data_files.append((os.path.split(dirname)[0], [f]))
148
149# Copy the settings file for the sans.dataloader file extension associations
150import sans.dataloader.readers
151f = os.path.join(sans.dataloader.readers.get_data_path(),'defaults.xml')
152if os.path.isfile(f):
153    data_files.append(('.', [f]))
154f = 'custom_config.py'
155if os.path.isfile(f):
156    data_files.append(('.', [f]))
157f = 'local_config.py'
158if os.path.isfile(f):
159    data_files.append(('.', [f]))
160# Copying the images directory to the distribution directory.
161for f in findall(images_dir):
162    if os.path.split(f)[0].count('.svn')==0:
163        data_files.append(("images", [f]))
164
165# Copying the HTML help docs
166for f in findall(media_dir):
167    if os.path.split(f)[0].count('.svn')==0:
168        data_files.append(("media", [f]))
169
170# Copying the sample data user data
171for f in findall(test_dir):
172    if os.path.split(f)[0].count('.svn')==0:
173        data_files.append(("test", [f]))
174       
175# Copying the sample data user data
176for f in findall(plugins_dir):
177    if os.path.split(f)[0].count('.svn')==0:
178        data_files.append(('plugins', [f]))
179
180   
181#
182# packages
183#
184
185packages = ['matplotlib', 'scipy', 'pytz', 'encodings']
186includes = ['site']
187
188# Exclude packages that are not needed but are often found on build systems
189excludes = ['PyQt4','sip','pylab'] 
190
191dll_excludes = [
192    'libgdk_pixbuf-2.0-0.dll', 
193    'libgobject-2.0-0.dll',
194    'libgdk-win32-2.0-0.dll',
195    ]
196
197target_wx_client = Target(
198    description = 'SansView',
199    script = 'sansview.py',
200    icon_resources = [(1, os.path.join(images_dir, "ball.ico"))],
201    other_resources = [(24,1,manifest)],
202    dest_base = "SansView"
203    )
204
205bundle_option = 2
206if platform.architecture()[0] == '64bit':
207    bundle_option = 3
208
209setup(
210    windows=[target_wx_client],
211    console=[],
212   
213    options={
214        'py2exe': {
215            'dll_excludes': dll_excludes,
216            'packages' : packages,
217            'includes':includes,
218            'excludes':excludes,
219            "compressed": 1,
220            "optimize": 0,
221            "bundle_files":bundle_option,
222            },
223    },
224    data_files=data_files,
225   
226)
227
228
Note: See TracBrowser for help on using the repository browser.