python.cmd 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. @ECHO OFF
  2. REM
  3. REM Copyright (c) Contributors to the Open 3D Engine Project.
  4. REM For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. REM
  6. REM SPDX-License-Identifier: Apache-2.0 OR MIT
  7. REM
  8. REM
  9. REM This script provides a single entry point that you can trust is present.
  10. REM Depending on this entry point instead of trying to find a python.exe
  11. REM In a subfolder allows you to keep working if the version of python changes or
  12. REM other environmental requirements change.
  13. REM When the project switches to a new version of Python, this file will be updated.
  14. :: Set up window
  15. TITLE O3DE DCC Scripting Interface Python.cmd
  16. :: Use obvious color to prevent confusion (Grey with Yellow Text)
  17. COLOR 8E
  18. echo.
  19. echo _____________________________________________________________________
  20. echo.
  21. echo ~ O3DE DCCsi Python.cmd ...
  22. echo _____________________________________________________________________
  23. echo.
  24. SETLOCAL
  25. SET CMD_DIR=%~dp0
  26. SET CMD_DIR=%CMD_DIR:~0,-1%
  27. IF "%PATH_DCCSIG%"=="" (set "PATH_DCCSIG=%CMD_DIR%")
  28. echo PATH_DCCSIG = %PATH_DCCSIG%
  29. :: Change to DCCsi root dir
  30. CD /D %PATH_DCCSIG%
  31. IF "%PATH_O3DE_PROJECT%"=="" (set "PATH_O3DE_PROJECT=%PATH_DCCSIG%")
  32. :: This maps up to the o3de root folder
  33. IF "%O3DE_REL_PATH%"=="" (set "O3DE_REL_PATH=..\..\..\..")
  34. :: Change to root o3de folder
  35. CD /d %O3DE_REL_PATH%
  36. IF "%O3DE_DEV%"=="" (set "O3DE_DEV=%CD%")
  37. :: Restore original directory
  38. popd
  39. SET O3DE_PYTHON=%O3DE_DEV%\python
  40. echo O3DE_PYTHON = %O3DE_PYTHON%
  41. :: O3DE Technical Art Gems Location
  42. IF "%PATH_O3DE_TECHART_GEMS%"=="" (set "PATH_O3DE_TECHART_GEMS=%O3DE_DEV%\Gems\AtomLyIntegration\TechnicalArt")
  43. echo PATH_O3DE_TECHART_GEMS = %PATH_O3DE_TECHART_GEMS%
  44. :: O3DE DccScriptingInterface Gem location
  45. IF "%PATH_DCCSIG%"=="" (set "DccScriptingInterface")
  46. echo PATH_DCCSIG = %PATH_DCCSIG%
  47. SET PATH=%O3DE_DEV%;%PATH_O3DE_TECHART_GEMS%;%PATH_DCCSIG%;%PATH%
  48. SET PYTHONPATH=%O3DE_DEV%;%PATH_O3DE_TECHART_GEMS%;%PATH_DCCSIG%;%PYTHONPATH%
  49. :: get the o3de python home
  50. FOR /F "tokens=* USEBACKQ" %%F IN (`%O3DE_PYTHON%\python.cmd %O3DE_PYTHON%\get_python_path.py`) DO (SET O3DE_PYTHONHOME=%%F)
  51. IF EXIST "%O3DE_PYTHONHOME%" GOTO PYTHONHOME_EXISTS
  52. ECHO Python not found in %O3DE_PYTHON%
  53. ECHO Try running %O3DE_PYTHON%\get_python.bat first.
  54. exit /B 1
  55. :PYTHONHOME_EXISTS
  56. SET PYTHON=%O3DE_PYTHONHOME%\python.exe
  57. echo PYTHON = %PYTHON%
  58. SET PYTHON_ARGS=%*
  59. IF [%1] EQU [debug] (
  60. SET PYTHON=%O3DE_PYTHONHOME%\python_d.exe
  61. SET PYTHON_ARGS=%PYTHON_ARGS:~6%
  62. )
  63. IF EXIST "%PYTHON%" GOTO PYTHON_EXISTS
  64. ECHO Could not find python executable at %PYTHON%
  65. exit /B 1
  66. :PYTHON_EXISTS
  67. :: Change to root dir
  68. CD /D %PATH_DCCSIG%
  69. echo _____________________________________________________________________
  70. echo.
  71. SET PYTHONNOUSERSITE=1
  72. "%PYTHON%" %PYTHON_ARGS%
  73. exit /B %ERRORLEVEL%