def appdir_from_executable(exepath): """Find the top-level application directory, given sys.executable.""" # The standard layout is <appdir>/ESKY_APPDATA_DIR/<vdir>/<exepath>. # Stripping of <exepath> is done by _bs_appdir_from_executable. vdir = _bs_appdir_from_executable(exepath) appdir = os.path.dirname(vdir) # On OSX we sometimes need to strip an additional directory since the # app can be contained in an <appname>.app directory. if sys.platform == "darwin" and is_version_dir(appdir): appdir = os.path.dirname(appdir) # TODO: remove compatability hook for ESKY_APPDATA_DIR="" if ESKY_APPDATA_DIR and os.path.basename(appdir) == ESKY_APPDATA_DIR: appdir = os.path.dirname(appdir) return appdir
def get_executable(self): executable = sys.executable if platform.system() == "Windows": # Find correct executable appdir = os.path.dirname(sys.executable) from esky.bootstrap import split_app_version, is_version_dir, \ pathjoin for nm in os.listdir(appdir): (appnm, ver, platform_name) = split_app_version(nm) if not (ver and platform_name): continue if is_version_dir(pathjoin(appdir, nm)): executable = pathjoin(appdir, nm, sys.executable.split("\\")[-1]) return executable