1 | """ |
---|
2 | This is a setup.py script partly generated by py2applet |
---|
3 | |
---|
4 | Usage: |
---|
5 | python setup.py py2app |
---|
6 | """ |
---|
7 | from setuptools import setup |
---|
8 | import periodictable.xsf |
---|
9 | import DataLoader.readers |
---|
10 | from distutils.sysconfig import get_python_lib |
---|
11 | import os |
---|
12 | import string |
---|
13 | import local_config |
---|
14 | |
---|
15 | ICON = local_config.SetupIconFile_mac |
---|
16 | DATA_FILES = [] |
---|
17 | RESOURCES_FILES = [] |
---|
18 | EXTENSIONS_LIST = [] |
---|
19 | |
---|
20 | #Periodictable data file |
---|
21 | DATA_FILES = periodictable.data_files() |
---|
22 | #add guiframe data file |
---|
23 | import sans.guiframe as guiframe |
---|
24 | DATA_files += guiframe.data_files() |
---|
25 | #invariant and calculator help doc |
---|
26 | import sans.perspectives.calculator as calculator |
---|
27 | DATA_FILES += calculator.data_files() |
---|
28 | import sans.perspectives.invariant as invariant |
---|
29 | DATA_FILES += invariant.data_files() |
---|
30 | import sans.models as models |
---|
31 | DATA_FILES += models.data_files() |
---|
32 | |
---|
33 | #CANSAxml reader data files |
---|
34 | RESOURCES_FILES.append(os.path.join(DataLoader.readers.get_data_path(), |
---|
35 | 'defaults.xml')) |
---|
36 | # locate file extensions |
---|
37 | def find_extension(): |
---|
38 | """ |
---|
39 | Describe the extensions that can be read by the current application |
---|
40 | """ |
---|
41 | try: |
---|
42 | list = [] |
---|
43 | EXCEPTION_LIST = ['*', '.', ''] |
---|
44 | #(ext, type, name, flags) |
---|
45 | from DataLoader.loader import Loader |
---|
46 | wild_cards = Loader().get_wildcards() |
---|
47 | for item in wild_cards: |
---|
48 | #['All (*.*)|*.*'] |
---|
49 | file_type, ext = string.split(item, "|*.", 1) |
---|
50 | if ext.strip() not in EXCEPTION_LIST and ext.strip() not in list: |
---|
51 | list.append((ext, 'string', file_type)) |
---|
52 | except: |
---|
53 | raise |
---|
54 | try: |
---|
55 | file_type, ext = string.split(local_config.APPLICATION_WLIST, "|*.", 1) |
---|
56 | if ext.strip() not in EXCEPTION_LIST and ext.strip() not in list: |
---|
57 | list.append((ext, 'string', file_type)) |
---|
58 | except: |
---|
59 | raise |
---|
60 | try: |
---|
61 | for item in local_config.PLUGINS_WLIST: |
---|
62 | file_type, ext = string.split(item, "|*.", 1) |
---|
63 | if ext.strip() not in EXCEPTION_LIST and ext.strip() not in list: |
---|
64 | list.append((ext, 'string', file_type)) |
---|
65 | except: |
---|
66 | raise |
---|
67 | |
---|
68 | return list |
---|
69 | |
---|
70 | EXTENSIONS_LIST = find_extension() |
---|
71 | temp = [] |
---|
72 | for (ext, _, file_type) in EXTENSIONS_LIST: |
---|
73 | dict(CFBundleTypeTypeExtensions=[str(ext)], |
---|
74 | CFBundleTypeIconFile=ICON, |
---|
75 | CFBundleTypeName=str(file_type), |
---|
76 | CFBundleTypeRole="Viewer") |
---|
77 | temp.append(dict) |
---|
78 | |
---|
79 | PLIST = dict(CFBundleDocumentTypes=temp) |
---|
80 | |
---|
81 | |
---|
82 | # Locate libxml2 library |
---|
83 | lib_locs = ['/usr/local/lib', '/usr/lib'] |
---|
84 | libxml_path = None |
---|
85 | for item in lib_locs: |
---|
86 | libxml_path_test = '%s/libxml2.2.dylib' % item |
---|
87 | if os.path.isfile(libxml_path_test): |
---|
88 | libxml_path = libxml_path_test |
---|
89 | if libxml_path == None: |
---|
90 | raise RuntimeError, "Could not find libxml2 on the system" |
---|
91 | |
---|
92 | APP = ['sansview.py'] |
---|
93 | DATA_FILES += ['images','test','plugins','media'] |
---|
94 | OPTIONS = {'argv_emulation': True, |
---|
95 | 'packages': ['lxml','periodictable'], |
---|
96 | 'iconfile': ICON, |
---|
97 | 'frameworks':[libxml_path], |
---|
98 | 'resources': RESOURCES_FILES, |
---|
99 | 'plist':PLIST |
---|
100 | } |
---|
101 | |
---|
102 | setup( |
---|
103 | app=APP, |
---|
104 | data_files=DATA_FILES, |
---|
105 | include_package_data= True, |
---|
106 | options={'py2app': OPTIONS}, |
---|
107 | setup_requires=['py2app'], |
---|
108 | ) |
---|
109 | |
---|