def appexe_from_executable(exepath):
    appdir = appdir_from_executable(exepath)
    exename = os.path.basename(exepath)
    #  On OSX we might be in a bundle, run from Contents/MacOS/<exename>
    if sys.platform == "darwin":
        osx_dot_app_name = os.path.basename(appdir)
        potential_py2app_bootstrap_exe = None
        if osx_dot_app_name.endswith('.app'):
            potential_py2app_bootstrap_exe = osx_dot_app_name[:-4]
        app_bin_dir = os.path.join(appdir,"Contents","MacOS")
        if os.path.isdir(app_bin_dir):
            if potential_py2app_bootstrap_exe and os.path.exists(
                    os.path.join(app_bin_dir, potential_py2app_bootstrap_exe)):
                return os.path.join(app_bin_dir, potential_py2app_bootstrap_exe)
            return os.path.join(app_bin_dir, exename)
    return os.path.join(appdir,exename)
Find the top-level application executable, given sys.executable.
dataset/ETHPy150Open cloudmatrix/esky/esky/util.py/appexe_from_executable