source: sasview/sasview/setup_mac.py @ 70be725

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 70be725 was 70be725, checked in by wojciech, 8 years ago

Build script fixes

  • Property mode set to 100644
File size: 5.2 KB
Line 
1"""
2This is a setup.py script partly generated by py2applet
3
4Usage:
5    python setup.py py2app
6
7
8NOTES:
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'])
11   12/05/2011: Needs macholib >= 1.4.3 and py2app >= 0.6.4 to create a 64-bit app
12"""
13from setuptools import setup
14import periodictable.xsf
15import sas.sascalc.dataloader.readers
16import os
17import string
18import local_config
19import pytz
20import sys
21import platform
22#Extending recursion limit
23sys.setrecursionlimit(10000)
24
25from distutils.util import get_platform
26root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
27platform = '%s-%s'%(get_platform(),sys.version[:3])
28#build_path = os.path.join(root, 'build','lib.'+platform)
29build_path = os.path.join(root)
30sys.path.insert(0, build_path)
31
32ICON = local_config.SetupIconFile_mac
33EXTENSIONS_LIST = []
34DATA_FILES = []
35RESOURCES_FILES = []
36
37#Periodictable data file
38DATA_FILES = periodictable.data_files()
39#invariant and calculator help doc
40import sas.sasgui.perspectives.fitting as fitting
41DATA_FILES += fitting.data_files()
42import sas.sasgui.perspectives.calculator as calculator
43DATA_FILES += calculator.data_files()
44import sas.sasgui.perspectives.invariant as invariant
45DATA_FILES += invariant.data_files()
46#import sas.models as models
47import sasmodels.models as models
48DATA_FILES += models.data_files()
49import sas.sasgui.guiframe as guiframe
50DATA_FILES += guiframe.data_files()
51
52#CANSAxml reader data files
53RESOURCES_FILES.append(os.path.join(sas.sascalc.dataloader.readers.get_data_path(),'defaults.json'))
54
55# Locate libxml2 library
56lib_locs = ['/usr/local/lib', '/usr/lib']
57libxml_path = None
58for item in lib_locs:
59    libxml_path_test = '%s/libxml2.2.dylib' % item
60    if os.path.isfile(libxml_path_test):
61        libxml_path = libxml_path_test
62if libxml_path == None:
63    raise RuntimeError, "Could not find libxml2 on the system"
64
65APP = ['sasview.py']
66DATA_FILES += ['images','test','media', 'custom_config.py', 'local_config.py',
67               'default_categories.json']
68if os.path.isfile("BUILD_NUMBER"):
69    DATA_FILES.append("BUILD_NUMBER")
70
71# See if the documentation has been built, and if so include it.
72doc_path = os.path.join(build_path, "docs")
73print doc_path
74if os.path.exists(doc_path):
75    for dirpath, dirnames, filenames in os.walk(doc_path):
76        for filename in filenames:
77            sub_dir = os.path.join("docs", os.path.relpath(dirpath, doc_path))
78            DATA_FILES.append((sub_dir, [os.path.join(dirpath, filename)]))
79else:
80    raise Exception("You must first build the documentation before creating an installer.")
81
82# locate file extensions
83def find_extension():
84    """
85    Describe the extensions that can be read by the current application
86    """
87    try:
88        list = []
89        EXCEPTION_LIST = ['*', '.', '']
90        from sas.sascalc.dataloader.loader import Loader
91        wild_cards = Loader().get_wildcards()
92        for item in wild_cards:
93            #['All (*.*)|*.*']
94            file_type, ext = string.split(item, "|*.", 1)
95            if ext.strip() not in EXCEPTION_LIST and ext.strip() not in list:
96                list.append(ext)
97    except:
98        pass
99    try:
100        file_type, ext = string.split(local_config.APPLICATION_WLIST, "|*.", 1)
101        if ext.strip() not in EXCEPTION_LIST and ext.strip() not in list:
102            list.append(ext)
103    except:
104        pass
105    try:
106        for item in local_config.PLUGINS_WLIST:
107            file_type, ext = string.split(item, "|*.", 1)
108            if ext.strip() not in EXCEPTION_LIST and ext.strip() not in list:
109                list.append(ext)
110    except:
111        pass
112
113    return list
114
115EXTENSIONS_LIST = find_extension()
116
117
118plist = dict(CFBundleDocumentTypes=[dict(CFBundleTypeExtensions=EXTENSIONS_LIST,
119                                         CFBundleTypeIconFile=ICON,
120                                   CFBundleTypeName="sasview file",
121                                   CFBundleTypeRole="Shell" )],)
122
123#Get version - NB nasty hack. Need to find correct way to give path to installed sasview (AJJ)
124import __init__ as sasviewver
125
126VERSION = sasviewver.__version__
127APPNAME = "SasView "+VERSION
128DMGNAME = "SasView-"+VERSION+"-MacOSX"
129
130APP = ['sasview.py']
131DATA_FILES += ['images','test','media']
132
133EXCLUDES = ['PyQt4', 'sip', 'QtGui']
134
135OPTIONS = {'argv_emulation': True,
136           'packages': ['lxml','numpy', 'scipy', 'pytz', 'encodings',
137                        'encodings','matplotlib', 'periodictable',
138                        'reportlab','sasmodels'
139                        ],
140           'iconfile': ICON,
141           'frameworks':[libxml_path],
142           'resources': RESOURCES_FILES,
143           'plist':plist,
144           'excludes' : EXCLUDES,
145           }
146setup(
147    name=APPNAME,
148    app=APP,
149    data_files=DATA_FILES,
150    include_package_data= True,
151    options={'py2app': OPTIONS},
152    setup_requires=['py2app'],
153)
154
155#Build dmg
156DMG="dist/%s.dmg"%DMGNAME
157if os.path.exists(DMG): os.unlink(DMG)
158os.system('cd dist && ../../build_tools/dmgpack.sh "%s" "%s.app"'%(DMGNAME,APPNAME))
159os.system('chmod a+r "%s"'%DMG)
Note: See TracBrowser for help on using the repository browser.