@@ -1866,32 +1866,61 @@ def installer_executable(self) -> Optional[str]:
18661866
18671867 path = None
18681868 if not self .need_installer_change :
1869- path = sys .executable
1869+ self ._installer_executable = sys .executable
1870+ return self ._installer_executable
18701871
1871- else :
1872- # Compare existing executable with current executable
1873- current_executable = sys .executable
1874- # Use 'ayon.exe' for executable lookup on Windows
1875- root , filename = os .path .split (current_executable )
1876- if filename == "ayon_console.exe" :
1877- current_executable = os .path .join (root , "ayon.exe" )
1878-
1879- # TODO look to expected target install directory too
1880- executables_info = get_executables_info_by_version (
1881- self .expected_installer_version )
1882- for executable_info in executables_info :
1883- executable_path = executable_info .get ("executable" )
1884- if (
1885- not os .path .exists (executable_path )
1886- or executable_path == current_executable
1887- ):
1888- continue
1889- path = executable_path
1890- break
1872+ # Compare existing executable with current executable
1873+ current_executable = sys .executable
1874+ # Use 'ayon.exe' for executable lookup on Windows
1875+ root , filename = os .path .split (current_executable )
1876+ if filename == "ayon_console.exe" :
1877+ current_executable = os .path .join (root , "ayon.exe" )
1878+
1879+ # TODO look to expected target install directory too
1880+ executables_info = get_executables_info_by_version (
1881+ self .expected_installer_version )
1882+ for executable_info in executables_info :
1883+ executable_path = executable_info .get ("executable" )
1884+ if (
1885+ not os .path .exists (executable_path )
1886+ or executable_path == current_executable
1887+ ):
1888+ continue
1889+ path = executable_path
1890+ break
1891+
1892+ # Make sure current executable filename is used on Windows
1893+ if path and filename == "ayon_console.exe" :
1894+ path = os .path .join (os .path .dirname (path ), filename )
1895+
1896+ if path :
1897+ self ._installer_executable = path
1898+ return path
1899+
1900+ # Guess based on "expected" path of the version
1901+ # - is used if the AYON is already installed at target location but is
1902+ # missing in the metadata file
1903+ current_version = os .environ ["AYON_VERSION" ]
1904+ platform_name = platform .system ().lower ()
1905+ if platform_name in {"windows" , "linux" }:
1906+ executable_dir , exe_name = os .path .split (sys .executable )
1907+ install_root , dirname = os .path .split (executable_dir )
1908+ if current_version in dirname :
1909+ new_dirname = dirname .replace (
1910+ current_version ,
1911+ self .expected_installer_version
1912+ )
1913+ executable = os .path .join (
1914+ install_root , new_dirname , exe_name
1915+ )
1916+ if os .path .exists (executable ):
1917+ path = executable
18911918
1892- # Make sure current executable filename is used on Windows
1893- if path and filename == "ayon_console.exe" :
1894- path = os .path .join (os .path .dirname (path ), filename )
1919+ elif platform_name == "darwin" :
1920+ app_name = f"AYON { self .expected_installer_version } .app"
1921+ excutable = f"/Applications/{ app_name } /Contents/MacOS/ayon"
1922+ if os .path .exists (excutable ):
1923+ path = excutable
18951924
18961925 self ._installer_executable = path
18971926 return path
0 commit comments