source: sasview/sansview/setup_exe.py @ 0571738

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 0571738 was 0571738, checked in by pkienzle, 10 years ago

try forcing windows build to download bumps, etc

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