get_python.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/bin/bash
  2. # Copyright (c) Contributors to the Open 3D Engine Project.
  3. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. SOURCE="${BASH_SOURCE[0]}"
  8. # While $SOURCE is a symlink, resolve it
  9. while [ -h "$SOURCE" ]; do
  10. DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  11. SOURCE="$( readlink "$SOURCE" )"
  12. # If $SOURCE was a relative symlink (so no "/" as prefix, need to resolve it relative to the symlink base directory
  13. [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
  14. done
  15. DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  16. cd $DIR
  17. install_dependencies () {
  18. echo installing via pip...
  19. $DIR/pip.sh install -r $DIR/requirements.txt --disable-pip-version-check --no-warn-script-location
  20. retVal=$?
  21. if [ $retVal -ne 0 ]; then
  22. echo "Failed to install the packages listed in $DIR/requirements.txt. Check the log above!"
  23. return $retVal
  24. fi
  25. # if we're building a container app, create a package from o3de then install that to remove absolute paths to o3de scripts
  26. if [ "$O3DE_PACKAGE_TYPE" == "SNAP" ]; then
  27. pushd $DIR/../scripts/o3de/
  28. $DIR/python.sh setup.py sdist
  29. popd
  30. $DIR/pip.sh install $DIR/../scripts/o3de/dist/o3de-1.0.0.tar.gz --no-deps --disable-pip-version-check --no-cache
  31. else
  32. $DIR/pip.sh install -e $DIR/../scripts/o3de --no-deps --disable-pip-version-check --no-warn-script-location
  33. fi
  34. retVal=$?
  35. if [ $retVal -ne 0 ]; then
  36. echo "Failed to install $DIR/../scripts/o3de into python. Check the log above!"
  37. return $retVal
  38. fi
  39. }
  40. # Overall strategy: Run python with --version to see if its already there
  41. # otherwise, use cmake and the new package system to download it.
  42. # To find cmake, search the path for cmake. If not found, try a fixed known location.
  43. # the version number below is only used if cmake isn't already on your path.
  44. # if you update this version number, remember to update the one(s) in the other platform
  45. # files, as well as in scripts/build/...
  46. ./python.sh --version > /dev/null
  47. python_exitcode=$?
  48. if [ $python_exitcode == 0 ]; then
  49. echo get_python.sh: Python is already downloaded: $(./python.sh --version)
  50. install_dependencies
  51. exit $?
  52. fi
  53. if [[ "$OSTYPE" = *"darwin"* ]];
  54. then
  55. PAL=Mac
  56. CMAKE_FOLDER_RELATIVE_TO_ROOT=CMake.app/Contents/bin
  57. else
  58. PAL=Linux
  59. CMAKE_FOLDER_RELATIVE_TO_ROOT=bin
  60. fi
  61. if ! [ -x "$(command -v cmake)" ]; then
  62. if [ -z ${LY_CMAKE_PATH} ]; then
  63. echo "ERROR: Could not find cmake on the PATH and LY_CMAKE_PATH is not defined, cannot continue."
  64. echo "Please add cmake to your PATH, or define LY_CMAKE_PATH"
  65. exit 1
  66. fi
  67. export PATH=$LY_CMAKE_PATH:$PATH
  68. if ! [ -x "$(command -v cmake)" ]; then
  69. echo "ERROR: Could not find cmake on the PATH or at the known location: $LY_CMAKE_PATH"
  70. echo "Please add cmake to the environment PATH or place it at the above known location."
  71. exit 1
  72. fi
  73. fi
  74. echo Using cmake located at: $(which cmake)
  75. echo $(cmake --version)
  76. cd ..
  77. cmake -DPAL_PLATFORM_NAME:string=$PAL -DLY_3RDPARTY_PATH:string=$DIR -P $DIR/get_python.cmake
  78. retVal=$?
  79. if [ $retVal -ne 0 ]; then
  80. echo Unable to fetch python using cmake.
  81. echo - Is LY_PACKAGE_SERVER_URLS set?
  82. echo - Do you have permission to access the packages?
  83. exit $retVal
  84. fi
  85. install_dependencies
  86. exit $?