From 656108ffd40419433372f91c5280e2a919a1bae3 Mon Sep 17 00:00:00 2001 From: Joseph Date: Sat, 18 Jan 2025 19:49:34 +0300 Subject: [PATCH] fix: update version number outputting build: update docker image configuration build: update uv installation into docker image build: attempt fixing uv installation build: add uv to path in docker image build: try fixing PATH update in docker image build: merge docker run instructions --- Dockerfile | 20 +++++++++----------- builder/__main__.py | 14 +++++++++++++- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index c5dcd73..b3418b5 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.12-slim-bookworm AS base +FROM debian:bookworm-slim AS base # variable store ARG WDIR=/zero_build @@ -29,20 +29,18 @@ RUN \ bison \ flex -# configure Python environment -RUN python3 -m pip install pip --upgrade && \ - python3 -m pip install -r requirement-uv.txt && \ - uv sync --frozen --no-install-project - -# install shared tools from tools.json; +# install UV, .venv and shared tools; # -# The idea here is that we pre-pack all the tools into the Docker/Podman image that can be used for any device: +# The main idea here is that we pre-pack all the tools into the Docker/Podman image that can be used for any device: # (toolchains, binutils -- everything except device-specific kernel source); # # This significantly reduces the total build time, as each time we make a build call for a device, # only device-specific kernel source is being downloaded into the container. # -RUN uv run ${WDIR}/builder/utils/bridge.py --shared +RUN curl -LsSf https://astral.sh/uv/$(cat ./requirement-uv.txt | awk -F'==' '{print $2}' | tr -d ' \n')/install.sh | sh && \ + . $HOME/.local/bin/env && \ + uv sync --frozen --no-install-project && \ + uv run ${WDIR}/builder/utils/bridge.py --shared -# launch app -CMD [ "/bin/bash" ] +# activate .venv +CMD [ "source", ".venv/bin/activate" ] diff --git a/builder/__main__.py b/builder/__main__.py index 5ac73ca..fff1060 100644 --- a/builder/__main__.py +++ b/builder/__main__.py @@ -12,6 +12,18 @@ from builder.commands import KernelCommand, AssetsCommand, BundleCommand +def __get_version() -> str: + """Get app version.""" + msg = "zero_kernel {}" + + try: + return msg.format(version("zero-kernel")) + except Exception: + with open(Path(__file__).absolute().parents[1] / "pyproject.toml", "r") as f: + v = f.read().split('version = "')[1].split('"')[0] + return msg.format(v) + + def parse_args() -> argparse.Namespace: """Parse the script arguments.""" # show the 'help' message if no arguments supplied @@ -31,7 +43,7 @@ def parse_args() -> argparse.Namespace: action="store_true", help="clean the root directory" ) - parser_parent.add_argument("-v", "--version", action="version", version=version("zero-kernel")) + parser_parent.add_argument("-v", "--version", action="version", version=__get_version()) # common argument attributes for subparsers help_base = "select a kernel base for the build"