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