[4a5de6f] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
| 3 | # |
---|
[b24bf4e] | 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. |
---|
[4a5de6f] | 7 | # |
---|
[b24bf4e] | 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. |
---|
[4a5de6f] | 15 | |
---|
[4851fcbc] | 16 | import os |
---|
| 17 | import sys |
---|
[697d798] | 18 | |
---|
| 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 | |
---|
[4a5de6f] | 33 | from distutils.core import setup |
---|
| 34 | from distutils.filelist import findall |
---|
| 35 | import matplotlib |
---|
| 36 | import py2exe |
---|
| 37 | |
---|
[a4bd2ac] | 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>PrView</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 | |
---|
[4a5de6f] | 64 | |
---|
| 65 | class Target: |
---|
| 66 | def __init__(self, **kw): |
---|
| 67 | self.__dict__.update(kw) |
---|
| 68 | # for the versioninfo resources |
---|
[a8d92db] | 69 | self.version = "0.3" |
---|
[4a5de6f] | 70 | self.company_name = "U Tennessee" |
---|
[a8d92db] | 71 | self.copyright = "copyright 2009" |
---|
[4a5de6f] | 72 | self.name = "PrView" |
---|
| 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) |
---|
[b24bf4e] | 80 | data_files = [] |
---|
[4a5de6f] | 81 | |
---|
| 82 | for f in matplotlibdata: |
---|
[b24bf4e] | 83 | dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:]) |
---|
| 84 | data_files.append((os.path.split(dirname)[0], [f])) |
---|
[4a5de6f] | 85 | |
---|
[b24bf4e] | 86 | # Copying the images directory to the distribution directory. |
---|
| 87 | for f in findall('images'): |
---|
| 88 | if os.path.split(f)[0].count('.svn')==0: |
---|
| 89 | data_files.append((os.path.split(f)[0], [f])) |
---|
[a8d92db] | 90 | |
---|
| 91 | # Copying the sample data user data |
---|
| 92 | for f in findall('test'): |
---|
| 93 | if os.path.split(f)[0].count('.svn')==0: |
---|
| 94 | data_files.append((os.path.split(f)[0], [f])) |
---|
| 95 | |
---|
| 96 | # Copying the sample data user data |
---|
| 97 | for f in findall('plugins'): |
---|
| 98 | if os.path.split(f)[0].count('.svn')==0: |
---|
| 99 | data_files.append((os.path.split(f)[0], [f])) |
---|
[b24bf4e] | 100 | |
---|
[4a5de6f] | 101 | # |
---|
| 102 | # packages |
---|
| 103 | # |
---|
[b24bf4e] | 104 | packages = ['matplotlib', 'pytz'] |
---|
[4a5de6f] | 105 | includes = [] |
---|
[b24bf4e] | 106 | excludes = [] |
---|
[4a5de6f] | 107 | |
---|
| 108 | dll_excludes = [ |
---|
| 109 | 'libgdk_pixbuf-2.0-0.dll', |
---|
| 110 | 'libgobject-2.0-0.dll', |
---|
| 111 | 'libgdk-win32-2.0-0.dll', |
---|
| 112 | ] |
---|
| 113 | |
---|
| 114 | target_wx_client = Target( |
---|
| 115 | description = 'P(r) inversion viewer', |
---|
[43db4a8] | 116 | script = 'PrView.py', |
---|
[4a5de6f] | 117 | icon_resources = [(1, "images/ball.ico")], |
---|
[a4bd2ac] | 118 | other_resources = [(24,1,manifest)], |
---|
[4a5de6f] | 119 | dest_base = "prView" |
---|
| 120 | ) |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | setup( |
---|
| 125 | windows=[target_wx_client], |
---|
| 126 | console=[], |
---|
| 127 | |
---|
| 128 | options={ |
---|
| 129 | 'py2exe': { |
---|
| 130 | 'dll_excludes': dll_excludes, |
---|
| 131 | 'packages' : packages, |
---|
| 132 | 'includes':includes, |
---|
| 133 | 'excludes':excludes, |
---|
| 134 | "compressed": 1, |
---|
| 135 | "optimize": 0, |
---|
| 136 | "bundle_files":2, |
---|
| 137 | }, |
---|
| 138 | }, |
---|
[b24bf4e] | 139 | data_files=data_files |
---|
[4a5de6f] | 140 | |
---|
| 141 | ) |
---|
| 142 | |
---|
| 143 | |
---|