Skip to content

Commit fff2872

Browse files
committed
pushing at end of day
1 parent 00268d8 commit fff2872

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

installation_and_upgrade/ibex_install_utils/install_tasks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ def run_developer_update(self) -> None:
296296
self._system_tasks.check_java_installation()
297297
self._system_tasks.install_or_upgrade_git()
298298
self._system_tasks.update_kafka_topics()
299+
self._system_tasks.create_virtual_envs()
299300

300301
def run_vhd_creation(self) -> None:
301302
"""Automated job which creates a set of VHDs containing all IBEX components.

installation_and_upgrade/ibex_install_utils/run_process.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def __init__(
2727
expected_return_codes: Union[int, List[int], None] = [0],
2828
capture_last_output=False,
2929
progress_metric=[],
30+
env: dict | None = None
3031
):
3132
"""
3233
Create a process that needs running
@@ -45,6 +46,8 @@ def __init__(
4546
capture_last_output: Whether to record the last console output of a command while pipes are captured.
4647
progress_metric: A list that is either empty if progress is not being calculated, or contains the output to
4748
count, the 100% value, and optionally a label for printing progress
49+
env: Environment variable mapping to pass to subprocess.POpen. Passing None inherits the parent process'
50+
environment.
4851
"""
4952
self._working_dir = working_dir
5053
self._bat_file = executable_file
@@ -55,6 +58,7 @@ def __init__(
5558
self._capture_last_output = capture_last_output
5659
self.captured_output = ""
5760
self._progress_metric = progress_metric
61+
self._env = env
5862
if isinstance(expected_return_codes, int):
5963
expected_return_codes = [expected_return_codes]
6064
self._expected_return_codes = expected_return_codes
@@ -102,6 +106,7 @@ def run(self):
102106
stdout=subprocess.PIPE,
103107
stderr=subprocess.STDOUT,
104108
stdin=subprocess.PIPE,
109+
env=self._env,
105110
)
106111
output_lines, err = output.communicate(b" ")
107112
for line in output_lines.splitlines():

installation_and_upgrade/ibex_install_utils/tasks/common_paths.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
AUTOSAVE = os.path.join(VAR_DIR, "Autosave")
1313
"""Path to the autosave directory."""
1414

15+
UV = os.path.join("c:\\", "Instrument", "Apps", "uv", "uv.exe")
16+
1517
EPICS_PATH = os.path.join(APPS_BASE_DIR, "EPICS")
1618
EPICS_IOC_PATH = os.path.join(EPICS_PATH, "ioc", "master")
1719
EPICS_UTILS_PATH = os.path.join(APPS_BASE_DIR, "EPICS_UTILS")

installation_and_upgrade/ibex_install_utils/tasks/system_tasks.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from ibex_install_utils.software_dependency.java import Java
1616
from ibex_install_utils.task import task
1717
from ibex_install_utils.tasks import BaseTasks
18-
from ibex_install_utils.tasks.common_paths import APPS_BASE_DIR, EPICS_PATH, VAR_DIR
18+
from ibex_install_utils.tasks.common_paths import APPS_BASE_DIR, EPICS_PATH, VAR_DIR, UV
1919
from ibex_install_utils.version_check import version_check
2020
from win32com.client import Dispatch
2121

@@ -191,6 +191,30 @@ def update_kafka_topics(self) -> None:
191191
"""
192192
add_required_topics("livedata.isis.cclrc.ac.uk:31092", self._get_instrument_name())
193193

194+
@task("Create virtual environments for python processes")
195+
def create_virtual_envs(self):
196+
dirs_with_venvs = []
197+
for root, _, files in os.walk(EPICS_PATH):
198+
for file in files:
199+
if file == 'requirements-frozen.txt':
200+
dirs_with_venvs.append(root)
201+
202+
for directory in dirs_with_venvs:
203+
print(f"Syncing venv using uv in {directory}")
204+
venv_name = ".venv"
205+
venv = os.path.join(directory, venv_name)
206+
if os.path.exists(venv):
207+
shutil.rmtree(venv)
208+
209+
RunProcess(working_dir=os.path.join(directory),
210+
executable_file=UV,
211+
prog_args=["venv", venv_name], env={}).run()
212+
213+
RunProcess(working_dir=os.path.join(directory),
214+
executable_file=UV,
215+
prog_args=["pip", "sync", "requirements-frozen.txt"], env={}).run()
216+
217+
194218
@task("Add Nagios checks")
195219
def add_nagios_checks(self) -> None:
196220
"""

0 commit comments

Comments
 (0)