python.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. if [[ "$OSTYPE" == *"darwin"* ]]; then
  17. PYTHON=$DIR/runtime/python-3.10.5-rev2-darwin/Python.framework/Versions/3.10/bin/python3
  18. elif [[ "$OSTYPE" == "msys" ]]; then
  19. PYTHON=$DIR/runtime/python-3.10.5-rev1-windows/python/python.exe
  20. else
  21. LINUX_HOST_ARCHITECTURE=$( uname -m )
  22. if [[ "$LINUX_HOST_ARCHITECTURE" == "aarch64" ]]; then
  23. PYTHON=$DIR/runtime/python-3.10.5-rev4-linux-aarch64/python/bin/python
  24. elif [[ "$LINUX_HOST_ARCHITECTURE" == "x86_64" ]]; then
  25. PYTHON=$DIR/runtime/python-3.10.5-rev4-linux/python/bin/python
  26. else
  27. echo "Linux host architecture ${LINUX_HOST_ARCHITECTURE} not supported."
  28. exit 1
  29. fi
  30. fi
  31. if [[ -e "$PYTHON" ]];
  32. then
  33. PYTHONNOUSERSITE=1 "$PYTHON" "$@"
  34. exit $?
  35. fi
  36. echo "Python not found in $DIR"
  37. echo "Try running $DIR/get_python.sh first."
  38. exit 1