source: sasview/sansview/setup_exe.py @ 7a7dbf4

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

Re #5 fixing installer build on windows

  • Property mode set to 100644
File size: 5.7 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
19if len(sys.argv) == 1:
20    sys.argv.append('py2exe')
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
39
40
41origIsSystemDLL = py2exe.build_exe.isSystemDLL
42def isSystemDLL(pathname):
43        if os.path.basename(pathname).lower() in ("msvcp71.dll", "msvcr90.dll", "dwmapi.dll"):
44                return 0
45        return origIsSystemDLL(pathname)
46py2exe.build_exe.isSystemDLL = isSystemDLL
47
48
49manifest = """
50   <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
51   <assembly xmlns="urn:schemas-microsoft-com:asm.v1"
52   manifestVersion="1.0">
53   <assemblyIdentity
54       version="0.64.1.0"
55       processorArchitecture="x86"
56       name="Controls"
57       type="win32"
58   />
59   <description>SansView</description>
60   <dependency>
61       <dependentAssembly>
62           <assemblyIdentity
63               type="win32"
64               name="Microsoft.Windows.Common-Controls"
65               version="6.0.0.0"
66               processorArchitecture="X86"
67               publicKeyToken="6595b64144ccf1df"
68               language="*"
69           />
70       </dependentAssembly>
71   </dependency>
72   </assembly>
73  """
74
75   
76class Target:
77    def __init__(self, **kw):
78        self.__dict__.update(kw)
79        # for the versioninfo resources
80        self.version = "2.0.1"
81        self.company_name = "U Tennessee"
82        self.copyright = "copyright 2009 - 2011"
83        self.name = "SansView"
84       
85#
86# Adapted from http://www.py2exe.org/index.cgi/MatPlotLib
87# to use the MatPlotLib.
88#
89path = os.getcwd()
90
91plugins_dir = os.path.join(path, "plugins")
92media_dir = os.path.join(path, "media")
93images_dir = os.path.join(path, "images")
94test_dir = os.path.join(path, "test")
95
96matplotlibdatadir = matplotlib.get_data_path()
97matplotlibdata = findall(matplotlibdatadir)
98data_files = []
99# Copying SLD data
100import periodictable
101import logging
102data_files += periodictable.data_files()
103
104import sans.perspectives.fitting as fitting
105data_files += fitting.data_files()
106
107import sans.perspectives.calculator as calculator
108data_files += calculator.data_files()
109
110import sans.perspectives.invariant as invariant
111data_files += invariant.data_files()
112
113import sans.guiframe as guiframe
114data_files += guiframe.data_files()
115
116import sans.models as models
117data_files += models.data_files()
118
119for f in matplotlibdata:
120    dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:])
121    data_files.append((os.path.split(dirname)[0], [f]))
122
123# Copy the settings file for the sans.dataloader file extension associations
124import sans.dataloader.readers
125f = os.path.join(sans.dataloader.readers.get_data_path(),'defaults.xml')
126if os.path.isfile(f):
127    data_files.append(('.', [f]))
128f = 'custom_config.py'
129if os.path.isfile(f):
130    data_files.append(('.', [f]))
131f = 'local_config.py'
132if os.path.isfile(f):
133    data_files.append(('.', [f]))
134# Copying the images directory to the distribution directory.
135for f in findall(images_dir):
136    if os.path.split(f)[0].count('.svn')==0:
137        data_files.append(("images", [f]))
138
139# Copying the HTML help docs
140for f in findall(media_dir):
141    if os.path.split(f)[0].count('.svn')==0:
142        data_files.append(("media", [f]))
143
144# Copying the sample data user data
145for f in findall(test_dir):
146    if os.path.split(f)[0].count('.svn')==0:
147        data_files.append(("test", [f]))
148       
149# Copying the sample data user data
150for f in findall(plugins_dir):
151    if os.path.split(f)[0].count('.svn')==0:
152        data_files.append(('plugins', [f]))
153
154   
155#
156# packages
157#
158
159packages = ['matplotlib', 'scipy', 'pytz', 'encodings']
160includes = ['site']
161
162# Exclude packages that are not needed but are often found on build systems
163excludes = ['PyQt4','sip','pylab'] 
164
165dll_excludes = [
166    'libgdk_pixbuf-2.0-0.dll', 
167    'libgobject-2.0-0.dll',
168    'libgdk-win32-2.0-0.dll',
169    ]
170
171target_wx_client = Target(
172    description = 'SansView',
173    script = 'sansview.py',
174    icon_resources = [(1, os.path.join(images_dir, "ball.ico"))],
175    other_resources = [(24,1,manifest)],
176    dest_base = "SansView"
177    )
178
179bundle_option = 2
180if platform.architecture()[0] == '64bit':
181    bundle_option = 3
182
183setup(
184    windows=[target_wx_client],
185    console=[],
186   
187    options={
188        'py2exe': {
189            'dll_excludes': dll_excludes,
190            'packages' : packages,
191            'includes':includes,
192            'excludes':excludes,
193            "compressed": 1,
194            "optimize": 0,
195            "bundle_files":bundle_option,
196            },
197    },
198    data_files=data_files,
199   
200)
201
202
Note: See TracBrowser for help on using the repository browser.