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