Changeset 0046c6a in sasview for installers/setup_mac.py


Ignore:
Timestamp:
Aug 30, 2017 6:46:37 PM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
0ccbd36
Parents:
156203a
Message:

reduce differences between setup_mac and setup_exe

File:
1 edited

Legend:

Unmodified
Added
Removed
  • installers/setup_mac.py

    r156203a r0046c6a  
    1515 
    1616import os 
     17import sys 
    1718import string 
    18 import sys 
    1919 
    2020from distutils.util import get_platform 
     
    2626import macholib_patch 
    2727 
     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 
    2832root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 
    2933platform = '%s-%s'%(get_platform(), sys.version[:3]) 
    3034doc_path = os.path.join(root, 'build', 'lib.'+platform, 'doc') 
    31 env = os.path.join(root, 'sasview-install', 'lib', 'python2.7', 'site-packages') 
    32 #sys.path.insert(0, env) 
     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) 
    3338 
    3439#Extending recursion limit 
    3540sys.setrecursionlimit(10000) 
    3641 
    37 print("BUILDING PATH INSIDE", env) 
    38  
    3942from sas.sasview import local_config 
    4043 
    4144ICON = local_config.SetupIconFile_mac 
    42 RESOURCES_FILES = [] 
    43 DATA_FILES = [] 
    44  
    45 #Periodictable data file 
     45data_files = [] 
     46 
     47# Include data for supporting packages 
    4648import periodictable 
    47 DATA_FILES += periodictable.data_files() 
    48 #invariant and calculator help doc 
     49data_files += periodictable.data_files() 
     50 
     51import sasmodels 
     52data_files += sasmodels.data_files() 
     53 
     54# Data files for the different perspectives 
    4955from sas.sasgui.perspectives import fitting 
    50 DATA_FILES += fitting.data_files() 
     56data_files += fitting.data_files() 
     57 
    5158from sas.sasgui.perspectives import calculator 
    52 DATA_FILES += calculator.data_files() 
     59data_files += calculator.data_files() 
     60 
    5361from sas.sasgui.perspectives import invariant 
    54 DATA_FILES += invariant.data_files() 
    55 import sasmodels 
    56 DATA_FILES += sasmodels.data_files() 
     62data_files += invariant.data_files() 
     63 
    5764from sas.sasgui import guiframe 
    58 DATA_FILES += guiframe.data_files() 
    59  
    60 #CANSAxml reader data files 
    61 from sas.sascalc.dataloader import readers 
    62 RESOURCES_FILES.append(os.path.join(readers.get_data_path(), 'defaults.json')) 
     65data_files += guiframe.data_files() 
    6366 
    6467# Copy the config files 
     68sasview_path = os.path.join(sas_path, '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 
    6574sas_path = os.path.join('..', 'src', 'sas') 
    66 DATA_FILES.append(('.', [os.path.join(sas_path, 'logging.ini')])) 
    67 sasview_path = os.path.join(sas_path, 'sasview') 
    68 custom_config_file = os.path.join(sasview_path, 'custom_config.py') 
    69 local_config_file = os.path.join(sasview_path, 'local_config.py') 
    70 logging_ini = os.path.join(sas_path, 'logging.ini') 
    71 DATA_FILES.append(('.', [custom_config_file])) 
    72 DATA_FILES.append(('config', [custom_config_file])) 
    73 DATA_FILES.append(('.', [local_config_file])) 
    74 DATA_FILES.append(('.', [logging_ini])) 
     75data_files.append(('.', [os.path.join(sas_path, 'logging.ini')])) 
    7576 
    7677if os.path.isfile("BUILD_NUMBER"): 
    77     DATA_FILES.append(('.', ["BUILD_NUMBER"])) 
    78  
     78    data_files.append(('.', ["BUILD_NUMBER"])) 
     79 
     80# Copying the images directory to the distribution directory. 
    7981images_dir = local_config.icon_path 
     82for f in findall(images_dir): 
     83    data_files.append(("images", [f])) 
     84 
     85# Copying the HTML help docs 
    8086media_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 
    8191test_dir = local_config.test_path 
    82 test_1d_dir = os.path.join(test_dir, "1d_data") 
    83 test_2d_dir = os.path.join(test_dir, "2d_data") 
    84 test_save_dir = os.path.join(test_dir, "save_states") 
    85 test_upcoming_dir = os.path.join(test_dir, "upcoming_formats") 
    86  
    87 # Copying the images directory to the distribution directory. 
    88 for f in findall(images_dir): 
    89     DATA_FILES.append(("images", [f])) 
    90  
    91 # Copying the HTML help docs 
    92 for f in findall(media_dir): 
    93     DATA_FILES.append(("media", [f])) 
    94  
    95 # Copying the sample data user data 
    96 for f in findall(test_1d_dir): 
    97     DATA_FILES.append((os.path.join("test", "1d_data"), [f])) 
    98  
    99 # Copying the sample data user data 
    100 for f in findall(test_2d_dir): 
    101     DATA_FILES.append((os.path.join("test", "2d_data"), [f])) 
    102  
    103 # Copying the sample data user data 
    104 for f in findall(test_save_dir): 
    105     DATA_FILES.append((os.path.join("test", "save_states"), [f])) 
    106  
    107 # Copying the sample data user data 
    108 for f in findall(test_upcoming_dir): 
    109     DATA_FILES.append((os.path.join("test", "upcoming_formats"), [f])) 
     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.") 
    110109 
    111110# Copying opencl include files 
     
    113112opencl_include_dir = os.path.join(site_loc, "pyopencl", "cl") 
    114113for f in findall(opencl_include_dir): 
    115     DATA_FILES.append((os.path.join("includes", "pyopencl"), [f])) 
    116  
    117 # See if the documentation has been built, and if so include it. 
    118 print(doc_path) 
    119 if os.path.exists(doc_path): 
    120     for dirpath, dirnames, filenames in os.walk(doc_path): 
    121         for filename in filenames: 
    122             sub_dir = os.path.join("doc", os.path.relpath(dirpath, doc_path)) 
    123             DATA_FILES.append((sub_dir, [os.path.join(dirpath, filename)])) 
    124 else: 
    125     raise Exception("You must first build the documentation before creating an installer.") 
     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") 
    126125 
    127126# locate file extensions 
     
    160159EXTENSIONS_LIST = find_extension() 
    161160 
    162  
    163161plist = dict(CFBundleDocumentTypes=[dict(CFBundleTypeExtensions=EXTENSIONS_LIST, 
    164162                                         CFBundleTypeIconFile=ICON, 
    165163                                         CFBundleTypeName="sasview file", 
    166164                                         CFBundleTypeRole="Shell")],) 
    167  
    168 # Locate libxml2 library 
    169 lib_locs = ['/usr/local/lib', '/usr/lib'] 
    170 libxml_path = None 
    171 for item in lib_locs: 
    172     libxml_path_test = '%s/libxml2.2.dylib' % item 
    173     if os.path.isfile(libxml_path_test): 
    174         libxml_path = libxml_path_test 
    175 if libxml_path is None: 
    176     raise RuntimeError, "Could not find libxml2 on the system" 
    177165 
    178166#Get version - NB nasty hack. Need to find correct way to give path to installed sasview (AJJ) 
     
    194182           'iconfile': ICON, 
    195183           'frameworks': [libxml_path], 
    196            'resources': RESOURCES_FILES, 
     184           'resources': [], 
    197185           'plist': plist, 
    198186           'excludes' : EXCLUDES, 
     
    201189    name=APPNAME, 
    202190    app=APP, 
    203     data_files=DATA_FILES, 
     191    data_files=data_files, 
    204192    include_package_data=True, 
    205193    options={'py2app': OPTIONS}, 
Note: See TracChangeset for help on using the changeset viewer.