o3de.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/bash
  2. #
  3. # Copyright (c) Contributors to the Open 3D Engine Project.
  4. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. #
  6. # SPDX-License-Identifier: Apache-2.0 OR MIT
  7. #
  8. #
  9. # This script must search for the o3de python script in a sibling python
  10. # directory. In order to do this, it needs to de-symlink itself to find out
  11. # where it is truly located. (deb installers symlink it to a bin folder).
  12. SOURCE="${BASH_SOURCE[0]}"
  13. # While $SOURCE is a symlink, resolve it
  14. while [[ -h "$SOURCE" ]]; do
  15. DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  16. SOURCE="$( readlink "$SOURCE" )"
  17. # If $SOURCE was a relative symlink (so no "/" as prefix, need to resolve it relative to the symlink base directory
  18. [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
  19. done
  20. SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  21. #python should be in the base path
  22. BASE_PATH=$(dirname "$SCRIPT_DIR")
  23. PYTHON_DIRECTORY="$BASE_PATH/python"
  24. #If engine python exists use it, if not try the system python
  25. if [ ! -d "$PYTHON_DIRECTORY" ]; then
  26. PYTHON_EXECUTABLE="python"
  27. else
  28. PYTHON_EXECUTABLE="$PYTHON_DIRECTORY/python.sh"
  29. fi
  30. if [ ! -f "$PYTHON_EXECUTABLE" ]; then
  31. echo "Python executable not found: $PYTHON_EXECUTABLE"
  32. exit 1
  33. fi
  34. #run the o3de.py pass along the command
  35. $PYTHON_EXECUTABLE "$SCRIPT_DIR/o3de.py" $*
  36. exit $?