diff --git a/tools/configure-environment.sh b/tools/configure-environment.sh index 0da64217..bc844493 100755 --- a/tools/configure-environment.sh +++ b/tools/configure-environment.sh @@ -1,8 +1,19 @@ #!/bin/bash -script_dir="$(dirname "$(readlink -f "$0")")" +script_source="${BASH_SOURCE[0]:-$0}" +script_dir="$(cd "$(dirname "${script_source}")" && pwd)" # Assign user-specified Python Virtual Environment -[ "${1:-}" = "none" ] && unset venv_path || export venv_path="$(readlink -f "${1:-${script_dir}/../.venv}")" +if [ "${1:-}" = "none" ]; then + unset venv_path +else + venv_arg="${1:-${script_dir}/../.venv}" + # Portable way to get absolute path without requiring the directory to exist + case "${venv_arg}" in + /*) venv_path="${venv_arg}" ;; + *) venv_path="$(cd "$(dirname "${venv_arg}")" && pwd)/$(basename "${venv_arg}")" ;; + esac + export venv_path +fi # Load custom build settings if [ -f "${script_dir}/lib/user-setup.sh" ]; then @@ -11,12 +22,12 @@ fi # Activate Python Virtual Environment if [ -n "${venv_path:-}" ]; then - python -m venv "${venv_path}" + python3 -m venv "${venv_path}" source "${venv_path}/bin/activate" fi # Detect if a Python Virtual Environment was specified above, or elsewhere -IN_VENV=$(python -c 'import sys; print(sys.prefix != getattr(sys, "base_prefix", sys.prefix))') +IN_VENV=$(python3 -c 'import sys; print(sys.prefix != getattr(sys, "base_prefix", sys.prefix))') if [ "${IN_VENV}" = "True" ]; then # In a virtual environment, don't use --user @@ -27,8 +38,8 @@ else fi # Install Python packages -python -m pip install ${PIP_FLAGS} --upgrade pip -pip install ${PIP_FLAGS} -r "${script_dir}/../requirements.txt" +python3 -m pip install ${PIP_FLAGS} --upgrade pip +python3 -m pip install ${PIP_FLAGS} -r "${script_dir}/../requirements.txt" # Configure default Conan profile conan profile detect -e diff --git a/tools/lib/run-cmake-configure.sh b/tools/lib/run-cmake-configure.sh index 5e1a3bbf..03bbcdb1 100755 --- a/tools/lib/run-cmake-configure.sh +++ b/tools/lib/run-cmake-configure.sh @@ -1,5 +1,6 @@ #!/bin/bash -script_dir="$(dirname "$(readlink -f "$0")")" +script_source="${BASH_SOURCE[0]:-$0}" +script_dir="$(cd "$(dirname "${script_source}")" && pwd)" cmake_args=( -B "${build_dir}" diff --git a/tools/lib/setup-common.sh b/tools/lib/setup-common.sh index e28978e9..b11270e8 100755 --- a/tools/lib/setup-common.sh +++ b/tools/lib/setup-common.sh @@ -1,5 +1,6 @@ #!/bin/bash -script_dir="$(dirname "$(readlink -f "$0")")" +script_source="${BASH_SOURCE[0]:-$0}" +script_dir="$(cd "$(dirname "${script_source}")" && pwd)" # Import common paths source "${script_dir}/common-paths.sh" @@ -9,14 +10,14 @@ if [ -f "${script_dir}/user-setup.sh" ]; then source "${script_dir}/user-setup.sh" fi -# Activate Python Virtual Environment +# Activate python3 Virtual Environment if [ -n "${venv_path:-}" ]; then - python -m venv "${venv_path}" + python3 -m venv "${venv_path}" source "${venv_path}/bin/activate" fi -# Detect if a Python Virtual Environment was specified above, or elsewhere -IN_VENV=$(python -c 'import sys; print(sys.prefix != getattr(sys, "base_prefix", sys.prefix))') +# Detect if a python3 Virtual Environment was specified above, or elsewhere +IN_VENV=$(python3 -c 'import sys; print(sys.prefix != getattr(sys, "base_prefix", sys.prefix))') if [ "${IN_VENV}" = "True" ]; then # In a virtual environment, don't use --user @@ -26,9 +27,9 @@ else PIP_FLAGS="--upgrade --user" fi -# Install Python packages -python -m pip install ${PIP_FLAGS} pip -pip install ${PIP_FLAGS} -r "${script_dir}/../../requirements.txt" +# Install python3 packages +python3 -m pip install ${PIP_FLAGS} pip +python3 -m pip install ${PIP_FLAGS} -r "${script_dir}/../../requirements.txt" if [[ -n "${build_type}" ]]; then # Install Conan profile and packages @@ -49,7 +50,7 @@ fi # Run CMake Configure "${script_dir}/run-cmake-configure.sh" -# Deactivate Python Virtual Environment +# Deactivate python3 Virtual Environment if [ -n "${venv_path:-}" ]; then deactivate fi diff --git a/tools/lib/setup-conan.sh b/tools/lib/setup-conan.sh index 2ac38ee7..0b6c5004 100755 --- a/tools/lib/setup-conan.sh +++ b/tools/lib/setup-conan.sh @@ -1,5 +1,6 @@ #!/bin/bash -script_dir="$(dirname "$(readlink -f "$0")")" +script_source="${BASH_SOURCE[0]:-$0}" +script_dir="$(cd "$(dirname "${script_source}")" && pwd)" # Configure default Conan profile conan profile detect -e