1 | """ |
---|
2 | This is a setup.py script partly generated by py2applet |
---|
3 | |
---|
4 | Usage: |
---|
5 | python setup.py py2app |
---|
6 | |
---|
7 | |
---|
8 | NOTES: |
---|
9 | 12/01/2011: When seeing an error related to pytz.zoneinfo not being found, change the following line in py2app/recipes/matplotlib.py |
---|
10 | mf.import_hook('pytz.tzinfo', m, ['UTC']) |
---|
11 | 12/05/2011: Generally needs a recent version of macholib, modulegraph, and altgraph (through easy_install) on OSX >= 10.6 |
---|
12 | """ |
---|
13 | from setuptools import setup |
---|
14 | import periodictable.xsf |
---|
15 | import sans.dataloader.readers |
---|
16 | from distutils.sysconfig import get_python_lib |
---|
17 | import os |
---|
18 | import string |
---|
19 | import local_config |
---|
20 | import pytz |
---|
21 | import sys |
---|
22 | import platform |
---|
23 | |
---|
24 | ICON = local_config.SetupIconFile_mac |
---|
25 | EXTENSIONS_LIST = [] |
---|
26 | DATA_FILES = [] |
---|
27 | RESOURCES_FILES = [] |
---|
28 | |
---|
29 | #Periodictable data file |
---|
30 | DATA_FILES = periodictable.data_files() |
---|
31 | #invariant and calculator help doc |
---|
32 | import sans.perspectives.fitting as fitting |
---|
33 | DATA_FILES += fitting.data_files() |
---|
34 | import sans.perspectives.calculator as calculator |
---|
35 | DATA_FILES += calculator.data_files() |
---|
36 | import sans.perspectives.invariant as invariant |
---|
37 | DATA_FILES += invariant.data_files() |
---|
38 | import sans.models as models |
---|
39 | DATA_FILES += models.data_files() |
---|
40 | import sans.guiframe as guiframe |
---|
41 | DATA_FILES += guiframe.data_files() |
---|
42 | |
---|
43 | #CANSAxml reader data files |
---|
44 | RESOURCES_FILES.append(os.path.join(sans.dataloader.readers.get_data_path(),'defaults.xml')) |
---|
45 | |
---|
46 | # Locate libxml2 library |
---|
47 | lib_locs = ['/usr/local/lib', '/usr/lib'] |
---|
48 | libxml_path = None |
---|
49 | for item in lib_locs: |
---|
50 | libxml_path_test = '%s/libxml2.2.dylib' % item |
---|
51 | if os.path.isfile(libxml_path_test): |
---|
52 | libxml_path = libxml_path_test |
---|
53 | if libxml_path == None: |
---|
54 | raise RuntimeError, "Could not find libxml2 on the system" |
---|
55 | |
---|
56 | APP = ['sansview.py'] |
---|
57 | DATA_FILES += ['images','test','plugins','media', 'custom_config.py', 'local_config.py'] |
---|
58 | # locate file extensions |
---|
59 | def find_extension(): |
---|
60 | """ |
---|
61 | Describe the extensions that can be read by the current application |
---|
62 | """ |
---|
63 | try: |
---|
64 | list = [] |
---|
65 | EXCEPTION_LIST = ['*', '.', ''] |
---|
66 | from sans.dataloader.loader import Loader |
---|
67 | wild_cards = Loader().get_wildcards() |
---|
68 | for item in wild_cards: |
---|
69 | #['All (*.*)|*.*'] |
---|
70 | file_type, ext = string.split(item, "|*.", 1) |
---|
71 | if ext.strip() not in EXCEPTION_LIST and ext.strip() not in list: |
---|
72 | list.append(ext) |
---|
73 | except: |
---|
74 | print sys.exc_value |
---|
75 | |
---|
76 | try: |
---|
77 | file_type, ext = string.split(local_config.APPLICATION_WLIST, "|*.", 1) |
---|
78 | if ext.strip() not in EXCEPTION_LIST and ext.strip() not in list: |
---|
79 | list.append(ext) |
---|
80 | except: |
---|
81 | print sys.exc_value |
---|
82 | |
---|
83 | try: |
---|
84 | for item in local_config.PLUGINS_WLIST: |
---|
85 | file_type, ext = string.split(item, "|*.", 1) |
---|
86 | if ext.strip() not in EXCEPTION_LIST and ext.strip() not in list: |
---|
87 | list.append(ext) |
---|
88 | except: |
---|
89 | print sys.exc_value |
---|
90 | |
---|
91 | return list |
---|
92 | |
---|
93 | EXTENSIONS_LIST = find_extension() |
---|
94 | |
---|
95 | |
---|
96 | plist = dict(CFBundleDocumentTypes=[dict(CFBundleTypeExtensions=EXTENSIONS_LIST, |
---|
97 | CFBundleTypeIconFile=ICON, |
---|
98 | CFBundleTypeName="sansview file", |
---|
99 | CFBundleTypeRole="Shell" )],) |
---|
100 | |
---|
101 | APP = ['sansview.py'] |
---|
102 | DATA_FILES += ['images','test','plugins','media'] |
---|
103 | |
---|
104 | EXCLUDES = ['PyQt4', 'sip', 'QtGui'] |
---|
105 | |
---|
106 | # Cross-platform applications generally expect sys.argv to |
---|
107 | # be used for opening files. This requires argv_emulation = True |
---|
108 | argv_emulation = True |
---|
109 | # argv_emulation is not supported for 64-bit apps |
---|
110 | if platform.architecture()[0] == '64bit': |
---|
111 | argv_emulation = False |
---|
112 | |
---|
113 | OPTIONS = {'argv_emulation': False, |
---|
114 | 'packages': ['lxml','numpy', 'scipy', 'pytz', 'encodings'], |
---|
115 | 'iconfile': ICON, |
---|
116 | 'frameworks':[libxml_path], |
---|
117 | 'resources': RESOURCES_FILES, |
---|
118 | 'plist':plist, |
---|
119 | 'excludes' : EXCLUDES, |
---|
120 | } |
---|
121 | setup( |
---|
122 | app=APP, |
---|
123 | data_files=DATA_FILES, |
---|
124 | include_package_data= True, |
---|
125 | options={'py2app': OPTIONS}, |
---|
126 | setup_requires=['py2app'], |
---|
127 | ) |
---|