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