[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 | |
---|
[b30f001] | 18 | from distutils.core import setup |
---|
| 19 | from distutils.filelist import findall |
---|
| 20 | import matplotlib |
---|
| 21 | import py2exe |
---|
| 22 | |
---|
| 23 | manifest = """ |
---|
| 24 | <?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
---|
| 25 | <assembly xmlns="urn:schemas-microsoft-com:asm.v1" |
---|
| 26 | manifestVersion="1.0"> |
---|
| 27 | <assemblyIdentity |
---|
| 28 | version="0.64.1.0" |
---|
| 29 | processorArchitecture="x86" |
---|
| 30 | name="Controls" |
---|
| 31 | type="win32" |
---|
| 32 | /> |
---|
[365a17f6] | 33 | <description>SansView</description> |
---|
[b30f001] | 34 | <dependency> |
---|
| 35 | <dependentAssembly> |
---|
| 36 | <assemblyIdentity |
---|
| 37 | type="win32" |
---|
| 38 | name="Microsoft.Windows.Common-Controls" |
---|
| 39 | version="6.0.0.0" |
---|
| 40 | processorArchitecture="X86" |
---|
| 41 | publicKeyToken="6595b64144ccf1df" |
---|
| 42 | language="*" |
---|
| 43 | /> |
---|
| 44 | </dependentAssembly> |
---|
| 45 | </dependency> |
---|
| 46 | </assembly> |
---|
| 47 | """ |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | class Target: |
---|
| 51 | def __init__(self, **kw): |
---|
| 52 | self.__dict__.update(kw) |
---|
| 53 | # for the versioninfo resources |
---|
[3c939e5] | 54 | self.version = "0.9.1" |
---|
[b30f001] | 55 | self.company_name = "U Tennessee" |
---|
[c9795f6] | 56 | self.copyright = "copyright 2009" |
---|
[365a17f6] | 57 | self.name = "SansView" |
---|
[b30f001] | 58 | |
---|
| 59 | # |
---|
| 60 | # Adapted from http://www.py2exe.org/index.cgi/MatPlotLib |
---|
| 61 | # to use the MatPlotLib. |
---|
| 62 | # |
---|
| 63 | matplotlibdatadir = matplotlib.get_data_path() |
---|
| 64 | matplotlibdata = findall(matplotlibdatadir) |
---|
[365a17f6] | 65 | data_files = [] |
---|
[a90a3c84] | 66 | # Copying SLD data |
---|
[c93cc15] | 67 | import periodictable |
---|
[cc1500d] | 68 | import logging |
---|
[c93cc15] | 69 | data_files += periodictable.data_files() |
---|
| 70 | |
---|
[698a734] | 71 | import sans.perspectives.calculator as calculator |
---|
| 72 | data_files += calculator.data_files() |
---|
| 73 | |
---|
| 74 | import sans.perspectives.invariant as invariant |
---|
| 75 | data_files += invariant.data_files() |
---|
[c93cc15] | 76 | |
---|
[b30f001] | 77 | for f in matplotlibdata: |
---|
[365a17f6] | 78 | dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:]) |
---|
| 79 | data_files.append((os.path.split(dirname)[0], [f])) |
---|
[b30f001] | 80 | |
---|
[25b9c26d] | 81 | # Copy the settings file for the DataLoader file extension associations |
---|
| 82 | import DataLoader.readers |
---|
| 83 | f = os.path.join(DataLoader.readers.get_data_path(),'defaults.xml') |
---|
| 84 | if os.path.isfile(f): |
---|
| 85 | data_files.append(('.', [f])) |
---|
| 86 | |
---|
[365a17f6] | 87 | # Copying the images directory to the distribution directory. |
---|
| 88 | for f in findall('images'): |
---|
| 89 | if os.path.split(f)[0].count('.svn')==0: |
---|
| 90 | data_files.append((os.path.split(f)[0], [f])) |
---|
[d35420d] | 91 | |
---|
| 92 | # Copying the HTML help docs |
---|
[e5d76ce] | 93 | for f in findall('media'): |
---|
[d35420d] | 94 | if os.path.split(f)[0].count('.svn')==0: |
---|
| 95 | data_files.append((os.path.split(f)[0], [f])) |
---|
[e284116] | 96 | |
---|
| 97 | # Copying the sample data user data |
---|
| 98 | for f in findall('test'): |
---|
| 99 | if os.path.split(f)[0].count('.svn')==0: |
---|
| 100 | data_files.append((os.path.split(f)[0], [f])) |
---|
[1b16714f] | 101 | |
---|
| 102 | # Copying the sample data user data |
---|
| 103 | for f in findall('plugins'): |
---|
| 104 | if os.path.split(f)[0].count('.svn')==0: |
---|
| 105 | data_files.append((os.path.split(f)[0], [f])) |
---|
[e284116] | 106 | |
---|
[365a17f6] | 107 | |
---|
[b30f001] | 108 | # |
---|
| 109 | # packages |
---|
| 110 | # |
---|
[3c939e5] | 111 | packages = ['matplotlib', 'pytz','encodings'] |
---|
[b30f001] | 112 | includes = [] |
---|
[365a17f6] | 113 | excludes = [] |
---|
[b30f001] | 114 | |
---|
| 115 | dll_excludes = [ |
---|
| 116 | 'libgdk_pixbuf-2.0-0.dll', |
---|
| 117 | 'libgobject-2.0-0.dll', |
---|
| 118 | 'libgdk-win32-2.0-0.dll', |
---|
| 119 | ] |
---|
| 120 | |
---|
| 121 | target_wx_client = Target( |
---|
[7f7e5f1] | 122 | description = 'SansView', |
---|
[b30f001] | 123 | script = 'sansview.py', |
---|
| 124 | icon_resources = [(1, "images/ball.ico")], |
---|
| 125 | other_resources = [(24,1,manifest)], |
---|
[365a17f6] | 126 | dest_base = "SansView" |
---|
[b30f001] | 127 | ) |
---|
| 128 | |
---|
| 129 | |
---|
| 130 | |
---|
| 131 | setup( |
---|
| 132 | windows=[target_wx_client], |
---|
| 133 | console=[], |
---|
| 134 | |
---|
| 135 | options={ |
---|
| 136 | 'py2exe': { |
---|
| 137 | 'dll_excludes': dll_excludes, |
---|
| 138 | 'packages' : packages, |
---|
| 139 | 'includes':includes, |
---|
| 140 | 'excludes':excludes, |
---|
| 141 | "compressed": 1, |
---|
| 142 | "optimize": 0, |
---|
| 143 | "bundle_files":2, |
---|
| 144 | }, |
---|
| 145 | }, |
---|
[c93cc15] | 146 | data_files=data_files, |
---|
[b30f001] | 147 | |
---|
| 148 | ) |
---|
| 149 | |
---|
| 150 | |
---|