source: sasview/installers/setup_mac.py @ 5f51c86

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalcmagnetic_scattrelease-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 5f51c86 was 0ccbd36, checked in by Paul Kienzle <pkienzle@…>, 7 years ago

reduce differences between setup_mac and setup_exe

  • Property mode set to 100644
File size: 6.7 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,
10               change the following line in py2app/recipes/matplotlib.py
11               mf.import_hook('pytz.tzinfo', m, ['UTC'])
12   12/05/2011: Needs macholib >= 1.4.3 and py2app >= 0.6.4 to create a 64-bit app
13"""
14from __future__ import print_function
15
16import os
17import sys
18import string
19
20from distutils.util import get_platform
21from distutils.filelist import findall
22from distutils.sysconfig import get_python_lib
23
24from setuptools import setup
25
26import macholib_patch
27
28if os.path.abspath(os.path.dirname(__file__)) != os.path.abspath(os.getcwd()):
29    raise RuntimeError("Must run setup_exe from the installers directory")
30
31# put the build directory at the front of the path
32root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
33platform = '%s-%s'%(get_platform(), sys.version[:3])
34doc_path = os.path.join(root, 'build', 'lib.'+platform, 'doc')
35build_path = os.path.join(root, 'sasview-install', 'lib', 'python2.7', 'site-packages')
36#sys.path.insert(0, build_path)
37print("build path", build_path)
38
39#Extending recursion limit
40sys.setrecursionlimit(10000)
41
42from sas.sasview import local_config
43
44ICON = local_config.SetupIconFile_mac
45data_files = []
46
47# Include data for supporting packages
48import periodictable
49data_files += periodictable.data_files()
50
51import sasmodels
52data_files += sasmodels.data_files()
53
54# Data files for the different perspectives
55from sas.sasgui.perspectives import fitting
56data_files += fitting.data_files()
57
58from sas.sasgui.perspectives import calculator
59data_files += calculator.data_files()
60
61from sas.sasgui.perspectives import invariant
62data_files += invariant.data_files()
63
64from sas.sasgui import guiframe
65data_files += guiframe.data_files()
66
67# Copy the config files
68sasview_path = os.path.join('..', 'src', 'sas', 'sasview')
69data_files.append(('.', [os.path.join(sasview_path, 'custom_config.py')]))
70data_files.append(('config', [os.path.join(sasview_path, 'custom_config.py')]))
71data_files.append(('.', [os.path.join(sasview_path, 'local_config.py')]))
72
73# Copy the logging config
74sas_path = os.path.join('..', 'src', 'sas')
75data_files.append(('.', [os.path.join(sas_path, 'logging.ini')]))
76
77if os.path.isfile("BUILD_NUMBER"):
78    data_files.append(('.', ["BUILD_NUMBER"]))
79
80# Copying the images directory to the distribution directory.
81images_dir = local_config.icon_path
82for f in findall(images_dir):
83    data_files.append(("images", [f]))
84
85# Copying the HTML help docs
86media_dir = local_config.media_path
87for f in findall(media_dir):
88    data_files.append(("media", [f]))
89
90# Copying the sample data user data
91test_dir = local_config.test_path
92for f in findall(os.path.join(test_dir, "1d_data")):
93    data_files.append((os.path.join("test", "1d_data"), [f]))
94for f in findall(os.path.join(test_dir, "2d_data")):
95    data_files.append((os.path.join("test", "2d_data"), [f]))
96for f in findall(os.path.join(test_dir, "save_states")):
97    data_files.append((os.path.join("test", "save_states"), [f]))
98for f in findall(os.path.join(test_dir, "upcoming_formats")):
99    data_files.append((os.path.join("test", "upcoming_formats"), [f]))
100
101# See if the documentation has been built, and if so include it.
102if os.path.exists(doc_path):
103    for dirpath, dirnames, filenames in os.walk(doc_path):
104        for filename in filenames:
105            sub_dir = os.path.join("doc", os.path.relpath(dirpath, doc_path))
106            data_files.append((sub_dir, [os.path.join(dirpath, filename)]))
107else:
108    raise Exception("You must first build the documentation before creating an installer.")
109
110# Copying opencl include files
111site_loc = get_python_lib()
112opencl_include_dir = os.path.join(site_loc, "pyopencl", "cl")
113for f in findall(opencl_include_dir):
114    data_files.append((os.path.join("includes", "pyopencl"), [f]))
115
116# Locate libxml2 library
117lib_locs = ['/usr/local/lib', '/usr/lib']
118libxml_path = None
119for item in lib_locs:
120    libxml_path_test = '%s/libxml2.2.dylib' % item
121    if os.path.isfile(libxml_path_test):
122        libxml_path = libxml_path_test
123if libxml_path is None:
124    raise RuntimeError("Could not find libxml2 on the system")
125
126# locate file extensions
127def find_extension():
128    """
129    Describe the extensions that can be read by the current application
130    """
131    try:
132        extensions = []
133        EXCEPTION_LIST = ['*', '.', '']
134        from sas.sascalc.dataloader.loader import Loader
135        wild_cards = Loader().get_wildcards()
136        for item in wild_cards:
137            #['All (*.*)|*.*']
138            file_type, ext = string.split(item, "|*.", 1)
139            if ext.strip() not in EXCEPTION_LIST and ext.strip() not in extensions:
140                extensions.append(ext)
141    except Exception:
142        pass
143    try:
144        file_type, ext = string.split(local_config.APPLICATION_WLIST, "|*.", 1)
145        if ext.strip() not in EXCEPTION_LIST and ext.strip() not in extensions:
146            extensions.append(ext)
147    except Exception:
148        pass
149    try:
150        for item in local_config.PLUGINS_WLIST:
151            file_type, ext = string.split(item, "|*.", 1)
152            if ext.strip() not in EXCEPTION_LIST and ext.strip() not in extensions:
153                extensions.append(ext)
154    except Exception:
155        pass
156
157    return extensions
158
159EXTENSIONS_LIST = find_extension()
160
161plist = dict(CFBundleDocumentTypes=[dict(CFBundleTypeExtensions=EXTENSIONS_LIST,
162                                         CFBundleTypeIconFile=ICON,
163                                         CFBundleTypeName="sasview file",
164                                         CFBundleTypeRole="Shell")],)
165
166#Get version - NB nasty hack. Need to find correct way to give path to installed sasview (AJJ)
167#h5py has been added to packages. It requires hdf5 to be installed separetly
168#
169
170from sas.sasview import __version__ as VERSION
171APPNAME = "SasView "+VERSION
172DMGNAME = "SasView-"+VERSION+"-MacOSX"
173APP = ['sasview_gui.py']
174
175EXCLUDES = ['PyQt4', 'sip', 'QtGui']
176
177OPTIONS = {'argv_emulation': True,
178           'packages': ['lxml', 'numpy', 'scipy', 'pytz', 'encodings',
179                        'encodings', 'matplotlib', 'periodictable',
180                        'reportlab', 'sasmodels', 'pyopencl', 'h5py',
181                       ],
182           'iconfile': ICON,
183           'frameworks': [libxml_path],
184           'resources': [],
185           'plist': plist,
186           'excludes' : EXCLUDES,
187          }
188setup(
189    name=APPNAME,
190    app=APP,
191    data_files=data_files,
192    include_package_data=True,
193    options={'py2app': OPTIONS},
194    setup_requires=['py2app'],
195)
196
197#Build dmg
198DMG = "dist/%s.dmg"%DMGNAME
199if os.path.exists(DMG):
200    os.unlink(DMG)
201os.system('cd dist && ../../build_tools/dmgpack.sh "%s" "%s.app"'%(DMGNAME, APPNAME))
202os.system('chmod a+r "%s"'%DMG)
Note: See TracBrowser for help on using the repository browser.