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