source: sasview/sansview/setup_exe.py @ f9505c30

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 f9505c30 was f9505c30, checked in by Jae Cho <jhjcho@…>, 12 years ago

more fix for cleaner config folder

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