get_python.bat 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. setlocal enabledelayedexpansion
  10. SET CMD_DIR=%~dp0
  11. SET CMD_DIR=%CMD_DIR:~0,-1%
  12. REM General strategy: Check if python is already installed
  13. REM If not, use cmake and the new package system to install it.
  14. REM Is python installed?
  15. cd /D %CMD_DIR%
  16. call python.cmd --version > NUL
  17. IF !ERRORLEVEL!==0 (
  18. echo get_python.bat: Python is already installed:
  19. call python.cmd --version
  20. goto install_packages
  21. )
  22. cd /D %CMD_DIR%\..
  23. REM IF you update this logic, update it in scripts/build/Platform/Windows/env_windows.cmd
  24. REM If cmake is not found on path, try a known location at LY_CMAKE_PATH
  25. where /Q cmake
  26. IF NOT !ERRORLEVEL!==0 (
  27. IF "%LY_CMAKE_PATH%"=="" (
  28. ECHO ERROR: CMake was not found on the PATH and LY_CMAKE_PATH is not defined.
  29. ECHO Please ensure CMake is on the path or set LY_CMAKE_PATH.
  30. EXIT /b 1
  31. )
  32. PATH !LY_CMAKE_PATH!;!PATH!
  33. where /Q cmake
  34. if NOT !ERRORLEVEL!==0 (
  35. ECHO ERROR: CMake was not found on the PATH or at the known location: !LY_CMAKE_PATH!
  36. ECHO Please add it to the path, set LY_CMAKE_PATH to be the directory containing it, or place it
  37. ECHO at the above location.
  38. EXIT /b 1
  39. )
  40. )
  41. REM output the version number for forensic logging
  42. cmake --version
  43. cmake -DPAL_PLATFORM_NAME:string=Windows -D "LY_3RDPARTY_PATH:string=%CMD_DIR%" -P "%CMD_DIR%\get_python.cmake"
  44. if ERRORLEVEL 1 (
  45. ECHO ERROR: Unable to fetch python using cmake.
  46. ECHO - Is LY_PACKAGE_SERVER_URLS set?
  47. ECHO - Do you have permission to access the packages?
  48. EXIT /b 1
  49. )
  50. :install_packages
  51. echo calling PIP to install requirements...
  52. call "%CMD_DIR%\pip.cmd" install -r "%CMD_DIR%/requirements.txt" --disable-pip-version-check --no-warn-script-location
  53. if ERRORLEVEL 1 (
  54. echo Failed to install the packages listed in %CMD_DIR%\requirements.txt. Check the log above!
  55. EXIT /b 1
  56. )
  57. call "%CMD_DIR%\pip.cmd" install -e "%CMD_DIR%/../scripts/o3de" --disable-pip-version-check --no-warn-script-location --no-deps
  58. if ERRORLEVEL 1 (
  59. echo Failed to install %CMD_DIR%\..\scripts\o3de into python. Check the log above!
  60. EXIT /b 1
  61. )
  62. exit /b 0