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