[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']) |
---|
[495acc2] | 11 | 12/05/2011: Needs macholib >= 1.4.3 and py2app >= 0.6.4 to create a 64-bit app |
---|
[fa597990] | 12 | """ |
---|
| 13 | from setuptools import setup |
---|
| 14 | import periodictable.xsf |
---|
| 15 | import sans.dataloader.readers |
---|
| 16 | import os |
---|
| 17 | import string |
---|
| 18 | import local_config |
---|
[9ba6bba] | 19 | import pytz |
---|
[bc69dcc] | 20 | import sys |
---|
[0f2c15d] | 21 | import platform |
---|
[fa597990] | 22 | |
---|
| 23 | ICON = local_config.SetupIconFile_mac |
---|
| 24 | EXTENSIONS_LIST = [] |
---|
| 25 | DATA_FILES = [] |
---|
| 26 | RESOURCES_FILES = [] |
---|
| 27 | |
---|
| 28 | #Periodictable data file |
---|
| 29 | DATA_FILES = periodictable.data_files() |
---|
| 30 | #invariant and calculator help doc |
---|
[0986586] | 31 | import sans.perspectives.fitting as fitting |
---|
| 32 | DATA_FILES += fitting.data_files() |
---|
[fa597990] | 33 | import sans.perspectives.calculator as calculator |
---|
| 34 | DATA_FILES += calculator.data_files() |
---|
| 35 | import sans.perspectives.invariant as invariant |
---|
| 36 | DATA_FILES += invariant.data_files() |
---|
| 37 | import sans.models as models |
---|
| 38 | DATA_FILES += models.data_files() |
---|
| 39 | import sans.guiframe as guiframe |
---|
| 40 | DATA_FILES += guiframe.data_files() |
---|
| 41 | |
---|
| 42 | #CANSAxml reader data files |
---|
| 43 | RESOURCES_FILES.append(os.path.join(sans.dataloader.readers.get_data_path(),'defaults.xml')) |
---|
| 44 | |
---|
| 45 | # Locate libxml2 library |
---|
| 46 | lib_locs = ['/usr/local/lib', '/usr/lib'] |
---|
| 47 | libxml_path = None |
---|
| 48 | for item in lib_locs: |
---|
| 49 | libxml_path_test = '%s/libxml2.2.dylib' % item |
---|
| 50 | if os.path.isfile(libxml_path_test): |
---|
| 51 | libxml_path = libxml_path_test |
---|
| 52 | if libxml_path == None: |
---|
| 53 | raise RuntimeError, "Could not find libxml2 on the system" |
---|
| 54 | |
---|
| 55 | APP = ['sansview.py'] |
---|
[ca6481c] | 56 | DATA_FILES += ['images','test','media', 'custom_config.py', 'local_config.py'] |
---|
[d6202e30] | 57 | if os.path.isfile("BUILD_NUMBER"): |
---|
| 58 | DATA_FILES.append("BUILD_NUMBER") |
---|
| 59 | |
---|
[fa597990] | 60 | # locate file extensions |
---|
| 61 | def find_extension(): |
---|
| 62 | """ |
---|
| 63 | Describe the extensions that can be read by the current application |
---|
| 64 | """ |
---|
| 65 | try: |
---|
| 66 | list = [] |
---|
| 67 | EXCEPTION_LIST = ['*', '.', ''] |
---|
| 68 | from sans.dataloader.loader import Loader |
---|
| 69 | wild_cards = Loader().get_wildcards() |
---|
| 70 | for item in wild_cards: |
---|
| 71 | #['All (*.*)|*.*'] |
---|
| 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: |
---|
[495acc2] | 76 | pass |
---|
[fa597990] | 77 | try: |
---|
| 78 | file_type, ext = string.split(local_config.APPLICATION_WLIST, "|*.", 1) |
---|
| 79 | if ext.strip() not in EXCEPTION_LIST and ext.strip() not in list: |
---|
| 80 | list.append(ext) |
---|
| 81 | except: |
---|
[495acc2] | 82 | pass |
---|
[fa597990] | 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: |
---|
[495acc2] | 89 | pass |
---|
[fa597990] | 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'] |
---|
[8ca5890] | 102 | DATA_FILES += ['images','test','media'] |
---|
[fd67a9e] | 103 | |
---|
[dffb5b2] | 104 | EXCLUDES = ['PyQt4', 'sip', 'QtGui'] |
---|
[fd67a9e] | 105 | |
---|
[495acc2] | 106 | OPTIONS = {'argv_emulation': True, |
---|
[dac6869] | 107 | 'packages': ['lxml','numpy', 'scipy', 'pytz', |
---|
| 108 | 'encodings','matplotlib', 'periodictable'], |
---|
[fa597990] | 109 | 'iconfile': ICON, |
---|
| 110 | 'frameworks':[libxml_path], |
---|
| 111 | 'resources': RESOURCES_FILES, |
---|
| 112 | 'plist':plist, |
---|
[fd67a9e] | 113 | 'excludes' : EXCLUDES, |
---|
[fa597990] | 114 | } |
---|
| 115 | setup( |
---|
| 116 | app=APP, |
---|
| 117 | data_files=DATA_FILES, |
---|
| 118 | include_package_data= True, |
---|
| 119 | options={'py2app': OPTIONS}, |
---|
| 120 | setup_requires=['py2app'], |
---|
| 121 | ) |
---|