Linux Python virtual environment updates

This commit is contained in:
Dan Paulat 2025-05-28 23:15:17 -05:00
parent ea2c2e8f58
commit 9ce411d85b
6 changed files with 42 additions and 3 deletions

View file

@ -1,6 +1,16 @@
#!/bin/bash
script_dir="$(dirname "$(readlink -f "$0")")"
# Assign user-specified Python Virtual Environment
[ "${1:-}" = "none" ] && unset venv_path || export venv_path="$(readlink -f "${1:-${script_dir}/../.venv}")"
# Activate Python Virtual Environment
if [ -n "${venv_path:-}" ]; then
python -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))')
if [ "${IN_VENV}" = "True" ]; then
@ -12,6 +22,7 @@ else
fi
# Install Python packages
python -m pip install ${PIP_FLAGS} --upgrade pip
pip install ${PIP_FLAGS} -r "${script_dir}/../requirements.txt"
# Configure default Conan profile
@ -37,3 +48,8 @@ conan_profiles=(
for profile_name in "${conan_profiles[@]}"; do
conan config install "${script_dir}/conan/profiles/${profile_name}" -tf profiles
done
# Deactivate Python Virtual Environment
if [ -n "${venv_path:-}" ]; then
deactivate
fi

View file

@ -9,6 +9,7 @@ cmake_args=(
-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES="${script_dir}/../../external/cmake-conan/conan_provider.cmake"
-DCONAN_HOST_PROFILE="${conan_profile}"
-DCONAN_BUILD_PROFILE="${conan_profile}"
-DSCWX_VIRTUAL_ENV="${venv_path}"
)
if [[ -n "${build_type}" ]]; then

View file

@ -4,6 +4,13 @@ script_dir="$(dirname "$(readlink -f "$0")")"
# Import common paths
source ${script_dir}/common-paths.sh
# Activate Python Virtual Environment
if [ -n "${venv_path:-}" ]; then
python -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))')
if [ "${IN_VENV}" = "True" ]; then
@ -15,6 +22,7 @@ else
fi
# Install Python packages
python -m pip install ${PIP_FLAGS} pip
pip install ${PIP_FLAGS} -r ${script_dir}/../../requirements.txt
if [[ -n "${build_type}" ]]; then
@ -35,3 +43,8 @@ fi
# Run CMake Configure
${script_dir}/run-cmake-configure.sh
# Deactivate Python Virtual Environment
if [ -n "${venv_path:-}" ]; then
deactivate
fi

View file

@ -1,12 +1,15 @@
#!/bin/bash
script_dir="$(dirname "$(readlink -f "$0")")"
export build_dir="${1:-${script_dir}/../build-debug}"
export build_dir="$(readlink -f "${1:-${script_dir}/../build-debug}")"
export build_type=Debug
export conan_profile=${2:-scwx-linux_gcc-11}
export generator=Ninja
export qt_base=/opt/Qt
export qt_arch=gcc_64
# Assign user-specified Python Virtual Environment
[ "${3:-}" = "none" ] && unset venv_path || export venv_path="$(readlink -f "${3:-${script_dir}/../.venv}")"
# Perform common setup
${script_dir}/lib/setup-common.sh

View file

@ -1,12 +1,15 @@
#!/bin/bash
script_dir="$(dirname "$(readlink -f "$0")")"
export build_dir="${1:-${script_dir}/../build}"
export build_dir="$(readlink -f "${1:-${script_dir}/../build-debug}")"
export conan_profile=${2:-scwx-linux_gcc-11}
export generator="Ninja Multi-Config"
export qt_base=/opt/Qt
export qt_arch=gcc_64
# Assign user-specified Python Virtual Environment
[ "${3:-}" = "none" ] && unset venv_path || export venv_path="$(readlink -f "${3:-${script_dir}/../.venv}")"
# FIXME: aws-sdk-cpp fails to configure using Ninja Multi-Config
echo "Ninja Multi-Config is not supported in Linux"
read -p "Press Enter to continue..."

View file

@ -1,12 +1,15 @@
#!/bin/bash
script_dir="$(dirname "$(readlink -f "$0")")"
export build_dir="${1:-${script_dir}/../build-release}"
export build_dir="$(readlink -f "${1:-${script_dir}/../build-debug}")"
export build_type=Release
export conan_profile=${2:-scwx-linux_gcc-11}
export generator=Ninja
export qt_base=/opt/Qt
export qt_arch=gcc_64
# Assign user-specified Python Virtual Environment
[ "${3:-}" = "none" ] && unset venv_path || export venv_path="$(readlink -f "${3:-${script_dir}/../.venv}")"
# Perform common setup
${script_dir}/lib/setup-common.sh