source: sasview/sansview/setup_exe.py @ b71a53b

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 b71a53b was df7a7e3, checked in by Mathieu Doucet <doucetm@…>, 12 years ago

merging category branch

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