source: sasview/invariantview/src/sans/perspectives/invariant/__init__.py @ 31f3222b

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 31f3222b was b7cfa8d, checked in by Mathieu Doucet <doucetm@…>, 13 years ago

Re #5 fixing installer build on mac

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[c128284]1PLUGIN_ID = "Invariant plug-in 1.0"
[698a734]2import os
[b7cfa8d]3from distutils.filelist import findall
[698a734]4def get_data_path(media):
5    """
6    """
7    # Check for data path in the package
8    path = os.path.join(os.path.dirname(__file__), media)
9    if os.path.isdir(path):
10        return path
11
12    # Check for data path next to exe/zip file.
13    # If we are inside a py2exe zip file, we need to go up
[e56869f]14    # to get to the directory containing
[85a24d9]15    # the media for this module
[e56869f]16    path = os.path.dirname(__file__)
[85a24d9]17    #Look for maximum n_dir up of the current dir to find media
[e56869f]18    n_dir = 12
[698a734]19    for i in range(n_dir):
[e56869f]20        path, _ = os.path.split(path)
21        media_path = os.path.join(path, media)
22        if os.path.isdir(media_path):
[4a2b054]23            module_media_path = os.path.join(media_path, 'invariant_media')
24            if os.path.isdir(module_media_path):
25                return module_media_path
26            return media_path
[e56869f]27   
[698a734]28    raise RuntimeError('Could not find invariant media files')
29
30def data_files():
31    """
32    Return the data files associated with media invariant.
33   
34    The format is a list of (directory, [files...]) pairs which can be
35    used directly in setup(...,data_files=...) for setup.py.
36
37    """
[4a2b054]38    data_files = []
[698a734]39    path = get_data_path(media="media")
[b7cfa8d]40    for f in findall(path):
[698a734]41        data_files.append(('media/invariant_media', [f]))
42    return data_files
Note: See TracBrowser for help on using the repository browser.