Skip to content
Draft
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
408 changes: 326 additions & 82 deletions .hooks/pre-push

Large diffs are not rendered by default.

22 changes: 20 additions & 2 deletions core/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ ENV PATH="/root/.local/bin/:$PATH"
# Project files
COPY ./uv.lock /home/pi/uv.lock
COPY ./pyproject.toml /home/pi/pyproject.toml
COPY ./python-venv2 /home/pi/python-venv2
COPY ./.python-version /home/pi/.python-version
COPY ./.python-version /home/pi/python-venv2/.python-version

COPY ./libs /home/pi/libs
COPY ./services /home/pi/services
Expand All @@ -54,9 +56,22 @@ COPY ./tools /home/pi/tools
WORKDIR /home/pi
RUN uv venv && uv sync --frozen --no-default-groups

WORKDIR /home/pi/python-venv2
RUN <<-EOF
set -e

uv venv /home/pi/.venv2
. /home/pi/.venv2/bin/activate
uv sync --frozen --no-default-groups --active

EOF

# Post install scripts
RUN BLUEOS_PYTHON_ENVS="/home/pi/.venv /home/pi/.venv2" /home/pi/tools/install-python-libs.sh

# Reset default workdir
WORKDIR /home/pi
ENV VIRTUAL_ENV=/home/pi/.venv
RUN /home/pi/tools/install-python-libs.sh

# BlueOS base image
FROM base
Expand Down Expand Up @@ -120,6 +135,7 @@ COPY --from=download-binaries \
# Copy frontend built on frontend-builder to this stage
COPY --from=frontend-builder /home/pi/frontend/dist /home/pi/frontend
COPY --from=install-services-and-libs /home/pi/.venv /usr/blueos/venv
COPY --from=install-services-and-libs /home/pi/.venv2 /usr/blueos/venv2

RUN <<-EOF
set -e
Expand All @@ -134,7 +150,9 @@ set -e
RCFILE_PATH="/etc/blueosrc"
echo "export GIT_DESCRIBE_TAGS=$GIT_DESCRIBE_TAGS" >> $RCFILE_PATH
echo "export HISTFILE=/etc/blueos/.bash_history" >> $RCFILE_PATH
echo "export PATH=/usr/blueos/venv/bin:/usr/blueos/bin:$PATH" >> $RCFILE_PATH
echo "export BLUEOS_VENV_PRIMARY=/usr/blueos/venv" >> $RCFILE_PATH
echo "export BLUEOS_VENV_SECONDARY=/usr/blueos/venv2" >> $RCFILE_PATH
echo "export PATH=/usr/blueos/venv/bin:/usr/blueos/venv2/bin:/usr/blueos/bin:$PATH" >> $RCFILE_PATH
echo "export RUST_BACKTRACE=1" >> $RCFILE_PATH

# Setup shortcuts
Expand Down
1 change: 0 additions & 1 deletion core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ dependencies = [
"nmea_injector",
"pardal",
"ping",
"versionchooser",
"wifi",
]

Expand Down
19 changes: 19 additions & 0 deletions core/python-venv2/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[project]
name = "blueos-core-venv2"
version = "1.4.0"
description = "Runtime workspace for BlueOS services that require newer dependencies."
requires-python = ">=3.11"
dependencies = [
"commonwealth",
"versionchooser",
]

[tool.uv.sources]
commonwealth = { workspace = true }
versionchooser = { workspace = true }

