Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8437 create network independent python venv #205

Merged
merged 7 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build_tools/check_builds_are_recent.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
setlocal
call "%~dp0..\installation_and_upgrade\define_latest_genie_python.bat" 3
call "%~dp0..\installation_and_upgrade\define_latest_genie_python.bat"
set PYTHONUNBUFFERED=TRUE
REM use LATEST_PYTHON3 so not killed by stop_ibex_server
call "%LATEST_PYTHON3%" -u "%~dp0check_builds_are_recent.py"
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
10 changes: 6 additions & 4 deletions build_tools/purge_archive.bat
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
setlocal EnableDelayedExpansion
REM Remove old builds from the archive
call "%~dp0..\installation_and_upgrade\define_latest_genie_python.bat" 3

if not "%WORKSPACE%" == "" (
if exist "%WORKSPACE%\Python3" rd /s /q %WORKSPACE%\Python3
call %LATEST_PYTHON_DIR%..\genie_python_install.bat %WORKSPACE%\Python3
if !errorlevel! neq 0 exit /b 1
set "LATEST_PYTHON3=%WORKSPACE%\Python3\python3.exe"
)

call "%~dp0..\installation_and_upgrade\define_latest_genie_python.bat" %WORKSPACE%\Python3

set PYTHONUNBUFFERED=TRUE
REM use LATEST_PYTHON3 to avoid process being killed
REM use LATEST_PYTHON3 to avoid process being killed
"%LATEST_PYTHON3%" -u "%~dp0purge_archive.py"
set errcode=!errorlevel!
@echo purge_archive.py exited with code !errcode!
for /F "skip=1" %%I in ('wmic path win32_localtime get dayofweek') do (set /a DOW=%%I 2>NUL)
if %DOW% neq 6 (
@echo Skipping debug symbol cleanup as day of week %DOW% is not 6
CALL "%~dp0..\installation_and_upgrade\remove_genie_python.bat" %LATEST_PYTHON_DIR%
exit /b !errcode!
)
REM Remove old debug symbols from the archive
Expand All @@ -33,3 +33,5 @@ if exist "%AGESTORE%" (
) else (
@echo agestore does not exist
)

CALL "%~dp0..\installation_and_upgrade\remove_genie_python.bat" %LATEST_PYTHON_DIR%
41 changes: 32 additions & 9 deletions installation_and_upgrade/define_latest_genie_python.bat
Original file line number Diff line number Diff line change
@@ -1,24 +1,47 @@
@echo off
REM Get latest python build and kits icp path
REM KITS_ICP_PATH is set to ICP directory
REM LATEST_PYTHON is set to a version on genie_python that can be run
REM KITS_ICP_PATH is set to ICP directory
REM LATEST_PYTHON is set to a version on genie_python that can be run

REM Fetch newest python build from \\isis\inst$\Kits$\CompGroup\ICP\genie_python_3
REM Use genie_python_install to install it into a temporary directory
REM Need to make sure that after every use of this bat that these variables are undefined and the temp dir is removed


set "KITS_ICP_PATH=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP"
set "genie_dir=%KITS_ICP_PATH%\genie_python_3"
set "latest_build_file=%genie_dir%\LATEST_BUILD.txt"

set "GENIE_DIR=%KITS_ICP_PATH%\genie_python_3"
set "PYTHON_BUILD_NO="

