[3be3a80] | 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 |
---|
[2f5d888] | 17 | if len(sys.argv) == 1: |
---|
| 18 | sys.argv.append('py2exe') |
---|
[3be3a80] | 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 |
---|
| 69 | self.version = "1.0" |
---|
| 70 | self.company_name = "U Tennessee" |
---|
| 71 | self.copyright = "copyright 2009" |
---|
| 72 | self.name = "SansViewTool" |
---|
| 73 | |
---|
| 74 | # |
---|
| 75 | # Adapted from http://www.py2exe.org/index.cgi/MatPlotLib |
---|
| 76 | # to use the MatPlotLib. |
---|
| 77 | # |
---|
| 78 | matplotlibdatadir = matplotlib.get_data_path() |
---|
| 79 | matplotlibdata = findall(matplotlibdatadir) |
---|
| 80 | data_files = [] |
---|
| 81 | # Copying SLD data |
---|
| 82 | import periodictable |
---|
| 83 | import logging |
---|
| 84 | data_files += periodictable.data_files() |
---|
| 85 | |
---|
| 86 | import sans.perspectives.calculator as calculator |
---|
| 87 | data_files += calculator.data_files() |
---|
| 88 | |
---|
| 89 | for f in matplotlibdata: |
---|
| 90 | dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:]) |
---|
| 91 | data_files.append((os.path.split(dirname)[0], [f])) |
---|
| 92 | |
---|
| 93 | # Copying the images directory to the distribution directory. |
---|
[2f5d888] | 94 | import sans.perspectives.calculator as cal |
---|
| 95 | path = cal.get_data_path('images') |
---|
| 96 | for f in findall(path): |
---|
[3be3a80] | 97 | if os.path.split(f)[0].count('.svn')==0: |
---|
[2f5d888] | 98 | data_files.append(('images', [f])) |
---|
[ae3e17e] | 99 | import sans.guiframe as guiframe |
---|
| 100 | data_files += guiframe.data_files() |
---|
[3be3a80] | 101 | # Copy the settings file for the DataLoader file extension associations |
---|
[4b2fcd8] | 102 | import sans.dataloader.readers |
---|
| 103 | f = os.path.join(sans.dataloader.readers.get_data_path(),'defaults.xml') |
---|
[3be3a80] | 104 | if os.path.isfile(f): |
---|
| 105 | data_files.append(('.', [f])) |
---|
[ae3e17e] | 106 | f = 'custom_config.py' |
---|
| 107 | if os.path.isfile(f): |
---|
| 108 | data_files.append(('.', [f])) |
---|
[ed94228] | 109 | f = 'local_config.py' |
---|
| 110 | if os.path.isfile(f): |
---|
| 111 | data_files.append(('.', [f])) |
---|
[3be3a80] | 112 | # Copying the HTML help docs |
---|
[2f5d888] | 113 | path = cal.get_data_path('media') |
---|
| 114 | for f in findall(path): |
---|
[3be3a80] | 115 | if os.path.split(f)[0].count('.svn')==0: |
---|
| 116 | data_files.append((os.path.split(f)[0], [f])) |
---|
| 117 | |
---|
| 118 | |
---|
| 119 | |
---|
| 120 | # |
---|
| 121 | # packages |
---|
| 122 | # |
---|
| 123 | packages = ['matplotlib', 'pytz','encodings', 'scipy'] |
---|
[3ff72e2] | 124 | includes = ['site'] |
---|
[3be3a80] | 125 | excludes = [] |
---|
| 126 | |
---|
| 127 | dll_excludes = [ |
---|
| 128 | 'libgdk_pixbuf-2.0-0.dll', |
---|
| 129 | 'libgobject-2.0-0.dll', |
---|
| 130 | 'libgdk-win32-2.0-0.dll', |
---|
| 131 | ] |
---|
| 132 | |
---|
| 133 | target_wx_client = Target( |
---|
| 134 | description = 'SansViewTool', |
---|
| 135 | script = 'sansviewtool.py', |
---|
| 136 | #icon_resources = [(1, "images/ball.ico")], |
---|
| 137 | other_resources = [(24,1,manifest)], |
---|
| 138 | dest_base = "SansViewTool" |
---|
| 139 | ) |
---|
| 140 | |
---|
| 141 | |
---|
| 142 | |
---|
| 143 | setup( |
---|
| 144 | windows=[target_wx_client], |
---|
| 145 | console=[], |
---|
| 146 | |
---|
| 147 | options={ |
---|
| 148 | 'py2exe': { |
---|
| 149 | 'dll_excludes': dll_excludes, |
---|
| 150 | 'packages' : packages, |
---|
| 151 | 'includes':includes, |
---|
| 152 | 'excludes':excludes, |
---|
| 153 | "compressed": 1, |
---|
| 154 | "optimize": 0, |
---|
| 155 | "bundle_files":2, |
---|
| 156 | }, |
---|
| 157 | }, |
---|
| 158 | data_files=data_files, |
---|
| 159 | |
---|
| 160 | ) |
---|
| 161 | |
---|
| 162 | |
---|