[fa597990] | 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 sans.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 | EXTENSIONS_LIST = [] |
---|
| 17 | DATA_FILES = [] |
---|
| 18 | RESOURCES_FILES = [] |
---|
| 19 | |
---|
| 20 | #Periodictable data file |
---|
| 21 | DATA_FILES = periodictable.data_files() |
---|
| 22 | #invariant and calculator help doc |
---|
| 23 | import sans.perspectives.calculator as calculator |
---|
| 24 | DATA_FILES += calculator.data_files() |
---|
| 25 | import sans.perspectives.invariant as invariant |
---|
| 26 | DATA_FILES += invariant.data_files() |
---|
| 27 | import sans.models as models |
---|
| 28 | DATA_FILES += models.data_files() |
---|
| 29 | import sans.guiframe as guiframe |
---|
| 30 | DATA_FILES += guiframe.data_files() |
---|
| 31 | |
---|
| 32 | #CANSAxml reader data files |
---|
| 33 | RESOURCES_FILES.append(os.path.join(sans.dataloader.readers.get_data_path(),'defaults.xml')) |
---|
| 34 | |
---|
| 35 | # Locate libxml2 library |
---|
| 36 | lib_locs = ['/usr/local/lib', '/usr/lib'] |
---|
| 37 | libxml_path = None |
---|
| 38 | for item in lib_locs: |
---|
| 39 | libxml_path_test = '%s/libxml2.2.dylib' % item |
---|
| 40 | if os.path.isfile(libxml_path_test): |
---|
| 41 | libxml_path = libxml_path_test |
---|
| 42 | if libxml_path == None: |
---|
| 43 | raise RuntimeError, "Could not find libxml2 on the system" |
---|
| 44 | |
---|
| 45 | APP = ['sansview.py'] |
---|
| 46 | DATA_FILES += ['images','test','plugins','media', 'custom_config.py'] |
---|
| 47 | # locate file extensions |
---|
| 48 | def find_extension(): |
---|
| 49 | """ |
---|
| 50 | Describe the extensions that can be read by the current application |
---|
| 51 | """ |
---|
| 52 | try: |
---|
| 53 | list = [] |
---|
| 54 | EXCEPTION_LIST = ['*', '.', ''] |
---|
| 55 | from sans.dataloader.loader import Loader |
---|
| 56 | wild_cards = Loader().get_wildcards() |
---|
| 57 | for item in wild_cards: |
---|
| 58 | #['All (*.*)|*.*'] |
---|
| 59 | file_type, ext = string.split(item, "|*.", 1) |
---|
| 60 | if ext.strip() not in EXCEPTION_LIST and ext.strip() not in list: |
---|
| 61 | list.append(ext) |
---|
| 62 | except: |
---|
| 63 | pass |
---|
| 64 | try: |
---|
| 65 | file_type, ext = string.split(local_config.APPLICATION_WLIST, "|*.", 1) |
---|
| 66 | if ext.strip() not in EXCEPTION_LIST and ext.strip() not in list: |
---|
| 67 | list.append(ext) |
---|
| 68 | except: |
---|
| 69 | pass |
---|
| 70 | try: |
---|
| 71 | for item in local_config.PLUGINS_WLIST: |
---|
| 72 | file_type, ext = string.split(item, "|*.", 1) |
---|
| 73 | if ext.strip() not in EXCEPTION_LIST and ext.strip() not in list: |
---|
| 74 | list.append(ext) |
---|
| 75 | except: |
---|
| 76 | pass |
---|
| 77 | |
---|
| 78 | return list |
---|
| 79 | |
---|
| 80 | EXTENSIONS_LIST = find_extension() |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | plist = dict(CFBundleDocumentTypes=[dict(CFBundleTypeExtensions=EXTENSIONS_LIST, |
---|
| 84 | CFBundleTypeIconFile=ICON, |
---|
| 85 | CFBundleTypeName="sansview file", |
---|
| 86 | CFBundleTypeRole="Shell" )],) |
---|
| 87 | |
---|
| 88 | APP = ['sansview.py'] |
---|
| 89 | DATA_FILES += ['images','test','plugins','media'] |
---|
| 90 | OPTIONS = {'argv_emulation': True, |
---|
| 91 | 'packages': ['lxml','periodictable'], |
---|
| 92 | 'iconfile': ICON, |
---|
| 93 | 'frameworks':[libxml_path], |
---|
| 94 | 'resources': RESOURCES_FILES, |
---|
| 95 | 'plist':plist, |
---|
| 96 | } |
---|
| 97 | setup( |
---|
| 98 | app=APP, |
---|
| 99 | data_files=DATA_FILES, |
---|
| 100 | include_package_data= True, |
---|
| 101 | options={'py2app': OPTIONS}, |
---|
| 102 | setup_requires=['py2app'], |
---|
| 103 | ) |
---|