Changeset 3aa2f3c in sasview for src/sas


Ignore:
Timestamp:
Jun 28, 2016 7:10:33 PM (9 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:
74d9780
Parents:
80c2c85
Message:

working mac build with revised tree

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/__init__.py

    refe730d r3aa2f3c  
     1import sys 
    12import os 
     3from os.path import exists, expanduser, dirname, realpath, join as joinpath 
     4 
     5def dirn(path, n): 
     6    path = realpath(path) 
     7    for _ in range(n): 
     8        path = dirname(path) 
     9    return path 
    210 
    311# Set up config directories 
    412def make_user_folder(): 
    5     path = os.path.join(os.path.expanduser("~"),'.sasview') 
    6     if not os.path.exists(path): 
     13    path = joinpath(expanduser("~"),'.sasview') 
     14    if not exists(path): 
    715        os.mkdir(path) 
    816    return path 
    917 
     18 
    1019def find_app_folder(): 
    11     # If the directory containing sasview.py exists, then we are not running 
    12     # frozen and the current path is the app path. 
    13     root = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) 
    14     path = os.path.join(root, 'sasview') 
    15     if os.path.exists(path): 
     20    # We are starting out with the following info: 
     21    #     __file__ = .../sas/sasgui/__init__.pyc 
     22    # Check if the sister path .../sas/sasview exists, and use it as the 
     23    # app directory.  This will only be the case if the app is not frozen. 
     24    path = joinpath(dirn(__file__, 2), 'sasview') 
     25    if exists(path): 
    1626        return path 
    1727 
    18     # If we are running frozen, then skip from: 
    19     #    library.zip/sas/sasview 
    20     path = os.path.dirname(os.path.dirname(root)) 
     28    # If we are running frozen, then root is a parent directory 
     29    if sys.platform == 'darwin': 
     30        # Here is the path to the file on the mac: 
     31        #     .../Sasview.app/Contents/Resources/lib/python2.7/site-packages.zip/sas/sasgui/__init__.pyc 
     32        # We want the path to the Resources directory. 
     33        path = dirn(__file__, 6) 
     34    elif os.name == 'nt': 
     35        # Here is the path to the file on windows: 
     36        #     ../Sasview/library.zip/sas/sasgui/__init__.pyc 
     37        # We want the path to the Sasview directory. 
     38        path = dirn(__file__, 4) 
     39    else: 
     40        raise RuntimeError("Couldn't find the app directory") 
    2141    return path 
    2242 
Note: See TracChangeset for help on using the changeset viewer.