source: sasview/sansview/setup_exe.py @ 162c778

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

changed sansview name to sansview (gui only)

  • Property mode set to 100644
File size: 11.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 SasView 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 SasView\n  %s" % sys.exc_value
34
35from distutils.core import setup
36from distutils.filelist import findall
37import matplotlib
38
39# Solution taken from here: http://www.py2exe.org/index.cgi/win32com.shell
40# ModuleFinder can't handle runtime changes to __path__, but win32com uses them
41win32_folder = "win32comext"
42try:
43    # py2exe 0.6.4 introduced a replacement modulefinder.
44    # This means we have to add package paths there, not to the built-in
45    # one.  If this new modulefinder gets integrated into Python, then
46    # we might be able to revert this some day.
47    # if this doesn't work, try import modulefinder
48    try:
49        import py2exe.mf as modulefinder
50    except ImportError:
51        import modulefinder
52    import win32com, sys
53    for p in win32com.__path__[1:]:
54        modulefinder.AddPackagePath(win32_folder, p)
55    for extra in ["win32com.shell", "win32com.adsi", "win32com.axcontrol",
56                    "win32com.axscript", "win32com.bits", "win32com.ifilter",
57                    "win32com.internet", "win32com.mapi", "win32com.propsys",
58                    "win32com.taskscheduler"]:
59       
60            __import__(extra)
61            m = sys.modules[extra]
62            for p in m.__path__[1:]:
63                modulefinder.AddPackagePath(extra, p)
64
65except ImportError:
66    # no build path setup, no worries.
67    pass
68
69import py2exe
70import shutil
71# Remove the build folder
72shutil.rmtree("build", ignore_errors=True)
73# do the same for dist folder
74shutil.rmtree("dist", ignore_errors=True)
75
76if sys.version_info < (2, 6):
77    is_64bits = False 
78    origIsSystemDLL = py2exe.build_exe.isSystemDLL
79    def isSystemDLL(pathname):
80            if os.path.basename(pathname).lower() in ("msvcp71.dll", "comctl32.dll"):
81                    return 0
82            return origIsSystemDLL(pathname)
83    py2exe.build_exe.isSystemDLL = isSystemDLL
84else:
85    is_64bits = sys.maxsize > 2**32
86
87if is_64bits and sys.version_info >= (2, 6):
88    manifest = """
89       <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
90       <assembly xmlns="urn:schemas-microsoft-com:asm.v1"
91       manifestVersion="1.0">
92       <assemblyIdentity
93           version="0.64.1.0"
94           processorArchitecture="amd64"
95           name="Controls"
96           type="win32"
97       />
98       <description>SasView</description>
99       <dependency>
100           <dependentAssembly>
101               <assemblyIdentity
102                   type="win32"
103                   name="Microsoft.Windows.Common-Controls"
104                   version="6.0.0.0"
105                   processorArchitecture="amd64"
106                   publicKeyToken="6595b64144ccf1df"
107                   language="*"
108               />
109           </dependentAssembly>
110       </dependency>
111       </assembly>
112      """
113else:
114    manifest_for_python26 = """
115        <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
116        <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
117          <assemblyIdentity
118            version="5.0.0.0"
119            processorArchitecture="x86"
120            name="SasView"
121            type="win32">
122          </assemblyIdentity>
123          <description>SasView</description>
124          <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
125            <security>
126              <requestedPrivileges>
127                <requestedExecutionLevel
128                  level="asInvoker"
129                  uiAccess="false">
130                </requestedExecutionLevel>
131              </requestedPrivileges>
132            </security>
133          </trustInfo>
134          <dependency>
135            <dependentAssembly>
136              <assemblyIdentity
137                type="win32"
138                name="Microsoft.VC90.CRT"
139                version="9.0.21022.8"
140                processorArchitecture="x86"
141                publicKeyToken="1fc8b3b9a1e18e3b">
142              </assemblyIdentity>
143            </dependentAssembly>
144          </dependency>
145          <dependency>
146            <dependentAssembly>
147              <assemblyIdentity
148                type="win32"
149                name="Microsoft.Windows.Common-Controls"
150                version="6.0.0.0"
151                processorArchitecture="x86"
152                publicKeyToken="6595b64144ccf1df"
153                language="*">
154              </assemblyIdentity>
155            </dependentAssembly>
156          </dependency>
157        </assembly>
158        """
159    manifest_for_python25 = """
160       <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
161       <assembly xmlns="urn:schemas-microsoft-com:asm.v1"
162       manifestVersion="1.0">
163       <assemblyIdentity
164           version="0.64.1.0"
165           processorArchitecture="x86"
166           name="Controls"
167           type="win32"
168       />
169       <description>SasView</description>
170       <dependency>
171           <dependentAssembly>
172               <assemblyIdentity
173                   type="win32"
174                   name="Microsoft.Windows.Common-Controls"
175                   version="6.0.0.0"
176                   processorArchitecture="X86"
177                   publicKeyToken="6595b64144ccf1df"
178                   language="*"
179               />
180           </dependentAssembly>
181       </dependency>
182       </assembly>
183      """
184
185# Select the appropriate manifest to use.
186py26MSdll_x86 = None
187if sys.version_info >= (3, 0) or sys.version_info < (2, 5):
188    print "*** This script only works with Python 2.5, 2.6, or 2.7."
189    sys.exit()
190elif sys.version_info >= (2, 6):
191    manifest = manifest_for_python26
192    from glob import glob
193    py26MSdll = glob(r"C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*")
194    try:
195        py26MSdll_x86 = glob(r"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*")
196    except:
197        pass
198elif sys.version_info >= (2, 5):
199    manifest = manifest_for_python25
200    py26MSdll = None
201   
202class Target:
203    def __init__(self, **kw):
204        self.__dict__.update(kw)
205        # for the versioninfo resources
206        self.version = "2.1.0"
207        self.company_name = "U Tennessee"
208        self.copyright = "copyright 2009 - 2012"
209        self.name = "SasView"
210       
211#
212# Adapted from http://www.py2exe.org/index.cgi/MatPlotLib
213# to use the MatPlotLib.
214#
215path = os.getcwd()
216
217media_dir = os.path.join(path, "media")
218images_dir = os.path.join(path, "images")
219test_dir = os.path.join(path, "test")
220
221matplotlibdatadir = matplotlib.get_data_path()
222matplotlibdata = findall(matplotlibdatadir)
223data_files = []
224# Copying SLD data
225import periodictable
226import logging
227data_files += periodictable.data_files()
228
229import sans.perspectives.fitting as fitting
230data_files += fitting.data_files()
231
232import sans.perspectives.calculator as calculator
233data_files += calculator.data_files()
234
235import sans.perspectives.invariant as invariant
236data_files += invariant.data_files()
237
238import sans.guiframe as guiframe
239data_files += guiframe.data_files()
240
241import sans.models as models
242data_files += models.data_files()
243
244for f in matplotlibdata:
245    dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:])
246    data_files.append((os.path.split(dirname)[0], [f]))
247
248# Copy the settings file for the sans.dataloader file extension associations
249import sans.dataloader.readers
250f = os.path.join(sans.dataloader.readers.get_data_path(),'defaults.xml')
251if os.path.isfile(f):
252    data_files.append(('.', [f]))
253f = 'custom_config.py'
254if os.path.isfile(f):
255    data_files.append(('.', [f]))
256    data_files.append(('config', [f]))
257f = 'local_config.py'
258if os.path.isfile(f):
259    data_files.append(('.', [f]))
260   
261if os.path.isfile("BUILD_NUMBER"):
262    data_files.append(('.',["BUILD_NUMBER"]))
263
264# Copying the images directory to the distribution directory.
265for f in findall(images_dir):
266    if os.path.split(f)[0].count('.svn')==0:
267        data_files.append(("images", [f]))
268
269# Copying the HTML help docs
270for f in findall(media_dir):
271    if os.path.split(f)[0].count('.svn')==0:
272        data_files.append(("media", [f]))
273
274# Copying the sample data user data
275for f in findall(test_dir):
276    if os.path.split(f)[0].count('.svn')==0:
277        data_files.append(("test", [f]))
278       
279if py26MSdll != None:
280    # install the MSVC 9 runtime dll's into the application folder
281    data_files.append(("Microsoft.VC90.CRT", py26MSdll))
282if py26MSdll_x86 != None:
283    # install the MSVC 9 runtime dll's into the application folder
284    data_files.append(("Microsoft.VC90.CRT", py26MSdll_x86))
285
286
287# packages
288#
289packages = ['matplotlib', 'scipy', 'pytz', 'encodings', 'comtypes', 'win32com', 'ho.pisa']
290packages.extend([
291'reportlab',
292'reportlab.graphics.charts',
293'reportlab.graphics.samples',
294'reportlab.graphics.widgets',
295'reportlab.graphics.barcode',
296'reportlab.graphics',
297'reportlab.lib',
298'reportlab.pdfbase',
299'reportlab.pdfgen',
300'reportlab.platypus',
301])
302includes = ['site']
303
304# Exclude packages that are not needed but are often found on build systems
305excludes = ['Tkinter', 'PyQt4', '_ssl', '_tkagg', 'sip']
306
307dll_excludes = ['libgdk_pixbuf-2.0-0.dll',
308                'libgobject-2.0-0.dll',
309                'libgdk-win32-2.0-0.dll',
310                'tcl84.dll',
311                'tk84.dll',
312                'QtGui4.dll',
313                'QtCore4.dll',
314                'msvcp90.dll',
315                'w9xpopen.exe',
316                'cygwin1.dll']
317
318target_wx_client = Target(
319    description = 'SasView',
320    script = 'sansview.py',
321    icon_resources = [(1, os.path.join(images_dir, "ball.ico"))],
322    other_resources = [(24,1,manifest)],
323    dest_base = "SasView"
324    )
325
326bundle_option = 2
327if is_64bits:
328    bundle_option = 3
329
330setup(
331    windows=[target_wx_client],
332    console=[],
333    options={
334        'py2exe': {
335            'dll_excludes': dll_excludes,
336            'packages' : packages,
337            'includes':includes,
338            'excludes':excludes,
339            "compressed": 1,
340            "optimize": 0,
341            "bundle_files":bundle_option,
342            },
343    },
344    data_files=data_files,
345   
346)
347
348
Note: See TracBrowser for help on using the repository browser.