[807560b] | 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 |
---|
| 17 | import sys |
---|
| 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 | |
---|
| 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>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 | |
---|
| 64 | |
---|
| 65 | class Target: |
---|
| 66 | def __init__(self, **kw): |
---|
| 67 | self.__dict__.update(kw) |
---|
| 68 | # for the versioninfo resources |
---|
[a2898df] | 69 | self.version = "1.0.0" |
---|
[807560b] | 70 | self.company_name = "U Tennessee" |
---|
| 71 | self.copyright = "copyright 2009" |
---|
| 72 | self.name = "PrView" |
---|
| 73 | |
---|
| 74 | # |
---|
| 75 | # Adapted from http://www.py2exe.org/index.cgi/MatPlotLib |
---|
| 76 | # to use the MatPlotLib. |
---|
| 77 | # |
---|
[8abbb12] | 78 | path = os.getcwd() |
---|
| 79 | plugins_dir = os.path.join(path, "plugins") |
---|
| 80 | images_dir = os.path.join(path, "images") |
---|
| 81 | test_dir = os.path.join(path, "test") |
---|
| 82 | |
---|
[807560b] | 83 | matplotlibdatadir = matplotlib.get_data_path() |
---|
| 84 | matplotlibdata = findall(matplotlibdatadir) |
---|
| 85 | data_files = [] |
---|
| 86 | |
---|
[8abbb12] | 87 | import sans.guiframe as guiframe |
---|
| 88 | data_files += guiframe.data_files() |
---|
| 89 | |
---|
[807560b] | 90 | for f in matplotlibdata: |
---|
| 91 | dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:]) |
---|
| 92 | data_files.append((os.path.split(dirname)[0], [f])) |
---|
[8abbb12] | 93 | |
---|
| 94 | f = 'local_config.py' |
---|
| 95 | if os.path.isfile(f): |
---|
| 96 | data_files.append(('.', [f])) |
---|
| 97 | f = 'custom_config.py' |
---|
| 98 | if os.path.isfile(f): |
---|
| 99 | data_files.append(('.', [f])) |
---|
[807560b] | 100 | # Copying the images directory to the distribution directory. |
---|
[8abbb12] | 101 | for f in findall(images_dir): |
---|
[807560b] | 102 | if os.path.split(f)[0].count('.svn')==0: |
---|
[8abbb12] | 103 | data_files.append(("images", [f])) |
---|
[807560b] | 104 | |
---|
| 105 | # Copying the sample data user data |
---|
[8abbb12] | 106 | for f in findall(test_dir): |
---|
[807560b] | 107 | if os.path.split(f)[0].count('.svn')==0: |
---|
[8abbb12] | 108 | data_files.append(("test", [f])) |
---|
[807560b] | 109 | |
---|
| 110 | # Copying the sample data user data |
---|
[8abbb12] | 111 | for f in findall(plugins_dir): |
---|
[807560b] | 112 | if os.path.split(f)[0].count('.svn')==0: |
---|
[8abbb12] | 113 | data_files.append(("plugins", [f])) |
---|
[807560b] | 114 | # |
---|
| 115 | # packages |
---|
| 116 | # |
---|
| 117 | packages = ['matplotlib', 'pytz'] |
---|
| 118 | includes = [] |
---|
| 119 | excludes = [] |
---|
| 120 | |
---|
| 121 | dll_excludes = [ |
---|
| 122 | 'libgdk_pixbuf-2.0-0.dll', |
---|
| 123 | 'libgobject-2.0-0.dll', |
---|
| 124 | 'libgdk-win32-2.0-0.dll', |
---|
| 125 | ] |
---|
| 126 | |
---|
| 127 | target_wx_client = Target( |
---|
| 128 | description = 'P(r) inversion viewer', |
---|
| 129 | script = 'PrView.py', |
---|
| 130 | icon_resources = [(1, "images/ball.ico")], |
---|
| 131 | other_resources = [(24,1,manifest)], |
---|
| 132 | dest_base = "prView" |
---|
| 133 | ) |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | setup( |
---|
| 138 | windows=[target_wx_client], |
---|
| 139 | console=[], |
---|
| 140 | |
---|
| 141 | options={ |
---|
| 142 | 'py2exe': { |
---|
| 143 | 'dll_excludes': dll_excludes, |
---|
| 144 | 'packages' : packages, |
---|
| 145 | 'includes':includes, |
---|
| 146 | 'excludes':excludes, |
---|
| 147 | "compressed": 1, |
---|
| 148 | "optimize": 0, |
---|
| 149 | "bundle_files":2, |
---|
| 150 | }, |
---|
| 151 | }, |
---|
| 152 | data_files=data_files |
---|
| 153 | |
---|
| 154 | ) |
---|
| 155 | |
---|
| 156 | |
---|