source: sasview/sansview/setup_exe.py @ cfe1feb

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 cfe1feb was 8ab3302, checked in by Jae Cho <jhjcho@…>, 13 years ago

fixed a little bit the setting of .sansview folder

  • Property mode set to 100644
File size: 9.6 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.
155py26MSdll_x86 = None
156if sys.version_info >= (3, 0) or sys.version_info < (2, 5):
157    print "*** This script only works with Python 2.5, 2.6, or 2.7."
158    sys.exit()
159elif sys.version_info >= (2, 6):
160    manifest = manifest_for_python26
161    from glob import glob
162    py26MSdll = glob(r"C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*")
163    try:
164        py26MSdll_x86 = glob(r"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*")
165    except:
166        pass
167elif sys.version_info >= (2, 5):
168    manifest = manifest_for_python25
169    py26MSdll = None
170   
171class Target:
172    def __init__(self, **kw):
173        self.__dict__.update(kw)
174        # for the versioninfo resources
175        self.version = "2.0.1"
176        self.company_name = "U Tennessee"
177        self.copyright = "copyright 2009 - 2011"
178        self.name = "SansView"
179       
180#
181# Adapted from http://www.py2exe.org/index.cgi/MatPlotLib
182# to use the MatPlotLib.
183#
184path = os.getcwd()
185
186media_dir = os.path.join(path, "media")
187images_dir = os.path.join(path, "images")
188test_dir = os.path.join(path, "test")
189
190matplotlibdatadir = matplotlib.get_data_path()
191matplotlibdata = findall(matplotlibdatadir)
192data_files = []
193# Copying SLD data
194import periodictable
195import logging
196data_files += periodictable.data_files()
197
198import sans.perspectives.fitting as fitting
199data_files += fitting.data_files()
200
201import sans.perspectives.calculator as calculator
202data_files += calculator.data_files()
203
204import sans.perspectives.invariant as invariant
205data_files += invariant.data_files()
206
207import sans.guiframe as guiframe
208data_files += guiframe.data_files()
209
210import sans.models as models
211data_files += models.data_files()
212
213for f in matplotlibdata:
214    dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:])
215    data_files.append((os.path.split(dirname)[0], [f]))
216
217# Copy the settings file for the sans.dataloader file extension associations
218import sans.dataloader.readers
219f = os.path.join(sans.dataloader.readers.get_data_path(),'defaults.xml')
220if os.path.isfile(f):
221    data_files.append(('.', [f]))
222f = 'custom_config.py'
223if os.path.isfile(f):
224    data_files.append(('.', [f]))
225    data_files.append(('config', [f]))
226f = 'local_config.py'
227if os.path.isfile(f):
228    data_files.append(('.', [f]))
229# Copying the images directory to the distribution directory.
230for f in findall(images_dir):
231    if os.path.split(f)[0].count('.svn')==0:
232        data_files.append(("images", [f]))
233
234# Copying the HTML help docs
235for f in findall(media_dir):
236    if os.path.split(f)[0].count('.svn')==0:
237        data_files.append(("media", [f]))
238
239# Copying the sample data user data
240for f in findall(test_dir):
241    if os.path.split(f)[0].count('.svn')==0:
242        data_files.append(("test", [f]))
243       
244if py26MSdll != None:
245    # install the MSVC 9 runtime dll's into the application folder
246    data_files.append(("Microsoft.VC90.CRT", py26MSdll))
247if py26MSdll_x86 != None:
248    # install the MSVC 9 runtime dll's into the application folder
249    data_files.append(("Microsoft.VC90.CRT", py26MSdll_x86))
250
251
252# packages
253#
254packages = ['matplotlib', 'scipy', 'pytz', 'encodings']
255includes = ['site']
256
257# Exclude packages that are not needed but are often found on build systems
258excludes = ['Tkinter', 'PyQt4', '_ssl', '_tkagg', 'sip']
259
260dll_excludes = ['libgdk_pixbuf-2.0-0.dll',
261                'libgobject-2.0-0.dll',
262                'libgdk-win32-2.0-0.dll',
263                'tcl84.dll',
264                'tk84.dll',
265                'QtGui4.dll',
266                'QtCore4.dll',
267                'msvcp90.dll',
268                'w9xpopen.exe',
269                'cygwin1.dll']
270
271target_wx_client = Target(
272    description = 'SansView',
273    script = 'sansview.py',
274    icon_resources = [(1, os.path.join(images_dir, "ball.ico"))],
275    other_resources = [(24,1,manifest)],
276    dest_base = "SansView"
277    )
278
279bundle_option = 2
280if is_64bits:
281    bundle_option = 3
282
283setup(
284    windows=[target_wx_client],
285    console=[],
286   
287    options={
288        'py2exe': {
289            'dll_excludes': dll_excludes,
290            'packages' : packages,
291            'includes':includes,
292            'excludes':excludes,
293            "compressed": 1,
294            "optimize": 0,
295            "bundle_files":bundle_option,
296            },
297    },
298    data_files=data_files,
299   
300)
301
302
Note: See TracBrowser for help on using the repository browser.