[tool.uv.workspace]
members = [
"../libs/commonwealth",
"../services/versionchooser",
]
693 changes: 693 additions & 0 deletions core/python-venv2/uv.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions core/services/versionchooser/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies = [
"docker==6.0.0",
"loguru==0.5.3",
"uvicorn==0.18.0",
"python-multipart==0.0.5",
# This dependency needs to be locked due to error in aiohttp
"yarl==1.12.1",
]
Expand Down
8 changes: 6 additions & 2 deletions core/start-blueos-core
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ echo "BlueOS ${GIT_DESCRIBE_TAGS}"
BLUEOS_PATH=/home/pi
SERVICES_PATH=$BLUEOS_PATH/services
TOOLS_PATH=$BLUEOS_PATH/tools
BLUEOS_VENV_PRIMARY=${BLUEOS_VENV_PRIMARY:-/usr/blueos/venv}
BLUEOS_VENV_SECONDARY=${BLUEOS_VENV_SECONDARY:-/usr/blueos/venv2}
BLUEOS_PYTHON_BIN_PRIMARY="$BLUEOS_VENV_PRIMARY/bin/python3"
BLUEOS_PYTHON_BIN_SECONDARY="$BLUEOS_VENV_SECONDARY/bin/python3"

# MAVLink configuration
MAV_SYSTEM_ID=${MAV_SYSTEM_ID:-1}
Expand Down Expand Up @@ -114,7 +118,7 @@ PRIORITY_SERVICES=(

SERVICES=(
# This services are not prioritized because they are not fundamental for the vehicle to work
'kraken',0,"nice -19 $SERVICES_PATH/kraken/main.py"
'kraken',0,"nice -19 $BLUEOS_PYTHON_BIN_PRIMARY $SERVICES_PATH/kraken/main.py"
'wifi',0,"nice -19 $SERVICES_PATH/wifi/main.py --socket wlan0"
'zenohd',0,"ZENOH_BACKEND_FS_ROOT=$TOOLS_PATH/zenoh zenohd -c $TOOLS_PATH/zenoh/blueos-zenoh.json5"
# This services are not as important as the others
Expand All @@ -126,7 +130,7 @@ SERVICES=(
'iperf3',250," iperf3 --server --port 5201"
'linux2rest',250,"linux2rest --log-settings netstat=30,platform=10,serial-ports=10,cpu=10,disk=30,info=10,memory=10,network=10,process=60,temperature=10,unix-time-seconds=10"
'filebrowser',250,"nice -19 filebrowser --database /etc/filebrowser/filebrowser.db --baseurl /file-browser"
'versionchooser',0,"$SERVICES_PATH/versionchooser/main.py"
'versionchooser',0,"$BLUEOS_PYTHON_BIN_SECONDARY $SERVICES_PATH/versionchooser/main.py"
'pardal',250,"nice -19 $SERVICES_PATH/pardal/main.py"
'ping',0,"nice -19 $RUN_AS_REGULAR_USER_BEGIN $SERVICES_PATH/ping/main.py $RUN_AS_REGULAR_USER_END"
'user_terminal',0,"cat /etc/motd"
Expand Down
30 changes: 29 additions & 1 deletion core/tools/install-python-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,32 @@ TOOLS=(
ardupilot_tools
)

parallel --halt now,fail=1 '/home/pi/tools/{}/setup-python-libs.sh' ::: "${TOOLS[@]}"
determine_target_envs() {
if [ -n "$BLUEOS_PYTHON_ENVS" ]; then
read -r -a TARGET_ENVS <<< "$BLUEOS_PYTHON_ENVS"
elif [ -n "$VIRTUAL_ENV" ]; then
TARGET_ENVS=("$VIRTUAL_ENV")
else
TARGET_ENVS=("")
fi
}

install_for_env() {
local target_env="$1"

if [ -n "$target_env" ]; then
export VIRTUAL_ENV="$target_env"
echo "Installing python tools for virtualenv: $target_env"
else
unset VIRTUAL_ENV
echo "Installing python tools for system python"
fi

parallel --halt now,fail=1 '/home/pi/tools/{}/setup-python-libs.sh' ::: "${TOOLS[@]}"
}

determine_target_envs

for env_path in "${TARGET_ENVS[@]}"; do
install_for_env "$env_path"
done
56 changes: 54 additions & 2 deletions core/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.