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

Prepare for execution in Python venv #85

Merged
merged 3 commits into from
Sep 4, 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
2 changes: 1 addition & 1 deletion desired_state_generator/src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
velocitas-lib==0.0.11
velocitas-lib==0.0.12
40 changes: 28 additions & 12 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,19 @@
"type": "runtime",
"programs": [
{
"id": "run-vehicledatabroker-cli",
"id": "install-deps",
"executable": "python3",
"args": [
"-m",
"pip",
"install",
"-r",
"./runtime_local/src/requirements.txt"
]
},
{
"id": "run-vehicledatabroker-cli",
"executable": "/usr/bin/python3",
"args": [
"./runtime_local/src/run-vehicledatabroker-cli.py"
],
Expand All @@ -34,17 +45,6 @@
"./runtime_local/src/runtime-down.py"
]
},
{
"id": "install-deps",
"executable": "python3",
"args": [
"-m",
"pip",
"install",
"-r",
"./runtime_local/src/requirements.txt"
]
},
{
"id": "run-vehicle-app",
"executable": "python3",
Expand Down Expand Up @@ -195,6 +195,17 @@
"alias": "kanto",
"type": "deployment",
"programs": [
{
"id": "install-deps",
"executable": "python3",
"args": [
"-m",
"pip",
"install",
"-r",
"./runtime_kanto/src/requirements.txt"
]
},
{
"id": "build-vehicleapp",
"executable": "python3",
Expand All @@ -210,6 +221,11 @@
]
}
],
"onPostInit": [
{
"ref": "install-deps"
}
],
"variables": [
{
"name": "dockerfilePath",
Expand Down
2 changes: 1 addition & 1 deletion runtime_kanto/src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
yaspin==2.3.0
velocitas-lib==0.0.11
velocitas-lib==0.0.12
2 changes: 1 addition & 1 deletion runtime_kanto/test/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ pytest==7.2.1
pytest-ordering==0.6
pytest-asyncio==0.20.3
pytest-cov==4.0.0
velocitas-lib==0.0.11
velocitas-lib==0.0.12
2 changes: 1 addition & 1 deletion runtime_local/src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
yaspin==2.3.0
velocitas-lib==0.0.11
velocitas-lib==0.0.12
34 changes: 32 additions & 2 deletions runtime_local/src/run-vehicledatabroker-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,40 @@
#
# SPDX-License-Identifier: Apache-2.0

# Workaround fix begin: Databroker CLI is not reactive if started via CLI in Python venv.
# Bug ticket: https://github.com/eclipse-velocitas/cli/issues/320
# With this fix in this file only standard libs are used avoiding the need for a venv.

# from local_lib import get_container_runtime_executable
# from velocitas_lib import require_env
import os
import subprocess

from local_lib import get_container_runtime_executable
from velocitas_lib import require_env

def require_env(name: str) -> str:
"""Require and return an environment variable.

Args:
name (str): The name of the variable.

Raises:
ValueError: In case the environment variable is not set.

Returns:
str: The value of the variable.
"""
var = os.getenv(name)
if not var:
raise ValueError(f"Environment variable {name!r} not set!")
return var


def get_container_runtime_executable() -> str:
"""Return the current container runtime executable. E.g. docker."""
return "docker"


# Workaround fix end: Databroker CLI is not reactive if started via CLI in Python venv


def run_databroker_cli():
Expand Down
2 changes: 1 addition & 1 deletion runtime_local/test/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pytest==7.2.1
pytest-cov==4.0.0
velocitas-lib==0.0.11
velocitas-lib==0.0.12
Loading