Changeset 92df9cbd in sasview for installers/setup_exe.py


Ignore:
Timestamp:
Sep 20, 2017 7:27:53 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:
488f3a5
Parents:
1693141
Message:

bundler resources by directory

File:
1 edited

Legend:

Unmodified
Added
Removed
  • installers/setup_exe.py

    r460d3a1 r92df9cbd  
    2525from distutils.filelist import findall 
    2626from distutils.sysconfig import get_python_lib 
    27 import py2exe 
    2827 
    2928#from idlelib.PyShell import warning_stream 
    3029 
     30# Need the installer dir on the python path to find helper modules 
     31installer_dir = os.path.abspath(os.path.dirname(__file__)) 
     32if installer_dir != os.path.abspath(os.getcwd()): 
     33    raise RuntimeError("Must run setup_exe from the installers directory") 
     34sys.path.append(installer_dir) 
     35 
     36# Need the installer dir on the python path to find helper modules 
    3137if os.path.abspath(os.path.dirname(__file__)) != os.path.abspath(os.getcwd()): 
    3238    raise RuntimeError("Must run setup_exe from the installers directory") 
     39sys.path.append(installer_dir) 
    3340 
    3441# put the build directory at the front of the path 
     
    159166        self.name = "SasView" 
    160167 
    161 # 
    162 # Adapted from http://www.py2exe.org/index.cgi/MatPlotLib 
    163 # to use the MatPlotLib. 
    164 # 
    165 matplotlibdatadir = matplotlib.get_data_path() 
    166 matplotlibdata = findall(matplotlibdatadir) 
    167  
    168168data_files = [] 
    169169 
     
    175175data_files += periodictable.data_files() 
    176176 
    177 for f in matplotlibdata: 
    178     dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:]) 
    179     data_files.append((os.path.split(dirname)[0], [f])) 
     177# 
     178# Adapted from http://www.py2exe.org/index.cgi/MatPlotLib 
     179# to use the MatPlotLib. 
     180# 
     181mpl_dir = matplotlib.get_data_path() 
     182for dirpath, dirnames, filenames in os.walk(mpl_dir): 
     183    target_dir = os.path.join("mpl-data", os.path.relpath(dirpath, mpl_dir)) 
     184    source_files = [os.path.join(dirpath, f) for f in filenames] 
     185    data_files.append((target_dir, source_files)) 
    180186 
    181187import sasmodels 
     
    219225 
    220226# Copying the images directory to the distribution directory. 
    221 images_dir = local_config.icon_path 
    222 for f in findall(images_dir): 
    223     data_files.append(("images", [f])) 
     227data_files.append(("images", findall(local_config.icon_path))) 
    224228 
    225229# Copying the HTML help docs 
    226 media_dir = local_config.media_path 
    227 for f in findall(media_dir): 
    228     data_files.append(("media", [f])) 
     230data_files.append(("media", findall(local_config.media_path))) 
    229231 
    230232# Copying the sample data user data 
    231233test_dir = local_config.test_path 
    232 for f in findall(os.path.join(test_dir, "1d_data")): 
    233     data_files.append((os.path.join("test", "1d_data"), [f])) 
    234 for f in findall(os.path.join(test_dir, "2d_data")): 
    235     data_files.append((os.path.join("test", "2d_data"), [f])) 
    236 for f in findall(os.path.join(test_dir, "save_states")): 
    237     data_files.append((os.path.join("test", "save_states"), [f])) 
    238 for f in findall(os.path.join(test_dir, "upcoming_formats")): 
    239     data_files.append((os.path.join("test", "upcoming_formats"), [f])) 
     234for dirpath, dirnames, filenames in os.walk(test_dir): 
     235    target_dir = os.path.join("test", os.path.relpath(dirpath, test_dir)) 
     236    source_files = [os.path.join(dirpath, f) for f in filenames] 
     237    data_files.append((target_dir, source_files)) 
    240238 
    241239# See if the documentation has been built, and if so include it. 
    242240if os.path.exists(doc_path): 
    243241    for dirpath, dirnames, filenames in os.walk(doc_path): 
    244         for filename in filenames: 
    245             sub_dir = os.path.join("doc", os.path.relpath(dirpath, doc_path)) 
    246             data_files.append((sub_dir, [os.path.join(dirpath, filename)])) 
     242        target_dir = os.path.join("doc", os.path.relpath(dirpath, doc_path)) 
     243        source_files = [os.path.join(dirpath, f) for f in filenames] 
     244        data_files.append((target_dir, source_files)) 
    247245else: 
    248246    raise Exception("You must first build the documentation before creating an installer.") 
    249247 
    250248# Copying opencl include files 
    251 site_loc = get_python_lib() 
    252 opencl_include_dir = os.path.join(site_loc, "pyopencl", "cl") 
    253 for f in findall(opencl_include_dir): 
    254     data_files.append((os.path.join("includes", "pyopencl"), [f])) 
     249opencl_source = os.path.join(get_python_lib(), "pyopencl", "cl") 
     250opencl_target = os.path.join("includes", "pyopencl") 
     251data_files.append((opencl_target, findall(opencl_source))) 
    255252 
    256253# Numerical libraries 
     
    357354#CategoryInstaller.check_install(s) 
    358355 
     356#import pprint; pprint.pprint(data_files); sys.exit() 
     357 
     358import py2exe 
    359359setup( 
    360360    windows=[target_wx_client], 
Note: See TracChangeset for help on using the changeset viewer.