3
0

Env_O3DE_Python.bat 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. :: Sets up extended environment for O3DE and DCCsi python
  10. :: Skip initialization if already completed
  11. IF "%DCCSI_ENV_PY_INIT%"=="1" GOTO :END_OF_FILE
  12. :: Store current dir
  13. %~d0
  14. cd %~dp0
  15. PUSHD %~dp0
  16. CALL %~dp0\Env_O3DE_Core.bat
  17. echo.
  18. echo _____________________________________________________________________
  19. echo.
  20. echo ~ O3DE DCCsi Python Environment ...
  21. echo _____________________________________________________________________
  22. echo.
  23. :: this is the default env setup for O3DE python
  24. :: we will attempt to avoid causing conflicts in DCC tools with their
  25. :: own python (which is most of them)
  26. :: Python Version
  27. :: Ideally these are set to match the O3DE python distribution
  28. :: <O3DE>\python\runtime
  29. :: need a more reliable way to set these, instead of updating them to match every time python runtime updates
  30. IF "%DCCSI_PY_VERSION_MAJOR%"=="" (set DCCSI_PY_VERSION_MAJOR=3)
  31. echo DCCSI_PY_VERSION_MAJOR = %DCCSI_PY_VERSION_MAJOR%
  32. :: PY version Major
  33. IF "%DCCSI_PY_VERSION_MINOR%"=="" (set DCCSI_PY_VERSION_MINOR=10)
  34. echo DCCSI_PY_VERSION_MINOR = %DCCSI_PY_VERSION_MINOR%
  35. IF "%DCCSI_PY_VERSION_RELEASE%"=="" (set DCCSI_PY_VERSION_RELEASE=5)
  36. echo DCCSI_PY_VERSION_RELEASE = %DCCSI_PY_VERSION_RELEASE%
  37. :: shared location for 64bit python 3.10 DEV location
  38. :: this defines a DCCsi sandbox for lib site-packages by version
  39. :: <O3DE>\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\3rdParty\Python\Lib
  40. set "PATH_DCCSI_PYTHON=%PATH_DCCSIG%\3rdParty\Python"
  41. echo PATH_DCCSI_PYTHON = %PATH_DCCSI_PYTHON%
  42. :: add access to a Lib location that matches the py version (example: 3.10.x)
  43. :: switch this for other python versions like maya (2.7.x)
  44. IF "%PATH_DCCSI_PYTHON_LIB%"=="" (set "PATH_DCCSI_PYTHON_LIB=%PATH_DCCSI_PYTHON%\Lib\%DCCSI_PY_VERSION_MAJOR%.x\%DCCSI_PY_VERSION_MAJOR%.%DCCSI_PY_VERSION_MINOR%.x\site-packages")
  45. echo PATH_DCCSI_PYTHON_LIB = %PATH_DCCSI_PYTHON_LIB%
  46. :: we should NOT add to the PATH here (this is global)
  47. :: setting PATH should be move to Launch .bat files
  48. :::SET PATH=%PATH_DCCSI_PYTHON_LIB%;%PATH%
  49. :: shared location for default O3DE python location
  50. IF "%PATH_O3DE_PYTHON_INSTALL%"=="" (set "PATH_O3DE_PYTHON_INSTALL=%O3DE_DEV%\python")
  51. echo PATH_O3DE_PYTHON_INSTALL = %PATH_O3DE_PYTHON_INSTALL%
  52. :: location for O3DE python 3.10 location
  53. :: Note, many DCC tools (like Maya) include thier own python interpreter
  54. :: Some DCC apps may not operate correctly if PYTHONHOME is set (this is definitely the case with Maya)
  55. :: Be aware the python.cmd below does set PYTHONHOME
  56. IF "%DCCSI_PY_BASE%"=="" (set "DCCSI_PY_BASE=%PATH_O3DE_PYTHON_INSTALL%\python.cmd")
  57. echo DCCSI_PY_BASE = %DCCSI_PY_BASE%
  58. :: will set O3DE_PYTHONHOME location
  59. CALL %PATH_O3DE_PYTHON_INSTALL%\get_python_path.bat
  60. :: ide and debugger plug
  61. IF "%DCCSI_PY_DEFAULT%"=="" (set "DCCSI_PY_DEFAULT=%PATH_O3DE_PYTHON_INSTALL%\python.cmd")
  62. echo DCCSI_PY_DEFAULT = %DCCSI_PY_DEFAULT%
  63. :: Some IDEs like Wing, may in some cases need acess directly to the exe to operate correctly
  64. :: ide and debugger plug
  65. IF "%DCCSI_PY_IDE%"=="" (set "DCCSI_PY_IDE=%O3DE_PYTHONHOME%\python.exe")
  66. echo DCCSI_PY_IDE = %DCCSI_PY_IDE%
  67. :: O3DE installs additional python pkgs from 3rd party and other locations
  68. :: See: C:\path\to\o3de\python\runtime\python-x.x.x-revX-windows\python\Lib\site-packages\easy-install.pth
  69. ::ENDLOCAL
  70. :: Set flag so we don't initialize dccsi environment twice
  71. SET DCCSI_ENV_PY_INIT=1
  72. GOTO END_OF_FILE
  73. :: Return to starting directory
  74. POPD
  75. :END_OF_FILE