[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 | |
---|
| 16 | import os, sys |
---|
[535d9f6] | 17 | |
---|
[50f4401] | 18 | if len(sys.argv) == 1: |
---|
| 19 | sys.argv.append('py2exe') |
---|
[fa597990] | 20 | # When using the SansView build script, we need to be able to pass |
---|
| 21 | # an extra path to be added to the python path. The extra arguments |
---|
| 22 | # should be removed from the list so that the setup processing doesn't |
---|
| 23 | # fail. |
---|
| 24 | try: |
---|
| 25 | if sys.argv.count('--extrapath'): |
---|
| 26 | path_flag_idx = sys.argv.index('--extrapath') |
---|
| 27 | extra_path = sys.argv[path_flag_idx+1] |
---|
| 28 | sys.path.insert(0, extra_path) |
---|
| 29 | del sys.argv[path_flag_idx+1] |
---|
| 30 | sys.argv.remove('--extrapath') |
---|
| 31 | except: |
---|
| 32 | print "Error processing extra python path needed to build SansView\n %s" % sys.exc_value |
---|
| 33 | |
---|
| 34 | from distutils.core import setup |
---|
| 35 | from distutils.filelist import findall |
---|
| 36 | import matplotlib |
---|
| 37 | import py2exe |
---|
| 38 | |
---|
[a490860] | 39 | |
---|
| 40 | origIsSystemDLL = py2exe.build_exe.isSystemDLL |
---|
| 41 | def isSystemDLL(pathname): |
---|
| 42 | if os.path.basename(pathname).lower() in ("msvcp71.dll", "dwmapi.dll"): |
---|
| 43 | return 0 |
---|
| 44 | return origIsSystemDLL(pathname) |
---|
| 45 | py2exe.build_exe.isSystemDLL = isSystemDLL |
---|
| 46 | |
---|
| 47 | |
---|
[fa597990] | 48 | manifest = """ |
---|
| 49 | <?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
---|
| 50 | <assembly xmlns="urn:schemas-microsoft-com:asm.v1" |
---|
| 51 | manifestVersion="1.0"> |
---|
| 52 | <assemblyIdentity |
---|
| 53 | version="0.64.1.0" |
---|
| 54 | processorArchitecture="x86" |
---|
| 55 | name="Controls" |
---|
| 56 | type="win32" |
---|
| 57 | /> |
---|
| 58 | <description>SansView</description> |
---|
| 59 | <dependency> |
---|
| 60 | <dependentAssembly> |
---|
| 61 | <assemblyIdentity |
---|
| 62 | type="win32" |
---|
| 63 | name="Microsoft.Windows.Common-Controls" |
---|
| 64 | version="6.0.0.0" |
---|
| 65 | processorArchitecture="X86" |
---|
| 66 | publicKeyToken="6595b64144ccf1df" |
---|
| 67 | language="*" |
---|
| 68 | /> |
---|
| 69 | </dependentAssembly> |
---|
| 70 | </dependency> |
---|
| 71 | </assembly> |
---|
| 72 | """ |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | class Target: |
---|
| 76 | def __init__(self, **kw): |
---|
| 77 | self.__dict__.update(kw) |
---|
| 78 | # for the versioninfo resources |
---|
[50f4401] | 79 | self.version = "1.9.2Dev" |
---|
[fa597990] | 80 | self.company_name = "U Tennessee" |
---|
[50f4401] | 81 | self.copyright = "copyright 2009 - 2011" |
---|
[fa597990] | 82 | self.name = "SansView" |
---|
| 83 | |
---|
| 84 | # |
---|
| 85 | # Adapted from http://www.py2exe.org/index.cgi/MatPlotLib |
---|
| 86 | # to use the MatPlotLib. |
---|
| 87 | # |
---|
[d4c19e5] | 88 | path = os.getcwd() |
---|
| 89 | |
---|
[fa597990] | 90 | plugins_dir = os.path.join(path, "plugins") |
---|
| 91 | media_dir = os.path.join(path, "media") |
---|
| 92 | images_dir = os.path.join(path, "images") |
---|
| 93 | test_dir = os.path.join(path, "test") |
---|
| 94 | |
---|
| 95 | matplotlibdatadir = matplotlib.get_data_path() |
---|
| 96 | matplotlibdata = findall(matplotlibdatadir) |
---|
| 97 | data_files = [] |
---|
| 98 | # Copying SLD data |
---|
| 99 | import periodictable |
---|
| 100 | import logging |
---|
| 101 | data_files += periodictable.data_files() |
---|
| 102 | |
---|
[d4c19e5] | 103 | import sans.perspectives.fitting as fitting |
---|
| 104 | data_files += fitting.data_files() |
---|
| 105 | |
---|
[fa597990] | 106 | import sans.perspectives.calculator as calculator |
---|
| 107 | data_files += calculator.data_files() |
---|
| 108 | |
---|
| 109 | import sans.perspectives.invariant as invariant |
---|
| 110 | data_files += invariant.data_files() |
---|
[d4c19e5] | 111 | |
---|
[fa597990] | 112 | import sans.guiframe as guiframe |
---|
| 113 | data_files += guiframe.data_files() |
---|
| 114 | |
---|
| 115 | import sans.models as models |
---|
| 116 | data_files += models.data_files() |
---|
| 117 | |
---|
| 118 | for f in matplotlibdata: |
---|
| 119 | dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:]) |
---|
| 120 | data_files.append((os.path.split(dirname)[0], [f])) |
---|
| 121 | |
---|
| 122 | # Copy the settings file for the sans.dataloader file extension associations |
---|
| 123 | import sans.dataloader.readers |
---|
| 124 | f = os.path.join(sans.dataloader.readers.get_data_path(),'defaults.xml') |
---|
| 125 | if os.path.isfile(f): |
---|
| 126 | data_files.append(('.', [f])) |
---|
| 127 | f = 'custom_config.py' |
---|
| 128 | if os.path.isfile(f): |
---|
| 129 | data_files.append(('.', [f])) |
---|
[d4c19e5] | 130 | f = 'local_config.py' |
---|
| 131 | if os.path.isfile(f): |
---|
| 132 | data_files.append(('.', [f])) |
---|
[fa597990] | 133 | # Copying the images directory to the distribution directory. |
---|
| 134 | for f in findall(images_dir): |
---|
| 135 | if os.path.split(f)[0].count('.svn')==0: |
---|
[f1044e9] | 136 | data_files.append(("images", [f])) |
---|
[fa597990] | 137 | |
---|
| 138 | # Copying the HTML help docs |
---|
| 139 | for f in findall(media_dir): |
---|
| 140 | if os.path.split(f)[0].count('.svn')==0: |
---|
[f1044e9] | 141 | data_files.append(("media", [f])) |
---|
[fa597990] | 142 | |
---|
| 143 | # Copying the sample data user data |
---|
| 144 | for f in findall(test_dir): |
---|
| 145 | if os.path.split(f)[0].count('.svn')==0: |
---|
[f1044e9] | 146 | data_files.append(("test", [f])) |
---|
[fa597990] | 147 | |
---|
| 148 | # Copying the sample data user data |
---|
| 149 | for f in findall(plugins_dir): |
---|
| 150 | if os.path.split(f)[0].count('.svn')==0: |
---|
[d4c19e5] | 151 | data_files.append(('plugins', [f])) |
---|
[fa597990] | 152 | |
---|
| 153 | |
---|
| 154 | # |
---|
| 155 | # packages |
---|
| 156 | # |
---|
| 157 | |
---|
[bb64650] | 158 | packages = ['matplotlib', 'scipy', 'pytz', 'encodings'] |
---|
[535d9f6] | 159 | includes = ['site'] |
---|
[fa597990] | 160 | excludes = [] |
---|
| 161 | |
---|
| 162 | dll_excludes = [ |
---|
| 163 | 'libgdk_pixbuf-2.0-0.dll', |
---|
| 164 | 'libgobject-2.0-0.dll', |
---|
| 165 | 'libgdk-win32-2.0-0.dll', |
---|
| 166 | ] |
---|
| 167 | |
---|
| 168 | target_wx_client = Target( |
---|
| 169 | description = 'SansView', |
---|
| 170 | script = 'sansview.py', |
---|
| 171 | icon_resources = [(1, os.path.join(images_dir, "ball.ico"))], |
---|
| 172 | other_resources = [(24,1,manifest)], |
---|
| 173 | dest_base = "SansView" |
---|
| 174 | ) |
---|
| 175 | |
---|
| 176 | |
---|
| 177 | |
---|
| 178 | setup( |
---|
| 179 | windows=[target_wx_client], |
---|
| 180 | console=[], |
---|
| 181 | |
---|
| 182 | options={ |
---|
| 183 | 'py2exe': { |
---|
| 184 | 'dll_excludes': dll_excludes, |
---|
| 185 | 'packages' : packages, |
---|
| 186 | 'includes':includes, |
---|
| 187 | 'excludes':excludes, |
---|
| 188 | "compressed": 1, |
---|
| 189 | "optimize": 0, |
---|
| 190 | "bundle_files":2, |
---|
| 191 | }, |
---|
| 192 | }, |
---|
| 193 | data_files=data_files, |
---|
| 194 | |
---|
| 195 | ) |
---|
| 196 | |
---|
| 197 | |
---|