Skip to content

Commit

Permalink
Update gui_setup.bat&sh: Check available Python version
Browse files Browse the repository at this point in the history
  • Loading branch information
niklases committed Oct 30, 2024
1 parent 41ba230 commit 4d8a0b8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
32 changes: 31 additions & 1 deletion gui_setup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,37 @@ echo Installing PyPEF...
set "python_exe=python"
set "prefix="

set /P AREYOUSURE=Install and use local Python version (Y/[N]) (downloads Python installer and installs Python locally in the current working directory)?
for /F "delims=" %%i in ('powershell python --version') do set py_ver=%%i
if not "%py_ver:~0,6%"=="Python" (
set "true=0"
) else (
set "true=0"
if "%py_ver:~7,5%"=="3.12." (
echo Found Python version 3.12.
set "true=1"
)
if "%py_ver:~7,5%"=="3.11." (
echo Found Python version 3.11.
set "true=1"
)
if "%py_ver:~7,5%"=="3.10." (
echo Found Python version 3.10.
set "true=1"
)
if "%py_ver:~7,4%"=="3.9." (
echo Found Python version 3.9.
set "true=1"
)
)

if "%true%"=="0" (
echo Did not find any Python version. Python will be installed locally in the next step...
set /P AREYOUSURE="Y"
) else (
echo A suitable Python version was found, no local download and Python installtion should be necessary...
set /P AREYOUSURE="Install and use local Python version (Y/[N]) (downloads Python installer and installs Python locally in the current working directory)? "
)

if /I "%AREYOUSURE%" NEQ "Y" if /I "%AREYOUSURE%" NEQ "y" goto NO_PYTHON

echo Installing Python...
Expand Down
9 changes: 8 additions & 1 deletion gui_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ set -e
# Only required for WSL(?):
# sudo apt-get install -y libxcb-cursor-dev

py_ver="$(python --version)"

if [[ $py_ver == *"3.12."* ]] || [[ $py_ver == *"3.11."* ]] || [[ $py_ver == *"3.10."* ]] || [[ $py_ver == *"3.9."* ]]; then
echo "Identified Python version should be suitable for installing and running PyPEF..."
else
echo >&2 "The identified Python version ($py_ver) does not match the required Python versions... you should activate/install a suitable version first, e.g. Python 3.12."; exit 1
fi
python -m pip install -U pypef pyside6

printf "
Expand All @@ -25,4 +32,4 @@ echo "+++ run_pypef_gui.sh +++"
echo "+++ for future GUI starting +++"

chmod a+x ./run_pypef_gui.sh
./run_pypef_gui.sh && exit
./run_pypef_gui.sh && exit 0

0 comments on commit 4d8a0b8

Please sign in to comment.