Changeset b1a65b6 in sasview for sansmodels


Ignore:
Timestamp:
Mar 1, 2011 10:05:05 PM (14 years ago)
Author:
Jae Cho <jhjcho@…>
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, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
8ec6923
Parents:
342a506
Message:

more fixes on media path for py2exe

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/__init__.py

    rae3ce4e rb1a65b6  
    7171# \section help_sec Contact Info 
    7272# Code and Documentation by Mathieu Doucet as part of the DANSE project. 
     73#PLUGIN_ID = "models plug-in 0.4" 
     74from sans.models import * 
    7375 
    74 __author__ = 'Mathieu Doucet' 
     76import os 
     77from distutils.filelist import findall 
     78 
     79def get_data_path(media): 
     80    """ 
     81    """ 
     82    # Check for data path in the package 
     83    path = os.path.join(os.path.dirname(__file__), media) 
     84    if os.path.isdir(path): 
     85        return path 
     86 
     87    # Check for data path next to exe/zip file. 
     88    # If we are inside a py2exe zip file, we need to go up 
     89    # to get to the directory containing  
     90    # the media for this module 
     91    path = os.path.dirname(__file__) 
     92    #Look for maximum n_dir up of the current dir to find media 
     93    n_dir = 12 
     94    for i in range(n_dir): 
     95        path, _ = os.path.split(path) 
     96        media_path = os.path.join(path, media) 
     97        if os.path.isdir(media_path): 
     98            module_media_path = os.path.join(media_path, 'models_media') 
     99            if os.path.isdir(module_media_path): 
     100                return module_media_path 
     101            return media_path 
     102    
     103    raise RuntimeError('Could not find models media files') 
     104 
     105def data_files(): 
     106    """ 
     107    Return the data files associated with media. 
     108     
     109    The format is a list of (directory, [files...]) pairs which can be 
     110    used directly in setup(...,data_files=...) for setup.py. 
     111 
     112    """ 
     113    data_files = [] 
     114    path = get_data_path(media="media") 
     115    for f in findall(path): 
     116        data_files.append(('media/models_media', [f])) 
     117    return data_files 
Note: See TracChangeset for help on using the changeset viewer.