if exist "%GENIE_DIR%\LATEST_BUILD.txt" (
for /f %%i in ( %GENIE_DIR%\LATEST_BUILD.txt ) do (
set LATEST_PYTHON_DIR=%GENIE_DIR%\BUILD-%%i\Python\
set LATEST_PYTHON=%GENIE_DIR%\BUILD-%%i\Python\python.exe
set LATEST_PYTHON3=%GENIE_DIR%\BUILD-%%i\Python\python3.exe
if exist "%genie_dir%\LATEST_BUILD.txt" (
for /f %%i in ( %genie_dir%\LATEST_BUILD.txt ) do (
set PYTHON_BUILD_NO=%%i
)
) else (
@echo Could not access LATEST_BUILD.txt
goto ERROR
)

@echo LATEST PYTHON: %LATEST_PYTHON%
if "%PYTHON_BUILD_NO%" == "" (
@echo invalid LATEST_BUILD.txt
goto ERROR
)

if "%~1" NEQ "" (
set "LATEST_PYTHON_DIR=%~1\Python_Build_%PYTHON_BUILD_NO%"
) else (
set "LATEST_PYTHON_DIR=%tmp%\Python_Build_%PYTHON_BUILD_NO%"
)

mkdir %LATEST_PYTHON_DIR%

%genie_dir%\BUILD-%PYTHON_BUILD_NO%\genie_python_install.bat %LATEST_PYTHON_DIR%

set "LATEST_PYTHON=%LATEST_PYTHON_DIR%\python.exe"
set "LATEST_PYTHON3=%LATEST_PYTHON_DIR%\python3.exe"

rem @echo LATEST PYTHON: %LATEST_PYTHON%

exit /b 0

Expand Down
11 changes: 8 additions & 3 deletions installation_and_upgrade/developer_update.bat
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
setlocal
setlocal EnableDelayedExpansion
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0\define_latest_genie_python.bat"
call "%~dp0define_latest_genie_python.bat"

set "STOP_IBEX=C:\Instrument\Apps\EPICS\stop_ibex_server"
set "START_IBEX=C:\Instrument\Apps\EPICS\start_ibex_server"

start /wait cmd /c "%STOP_IBEX%"

call "%LATEST_PYTHON%" "%~dp0IBEX_upgrade.py" --release_dir "%SOURCE%" --release_suffix "%SUFFIX%" --confirm_step developer_update
IF ERRORLEVEL 1 EXIT /b %errorlevel%
IF ERRORLEVEL 1 (
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
)

start /wait cmd /c "%START_IBEX%"
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
7 changes: 6 additions & 1 deletion installation_and_upgrade/instrument_deploy.bat
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ REM Set python as share just for script call
call "%~dp0define_latest_genie_python.bat"
IF %errorlevel% neq 0 exit /b %errorlevel%
if not exist "%LATEST_PYTHON%" (
@echo Cannot find python on network share
@echo Cannot install python from network share
goto ERROR
)

Expand All @@ -102,5 +102,10 @@ set "PYTHONHOME=%LATEST_PYTHON_DIR%"
set "PYTHONPATH=%LATEST_PYTHON_DIR%"

call "%LATEST_PYTHON%" "%~dp0IBEX_upgrade.py" --release_dir "%SOURCE%" --release_suffix "%SUFFIX%" --server_arch %SERVER_ARCH% --confirm_step instrument_deploy_post_start
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%

exit /b 0

:ERROR
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b 1
18 changes: 13 additions & 5 deletions installation_and_upgrade/instrument_install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ setlocal

REM check if console has Administrative privileges
call "%~dp0check_for_admin_console.bat"
IF %errorlevel% neq 0 EXIT /b %errorlevel%
if %errorlevel% neq 0 goto ERROR

set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0\define_latest_genie_python.bat"
IF %errorlevel% neq 0 EXIT /b %errorlevel%
call "%~dp0define_latest_genie_python.bat"
if %errorlevel% neq 0 goto ERROR

set SERVER_ARCH=x64
if not "%1" == "" set SERVER_ARCH=%1
Expand All @@ -24,7 +24,7 @@ if not exist "%SOURCE%" (
git --version
IF %errorlevel% neq 0 (
echo No installation of Git found on machine. Please download Git from https://git-scm.com/downloads before proceeding.
EXIT /b %errorlevel%
goto ERROR
)

set "STOP_IBEX=C:\Instrument\Apps\EPICS\stop_ibex_server"
Expand All @@ -38,7 +38,15 @@ set "PYTHONHOME=%LATEST_PYTHON_DIR%"
set "PYTHONPATH=%LATEST_PYTHON_DIR%"

call "%LATEST_PYTHON%" "%~dp0IBEX_upgrade.py" --release_dir "%SOURCE%" --release_suffix "%SUFFIX%" --server_arch %SERVER_ARCH% --confirm_step instrument_install
IF %errorlevel% neq 0 EXIT /b %errorlevel%
if %errorlevel% neq 0 goto ERROR
ENDLOCAL

start /wait cmd /c "%START_IBEX%"

call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
exit /b 0

:ERROR
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ setlocal EnableDelayedExpansion

set PYTHONUNBUFFERED=TRUE

call "%~dp0\define_latest_genie_python.bat"
call "%~dp0define_latest_genie_python.bat"
IF %errorlevel% neq 0 (
@echo Failed to define genie python
GOTO ERROR
Expand Down Expand Up @@ -81,8 +81,10 @@ IF %errorlevel% neq 0 (
GOTO ERROR
)

call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
GOTO :EOF

:ERROR
echo Error on Install
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
exit /b 2
12 changes: 10 additions & 2 deletions installation_and_upgrade/instrument_save_settings.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
setlocal
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0define_latest_genie_python.bat"
IF %errorlevel% neq 0 EXIT /b %errorlevel%
if %errorlevel% neq 0 goto ERROR
call C:\Instrument\Apps\EPICS\config_env.bat
set "PYTHONDIR=%LATEST_PYTHON_DIR%"
set "PYTHONHOME=%LATEST_PYTHON_DIR%"
Expand All @@ -11,4 +11,12 @@ set "PYTHONPATH=%LATEST_PYTHON_DIR%"
@echo *** IBEX should still be running at this point
@echo.
call "%LATEST_PYTHON%" -u "%~dp0IBEX_upgrade.py" --release_dir "%SOURCE%" --confirm_step instrument_deploy_pre_stop
IF %errorlevel% neq 0 EXIT /b %errorlevel%
if %errorlevel% neq 0 goto ERROR

call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
exit /b 0

:ERROR
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
14 changes: 11 additions & 3 deletions installation_and_upgrade/instrument_test.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0\define_latest_genie_python.bat"
IF %errorlevel% neq 0 EXIT /b %errorlevel%
call "%~dp0define_latest_genie_python.bat"
if %errorlevel% neq 0 goto ERROR

call "%LATEST_PYTHON%" "%~dp0IBEX_upgrade.py" --release_dir "%SOURCE%" --confirm_step instrument_test
IF %errorlevel% neq 0 EXIT /b %errorlevel%
if %errorlevel% neq 0 goto ERROR

call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
exit /b 0

:ERROR
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
15 changes: 11 additions & 4 deletions installation_and_upgrade/instrument_update.bat
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
setlocal
call "%~dp0\define_latest_genie_python.bat"
if %errorlevel% neq 0 exit /b %errorlevel%
call "%~dp0define_latest_genie_python.bat"
if %errorlevel% neq 0 goto ERROR
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases\4.0.0"

set "STOP_IBEX=C:\Instrument\Apps\EPICS\stop_ibex_server"
set "START_IBEX=C:\Instrument\Apps\EPICS\start_ibex_server"
IF EXIST "C:\Instrument\Apps\EPICS" (start /wait cmd /c "%STOP_IBEX%")

call "%LATEST_PYTHON%" "%~dp0IBEX_upgrade.py" --release_dir "%SOURCE%" --confirm_step instrument_update
if %errorlevel% neq 0 exit /b %errorlevel%

if %errorlevel% neq 0 goto ERROR
start /wait cmd /c "%START_IBEX%"

call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
exit /b 0

:ERROR
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
30 changes: 30 additions & 0 deletions installation_and_upgrade/remove_genie_python.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@echo off

if "%~1"=="" (
@echo No path provided as the first parameter.
goto ERROR
)

set substring=Python_Build_
set path=%~1
set modified_path=%path:%substring%=%

if "%path%" neq "%modified_path%" (

RMDIR /S /Q %path%

set LATEST_PYTHON_DIR=
set LATEST_PYTHON=
set LATEST_PYTHON3=

) else (
@echo Could not find the specified path: %path%.
goto ERROR
)

@echo Successfully removed %path% and unset genie build variables.
exit /b 0

:ERROR
@echo remove_genie_python failed
exit /b 1
3 changes: 2 additions & 1 deletion installation_and_upgrade/run_standalone_backup.bat
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
@ECHO OFF
setlocal
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0\define_latest_genie_python.bat"
call "%~dp0define_latest_genie_python.bat"
call cd "%~dp0"
set PYTHONPATH=.
@REM Uses Python from the Shares, set as LATEST_PYTHON
call "%LATEST_PYTHON%" "%~dp0ibex_install_utils\tasks\backup_tasks.py"
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
endlocal
17 changes: 13 additions & 4 deletions installation_and_upgrade/save_motor_params.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
setlocal
setlocal EnableDelayedExpansion
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0\define_latest_genie_python.bat"
IF %errorlevel% neq 0 EXIT /b %errorlevel%
call "%~dp0define_latest_genie_python.bat"
IF %errorlevel% neq 0 goto ERROR

call "%LATEST_PYTHON%" "%~dp0IBEX_upgrade.py" --release_dir "%SOURCE%" --confirm_step save_motor_params
IF %errorlevel% neq 0 EXIT /b %errorlevel%

IF %errorlevel% neq 0 goto ERROR

call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
exit /b 0

:ERROR
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
17 changes: 13 additions & 4 deletions installation_and_upgrade/truncate_database.bat
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
setlocal EnableDelayedExpansion
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0\define_latest_genie_python.bat"
IF %errorlevel% neq 0 EXIT /b %errorlevel%
call "%~dp0define_latest_genie_python.bat"
IF %errorlevel% neq 0 goto ERROR

git --version

IF %errorlevel% neq 0 (
echo No installation of Git found on machine. Please download Git from https://git-scm.com/downloads before proceeding.
EXIT /b %errorlevel%
goto ERROR
)

call "%LATEST_PYTHON%" "%~dp0IBEX_upgrade.py" --release_dir "%SOURCE%" --release_suffix "%SUFFIX%" --confirm_step truncate_database
IF %errorlevel% neq 0 EXIT /b %errorlevel%
IF %errorlevel% neq 0 goto ERROR
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%

exit /b 0

:ERROR
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
10 changes: 8 additions & 2 deletions installation_and_upgrade/upgrade_mysql.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
setlocal
setlocal EnableDelayedExpansion
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0define_latest_genie_python.bat"

Expand All @@ -8,6 +8,12 @@ set "START_IBEX=C:\Instrument\Apps\EPICS\start_ibex_server"
start /wait cmd /c "%STOP_IBEX%"

call "%LATEST_PYTHON%" -u "%~dp0IBEX_upgrade.py" --release_dir "%SOURCE%" --release_suffix "%SUFFIX%" --confirm_step force_upgrade_mysql
IF %errorlevel% neq 0 EXIT /b %errorlevel%

IF %errorlevel% neq 0 (
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
)

start /wait cmd /c "%START_IBEX%"
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
11 changes: 9 additions & 2 deletions installation_and_upgrade/vhd_build.bat
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
setlocal EnableDelayedExpansion
set PYTHONUNBUFFERED=1
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0\define_latest_genie_python.bat"
call "%~dp0define_latest_genie_python.bat"

IF EXIST "C:\Instrument\Apps\EPICS\stop_ibex_server.bat" (
start /wait cmd /c "C:\Instrument\Apps\EPICS\stop_ibex_server.bat"
)

call "%LATEST_PYTHON%" "%~dp0IBEX_upgrade.py" --kits_icp_dir "%KITS_ICP_PATH%" create_vhds --quiet --no_log_to_var
IF %ERRORLEVEL% NEQ 0 EXIT /b %errorlevel%
IF %ERRORLEVEL% NEQ 0 (
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
)

call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
Loading