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
RevLine 
[fa597990]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
[7476d30]17import platform
[80b93da]18import local_config
[df7a7e3]19
[50f4401]20if len(sys.argv) == 1:
21    sys.argv.append('py2exe')
[c329f4d]22# When using the SasView build script, we need to be able to pass
[fa597990]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:
[ea5fa58]34    print "Error processing extra python path needed to build SasView\n  %s" % \
35                sys.exc_value
[fa597990]36
37from distutils.core import setup
38from distutils.filelist import findall
39import matplotlib
[cc37badc]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
[d0f5103]43win32_folder = "win32comext"
[cc37badc]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:]:
[bd26a85]56        modulefinder.AddPackagePath(win32_folder, p)
[cc37badc]57    for extra in ["win32com.shell", "win32com.adsi", "win32com.axcontrol",
[307b1d2]58                    "win32com.axscript", "win32com.bits", "win32com.ifilter",
[cc37badc]59                    "win32com.internet", "win32com.mapi", "win32com.propsys",
60                    "win32com.taskscheduler"]:
[270cc72e]61       
62            __import__(extra)
63            m = sys.modules[extra]
64            for p in m.__path__[1:]:
65                modulefinder.AddPackagePath(extra, p)
66
[cc37badc]67except ImportError:
68    # no build path setup, no worries.
69    pass
70
[fa597990]71import py2exe
[59c6c1e]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)
[fa597990]77
[59c6c1e]78if sys.version_info < (2, 6):
[13bc1b3a]79    is_64bits = False 
[59c6c1e]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
[13bc1b3a]86else:
87    is_64bits = sys.maxsize > 2**32
[a490860]88
[762984a]89if is_64bits and sys.version_info >= (2, 6):
[b08d3cd]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"
[a613fe0]96           processorArchitecture="amd64"
[b08d3cd]97           name="Controls"
98           type="win32"
99       />
[c329f4d]100       <description>SasView</description>
[b08d3cd]101       <dependency>
102           <dependentAssembly>
103               <assemblyIdentity
104                   type="win32"
105                   name="Microsoft.Windows.Common-Controls"
106                   version="6.0.0.0"
[a613fe0]107                   processorArchitecture="amd64"
[b08d3cd]108                   publicKeyToken="6595b64144ccf1df"
109                   language="*"
110               />
111           </dependentAssembly>
112       </dependency>
113       </assembly>
114      """
115else:
[59c6c1e]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"
[c329f4d]122            name="SasView"
[59c6c1e]123            type="win32">
124          </assemblyIdentity>
[c329f4d]125          <description>SasView</description>
[59c6c1e]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 = """
[b08d3cd]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       />
[c329f4d]171       <description>SasView</description>
[b08d3cd]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      """
[fa597990]186
[59c6c1e]187# Select the appropriate manifest to use.
[7983000f]188py26MSdll_x86 = None
[59c6c1e]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\*.*")
[7983000f]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
[59c6c1e]200elif sys.version_info >= (2, 5):
201    manifest = manifest_for_python25
202    py26MSdll = None
[fa597990]203   
204class Target:
205    def __init__(self, **kw):
206        self.__dict__.update(kw)
207        # for the versioninfo resources
[80b93da]208        self.version = local_config.__version__
209        self.company_name = "SasView.org"
210        self.copyright = "copyright 2009 - 2013"
[c329f4d]211        self.name = "SasView"
[fa597990]212       
213#
214# Adapted from http://www.py2exe.org/index.cgi/MatPlotLib
215# to use the MatPlotLib.
216#
[d4c19e5]217path = os.getcwd()
218
[fa597990]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
[d4c19e5]231import sans.perspectives.fitting as fitting
232data_files += fitting.data_files()
233
[fa597990]234import sans.perspectives.calculator as calculator
235data_files += calculator.data_files()
236
237import sans.perspectives.invariant as invariant
238data_files += invariant.data_files()
[d4c19e5]239
[fa597990]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):
[8ab3302]257    data_files.append(('.', [f]))
[f9505c30]258    data_files.append(('config', [f]))
[d4c19e5]259f = 'local_config.py'
260if os.path.isfile(f):
261    data_files.append(('.', [f]))
[ea5fa58]262
263f = 'default_categories.p'
264if os.path.isfile(f):
265    data_files.append(('.', [f]))
[3a6c3b9]266   
267if os.path.isfile("BUILD_NUMBER"):
268    data_files.append(('.',["BUILD_NUMBER"]))
269
[fa597990]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:
[f1044e9]273        data_files.append(("images", [f]))
[fa597990]274
275# Copying the HTML help docs
276for f in findall(media_dir):
277    if os.path.split(f)[0].count('.svn')==0:
[f1044e9]278        data_files.append(("media", [f]))
[fa597990]279
280# Copying the sample data user data
281for f in findall(test_dir):
282    if os.path.split(f)[0].count('.svn')==0:
[f1044e9]283        data_files.append(("test", [f]))
[fa597990]284       
[59c6c1e]285if py26MSdll != None:
286    # install the MSVC 9 runtime dll's into the application folder
287    data_files.append(("Microsoft.VC90.CRT", py26MSdll))
[7983000f]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
[fa597990]292
293# packages
294#
[213b445]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])
[535d9f6]308includes = ['site']
[d42a24b]309
310# Exclude packages that are not needed but are often found on build systems
[59c6c1e]311excludes = ['Tkinter', 'PyQt4', '_ssl', '_tkagg', 'sip']
[fa597990]312
[59c6c1e]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',
[ea32de3]320                'msvcp90.dll',
[59c6c1e]321                'w9xpopen.exe',
322                'cygwin1.dll']
[fa597990]323
324target_wx_client = Target(
[c329f4d]325    description = 'SasView',
[fa597990]326    script = 'sansview.py',
327    icon_resources = [(1, os.path.join(images_dir, "ball.ico"))],
328    other_resources = [(24,1,manifest)],
[c329f4d]329    dest_base = "SasView"
[fa597990]330    )
331
[7476d30]332bundle_option = 2
[762984a]333if is_64bits:
[7476d30]334    bundle_option = 3
[80b93da]335import installer_generator as gen
336gen.generate_installer()
[df7a7e3]337#initialize category stuff
[4f973f3]338#from sans.guiframe.CategoryInstaller import CategoryInstaller
339#CategoryInstaller.check_install()
[df7a7e3]340
[fa597990]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,
[7476d30]352            "bundle_files":bundle_option,
[fa597990]353            },
354    },
355    data_files=data_files,
356   
357)
358
359
Note: See TracBrowser for help on using the repository browser.