source: sasview/installers/setup_mac.py @ 0046c6a

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 0046c6a was 0046c6a, 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
RevLine 
[959eb01]1"""
2This is a setup.py script partly generated by py2applet
3
4Usage:
5    python setup.py py2app
6
7
8NOTES:
[25a42f99]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
[959eb01]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"""
[d66dbcc]14from __future__ import print_function
15
[959eb01]16import os
17import sys
[0046c6a]18import string
[914ba0a]19
[959eb01]20from distutils.util import get_platform
[914ba0a]21from distutils.filelist import findall
22from distutils.sysconfig import get_python_lib
[d66dbcc]23
24from setuptools import setup
25
26import macholib_patch
27
[0046c6a]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
[959eb01]32root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
[d66dbcc]33platform = '%s-%s'%(get_platform(), sys.version[:3])
[914ba0a]34doc_path = os.path.join(root, 'build', 'lib.'+platform, 'doc')
[0046c6a]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)
[914ba0a]38
[d66dbcc]39#Extending recursion limit
40sys.setrecursionlimit(10000)
41
[914ba0a]42from sas.sasview import local_config
43
[959eb01]44ICON = local_config.SetupIconFile_mac
[0046c6a]45data_files = []
[959eb01]46
[0046c6a]47# Include data for supporting packages
[914ba0a]48import periodictable
[0046c6a]49data_files += periodictable.data_files()
50
51import sasmodels
52data_files += sasmodels.data_files()
53
54# Data files for the different perspectives
[914ba0a]55from sas.sasgui.perspectives import fitting
[0046c6a]56data_files += fitting.data_files()
57
[914ba0a]58from sas.sasgui.perspectives import calculator
[0046c6a]59data_files += calculator.data_files()
60
[914ba0a]61from sas.sasgui.perspectives import invariant
[0046c6a]62data_files += invariant.data_files()
[959eb01]63
[0046c6a]64from sas.sasgui import guiframe
65data_files += guiframe.data_files()
[914ba0a]66
67# Copy the config files
[25a42f99]68sasview_path = os.path.join(sas_path, 'sasview')
[0046c6a]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')]))
[914ba0a]72
[0046c6a]73# Copy the logging config
74sas_path = os.path.join('..', 'src', 'sas')
75data_files.append(('.', [os.path.join(sas_path, 'logging.ini')]))
[914ba0a]76
[0046c6a]77if os.path.isfile("BUILD_NUMBER"):
78    data_files.append(('.', ["BUILD_NUMBER"]))
[914ba0a]79
80# Copying the images directory to the distribution directory.
[0046c6a]81images_dir = local_config.icon_path
[914ba0a]82for f in findall(images_dir):
[0046c6a]83    data_files.append(("images", [f]))
[914ba0a]84
85# Copying the HTML help docs
[0046c6a]86media_dir = local_config.media_path
[914ba0a]87for f in findall(media_dir):
[0046c6a]88    data_files.append(("media", [f]))
[914ba0a]89
90# Copying the sample data user data
[0046c6a]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]))
[959eb01]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))
[0046c6a]106            data_files.append((sub_dir, [os.path.join(dirpath, filename)]))
[959eb01]107else:
108    raise Exception("You must first build the documentation before creating an installer.")
109
[0046c6a]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
[959eb01]126# locate file extensions
127def find_extension():
128    """
129    Describe the extensions that can be read by the current application
130    """
131    try:
[a67ec83]132        extensions = []
[959eb01]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)
[a67ec83]139            if ext.strip() not in EXCEPTION_LIST and ext.strip() not in extensions:
140                extensions.append(ext)
141    except Exception:
[959eb01]142        pass
143    try:
144        file_type, ext = string.split(local_config.APPLICATION_WLIST, "|*.", 1)
[a67ec83]145        if ext.strip() not in EXCEPTION_LIST and ext.strip() not in extensions:
146            extensions.append(ext)
147    except Exception:
[959eb01]148        pass
149    try:
150        for item in local_config.PLUGINS_WLIST:
151            file_type, ext = string.split(item, "|*.", 1)
[a67ec83]152            if ext.strip() not in EXCEPTION_LIST and ext.strip() not in extensions:
153                extensions.append(ext)
154    except Exception:
[959eb01]155        pass
156
[a67ec83]157    return extensions
[959eb01]158
159EXTENSIONS_LIST = find_extension()
160
161plist = dict(CFBundleDocumentTypes=[dict(CFBundleTypeExtensions=EXTENSIONS_LIST,
162                                         CFBundleTypeIconFile=ICON,
[25a42f99]163                                         CFBundleTypeName="sasview file",
164                                         CFBundleTypeRole="Shell")],)
[959eb01]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
[914ba0a]170from sas.sasview import __version__ as VERSION
[959eb01]171APPNAME = "SasView "+VERSION
172DMGNAME = "SasView-"+VERSION+"-MacOSX"
[914ba0a]173APP = ['sasview_gui.py']
[959eb01]174
175EXCLUDES = ['PyQt4', 'sip', 'QtGui']
176
177OPTIONS = {'argv_emulation': True,
[914ba0a]178           'packages': ['lxml', 'numpy', 'scipy', 'pytz', 'encodings',
179                        'encodings', 'matplotlib', 'periodictable',
180                        'reportlab', 'sasmodels', 'pyopencl', 'h5py',
181                       ],
[959eb01]182           'iconfile': ICON,
[914ba0a]183           'frameworks': [libxml_path],
[0046c6a]184           'resources': [],
[914ba0a]185           'plist': plist,
[959eb01]186           'excludes' : EXCLUDES,
[914ba0a]187          }
[959eb01]188setup(
189    name=APPNAME,
190    app=APP,
[0046c6a]191    data_files=data_files,
[914ba0a]192    include_package_data=True,
[959eb01]193    options={'py2app': OPTIONS},
194    setup_requires=['py2app'],
195)
196
197#Build dmg
[914ba0a]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))
[959eb01]202os.system('chmod a+r "%s"'%DMG)
Note: See TracBrowser for help on using the repository browser.