source: sasview/sansview/setup_exe.py @ bfcae3c

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 bfcae3c was ac2ceb9b, checked in by Mathieu Doucet <doucetm@…>, 13 years ago

Re #3 Clean up

  • Property mode set to 100644
File size: 9.2 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
[535d9f6]18
[50f4401]19if len(sys.argv) == 1:
20    sys.argv.append('py2exe')
[fa597990]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
[59c6c1e]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)
[fa597990]44
[59c6c1e]45if sys.version_info < (2, 6):
46    origIsSystemDLL = py2exe.build_exe.isSystemDLL
47    def isSystemDLL(pathname):
48            if os.path.basename(pathname).lower() in ("msvcp71.dll", "comctl32.dll"):
49                    return 0
50            return origIsSystemDLL(pathname)
51    py2exe.build_exe.isSystemDLL = isSystemDLL
[a490860]52
[762984a]53is_64bits = sys.maxsize > 2**32
54if is_64bits and sys.version_info >= (2, 6):
[b08d3cd]55    manifest = """
56       <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
57       <assembly xmlns="urn:schemas-microsoft-com:asm.v1"
58       manifestVersion="1.0">
59       <assemblyIdentity
60           version="0.64.1.0"
[a613fe0]61           processorArchitecture="amd64"
[b08d3cd]62           name="Controls"
63           type="win32"
64       />
65       <description>SansView</description>
66       <dependency>
67           <dependentAssembly>
68               <assemblyIdentity
69                   type="win32"
70                   name="Microsoft.Windows.Common-Controls"
71                   version="6.0.0.0"
[a613fe0]72                   processorArchitecture="amd64"
[b08d3cd]73                   publicKeyToken="6595b64144ccf1df"
74                   language="*"
75               />
76           </dependentAssembly>
77       </dependency>
78       </assembly>
79      """
80else:
[59c6c1e]81    manifest_for_python26 = """
82        <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
83        <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
84          <assemblyIdentity
85            version="5.0.0.0"
86            processorArchitecture="x86"
87            name="SansView"
88            type="win32">
89          </assemblyIdentity>
90          <description>SansView</description>
91          <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
92            <security>
93              <requestedPrivileges>
94                <requestedExecutionLevel
95                  level="asInvoker"
96                  uiAccess="false">
97                </requestedExecutionLevel>
98              </requestedPrivileges>
99            </security>
100          </trustInfo>
101          <dependency>
102            <dependentAssembly>
103              <assemblyIdentity
104                type="win32"
105                name="Microsoft.VC90.CRT"
106                version="9.0.21022.8"
107                processorArchitecture="x86"
108                publicKeyToken="1fc8b3b9a1e18e3b">
109              </assemblyIdentity>
110            </dependentAssembly>
111          </dependency>
112          <dependency>
113            <dependentAssembly>
114              <assemblyIdentity
115                type="win32"
116                name="Microsoft.Windows.Common-Controls"
117                version="6.0.0.0"
118                processorArchitecture="x86"
119                publicKeyToken="6595b64144ccf1df"
120                language="*">
121              </assemblyIdentity>
122            </dependentAssembly>
123          </dependency>
124        </assembly>
125        """
126    manifest_for_python25 = """
[b08d3cd]127       <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
128       <assembly xmlns="urn:schemas-microsoft-com:asm.v1"
129       manifestVersion="1.0">
130       <assemblyIdentity
131           version="0.64.1.0"
132           processorArchitecture="x86"
133           name="Controls"
134           type="win32"
135       />
136       <description>SansView</description>
137       <dependency>
138           <dependentAssembly>
139               <assemblyIdentity
140                   type="win32"
141                   name="Microsoft.Windows.Common-Controls"
142                   version="6.0.0.0"
143                   processorArchitecture="X86"
144                   publicKeyToken="6595b64144ccf1df"
145                   language="*"
146               />
147           </dependentAssembly>
148       </dependency>
149       </assembly>
150      """
[fa597990]151
[59c6c1e]152# Select the appropriate manifest to use.
153if sys.version_info >= (3, 0) or sys.version_info < (2, 5):
154    print "*** This script only works with Python 2.5, 2.6, or 2.7."
155    sys.exit()
156elif sys.version_info >= (2, 6):
157    manifest = manifest_for_python26
158    from glob import glob
159    py26MSdll = glob(r"C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*")
160elif sys.version_info >= (2, 5):
161    manifest = manifest_for_python25
162    py26MSdll = None
[fa597990]163   
164class Target:
165    def __init__(self, **kw):
166        self.__dict__.update(kw)
167        # for the versioninfo resources
[2d74016]168        self.version = "2.0.1"
[fa597990]169        self.company_name = "U Tennessee"
[50f4401]170        self.copyright = "copyright 2009 - 2011"
[fa597990]171        self.name = "SansView"
172       
173#
174# Adapted from http://www.py2exe.org/index.cgi/MatPlotLib
175# to use the MatPlotLib.
176#
[d4c19e5]177path = os.getcwd()
178
[fa597990]179media_dir = os.path.join(path, "media")
180images_dir = os.path.join(path, "images")
181test_dir = os.path.join(path, "test")
182
183matplotlibdatadir = matplotlib.get_data_path()
184matplotlibdata = findall(matplotlibdatadir)
185data_files = []
186# Copying SLD data
187import periodictable
188import logging
189data_files += periodictable.data_files()
190
[d4c19e5]191import sans.perspectives.fitting as fitting
192data_files += fitting.data_files()
193
[fa597990]194import sans.perspectives.calculator as calculator
195data_files += calculator.data_files()
196
197import sans.perspectives.invariant as invariant
198data_files += invariant.data_files()
[d4c19e5]199
[fa597990]200import sans.guiframe as guiframe
201data_files += guiframe.data_files()
202
203import sans.models as models
204data_files += models.data_files()
205
206for f in matplotlibdata:
207    dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:])
208    data_files.append((os.path.split(dirname)[0], [f]))
209
210# Copy the settings file for the sans.dataloader file extension associations
211import sans.dataloader.readers
212f = os.path.join(sans.dataloader.readers.get_data_path(),'defaults.xml')
213if os.path.isfile(f):
214    data_files.append(('.', [f]))
215f = 'custom_config.py'
216if os.path.isfile(f):
217    data_files.append(('.', [f]))
[d4c19e5]218f = 'local_config.py'
219if os.path.isfile(f):
220    data_files.append(('.', [f]))
[fa597990]221# Copying the images directory to the distribution directory.
222for f in findall(images_dir):
223    if os.path.split(f)[0].count('.svn')==0:
[f1044e9]224        data_files.append(("images", [f]))
[fa597990]225
226# Copying the HTML help docs
227for f in findall(media_dir):
228    if os.path.split(f)[0].count('.svn')==0:
[f1044e9]229        data_files.append(("media", [f]))
[fa597990]230
231# Copying the sample data user data
232for f in findall(test_dir):
233    if os.path.split(f)[0].count('.svn')==0:
[f1044e9]234        data_files.append(("test", [f]))
[fa597990]235       
[59c6c1e]236if py26MSdll != None:
237    # install the MSVC 9 runtime dll's into the application folder
238    data_files.append(("Microsoft.VC90.CRT", py26MSdll))
[fa597990]239
240# packages
241#
[bb64650]242packages = ['matplotlib', 'scipy', 'pytz', 'encodings']
[535d9f6]243includes = ['site']
[d42a24b]244
245# Exclude packages that are not needed but are often found on build systems
[59c6c1e]246excludes = ['Tkinter', 'PyQt4', '_ssl', '_tkagg', 'sip']
[fa597990]247
[59c6c1e]248dll_excludes = ['libgdk_pixbuf-2.0-0.dll',
249                'libgobject-2.0-0.dll',
250                'libgdk-win32-2.0-0.dll',
251                'tcl84.dll',
252                'tk84.dll',
253                'QtGui4.dll',
254                'QtCore4.dll',
[ea32de3]255                'msvcp90.dll',
[59c6c1e]256                'w9xpopen.exe',
257                'cygwin1.dll']
[fa597990]258
259target_wx_client = Target(
260    description = 'SansView',
261    script = 'sansview.py',
262    icon_resources = [(1, os.path.join(images_dir, "ball.ico"))],
263    other_resources = [(24,1,manifest)],
264    dest_base = "SansView"
265    )
266
[7476d30]267bundle_option = 2
[762984a]268if is_64bits:
[7476d30]269    bundle_option = 3
[fa597990]270
271setup(
272    windows=[target_wx_client],
273    console=[],
274   
275    options={
276        'py2exe': {
277            'dll_excludes': dll_excludes,
278            'packages' : packages,
279            'includes':includes,
280            'excludes':excludes,
281            "compressed": 1,
282            "optimize": 0,
[7476d30]283            "bundle_files":bundle_option,
[fa597990]284            },
285    },
286    data_files=data_files,
287   
288)
289
290
Note: See TracBrowser for help on using the repository browser.