[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 |
---|
| 17 | |
---|
| 18 | # When using the SansView build script, we need to be able to pass |
---|
| 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. |
---|
| 22 | try: |
---|
| 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') |
---|
| 29 | except: |
---|
| 30 | print "Error processing extra python path needed to build SansView\n %s" % sys.exc_value |
---|
| 31 | |
---|
| 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 | /> |
---|
| 47 | <description>SansView</description> |
---|
| 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 |
---|
| 68 | self.version = "1.9.1" |
---|
| 69 | self.company_name = "U Tennessee" |
---|
| 70 | self.copyright = "copyright 2009" |
---|
| 71 | self.name = "SansView" |
---|
| 72 | |
---|
| 73 | # |
---|
| 74 | # Adapted from http://www.py2exe.org/index.cgi/MatPlotLib |
---|
| 75 | # to use the MatPlotLib. |
---|
| 76 | # |
---|
[d4c19e5] | 77 | path = os.getcwd() |
---|
| 78 | |
---|
[fa597990] | 79 | plugins_dir = os.path.join(path, "plugins") |
---|
| 80 | media_dir = os.path.join(path, "media") |
---|
| 81 | images_dir = os.path.join(path, "images") |
---|
| 82 | test_dir = os.path.join(path, "test") |
---|
| 83 | |
---|
| 84 | matplotlibdatadir = matplotlib.get_data_path() |
---|
| 85 | matplotlibdata = findall(matplotlibdatadir) |
---|
| 86 | data_files = [] |
---|
| 87 | # Copying SLD data |
---|
| 88 | import periodictable |
---|
| 89 | import logging |
---|
| 90 | data_files += periodictable.data_files() |
---|
| 91 | |
---|
[d4c19e5] | 92 | import sans.perspectives.fitting as fitting |
---|
| 93 | data_files += fitting.data_files() |
---|
| 94 | |
---|
[fa597990] | 95 | import sans.perspectives.calculator as calculator |
---|
| 96 | data_files += calculator.data_files() |
---|
| 97 | |
---|
| 98 | import sans.perspectives.invariant as invariant |
---|
| 99 | data_files += invariant.data_files() |
---|
[d4c19e5] | 100 | |
---|
[fa597990] | 101 | import sans.guiframe as guiframe |
---|
| 102 | data_files += guiframe.data_files() |
---|
| 103 | |
---|
| 104 | import sans.models as models |
---|
| 105 | data_files += models.data_files() |
---|
| 106 | |
---|
| 107 | for f in matplotlibdata: |
---|
| 108 | dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:]) |
---|
| 109 | data_files.append((os.path.split(dirname)[0], [f])) |
---|
| 110 | |
---|
| 111 | # Copy the settings file for the sans.dataloader file extension associations |
---|
| 112 | import sans.dataloader.readers |
---|
| 113 | f = os.path.join(sans.dataloader.readers.get_data_path(),'defaults.xml') |
---|
| 114 | if os.path.isfile(f): |
---|
| 115 | data_files.append(('.', [f])) |
---|
| 116 | f = 'custom_config.py' |
---|
| 117 | if os.path.isfile(f): |
---|
| 118 | data_files.append(('.', [f])) |
---|
[d4c19e5] | 119 | f = 'local_config.py' |
---|
| 120 | if os.path.isfile(f): |
---|
| 121 | data_files.append(('.', [f])) |
---|
[fa597990] | 122 | # Copying the images directory to the distribution directory. |
---|
| 123 | for f in findall(images_dir): |
---|
| 124 | if os.path.split(f)[0].count('.svn')==0: |
---|
| 125 | data_files.append((os.path.split(f)[0], [f])) |
---|
| 126 | |
---|
| 127 | # Copying the HTML help docs |
---|
| 128 | for f in findall(media_dir): |
---|
| 129 | if os.path.split(f)[0].count('.svn')==0: |
---|
| 130 | data_files.append((os.path.split(f)[0], [f])) |
---|
| 131 | |
---|
| 132 | # Copying the sample data user data |
---|
| 133 | for f in findall(test_dir): |
---|
| 134 | if os.path.split(f)[0].count('.svn')==0: |
---|
| 135 | data_files.append((os.path.split(f)[0], [f])) |
---|
| 136 | |
---|
| 137 | # Copying the sample data user data |
---|
| 138 | for f in findall(plugins_dir): |
---|
| 139 | if os.path.split(f)[0].count('.svn')==0: |
---|
[d4c19e5] | 140 | data_files.append(('plugins', [f])) |
---|
[fa597990] | 141 | |
---|
| 142 | |
---|
| 143 | # |
---|
| 144 | # packages |
---|
| 145 | # |
---|
| 146 | |
---|
| 147 | packages = ['matplotlib', 'pytz','encodings'] |
---|
| 148 | includes = [] |
---|
| 149 | excludes = [] |
---|
| 150 | |
---|
| 151 | dll_excludes = [ |
---|
| 152 | 'libgdk_pixbuf-2.0-0.dll', |
---|
| 153 | 'libgobject-2.0-0.dll', |
---|
| 154 | 'libgdk-win32-2.0-0.dll', |
---|
| 155 | ] |
---|
| 156 | |
---|
| 157 | target_wx_client = Target( |
---|
| 158 | description = 'SansView', |
---|
| 159 | script = 'sansview.py', |
---|
| 160 | icon_resources = [(1, os.path.join(images_dir, "ball.ico"))], |
---|
| 161 | other_resources = [(24,1,manifest)], |
---|
| 162 | dest_base = "SansView" |
---|
| 163 | ) |
---|
| 164 | |
---|
| 165 | |
---|
| 166 | |
---|
| 167 | setup( |
---|
| 168 | windows=[target_wx_client], |
---|
| 169 | console=[], |
---|
| 170 | |
---|
| 171 | options={ |
---|
| 172 | 'py2exe': { |
---|
| 173 | 'dll_excludes': dll_excludes, |
---|
| 174 | 'packages' : packages, |
---|
| 175 | 'includes':includes, |
---|
| 176 | 'excludes':excludes, |
---|
| 177 | "compressed": 1, |
---|
| 178 | "optimize": 0, |
---|
| 179 | "bundle_files":2, |
---|
| 180 | }, |
---|
| 181 | }, |
---|
| 182 | data_files=data_files, |
---|
| 183 | |
---|
| 184 | ) |
---|
| 185 | |
---|
| 186 | |
---|