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