source: sasview/sansview/setup_exe.py @ e090c624

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

automatically regenerate installer.iss by setup_exe

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