From 8d4b78514a98f96872b522b030892f9ea0ff8f7c Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Thu, 26 Dec 2024 10:28:02 +0800 Subject: [PATCH] fix: permission issue of uv python installation directory (#5151) --- src/_bentoml_sdk/images.py | 9 +++++---- src/bentoml/_internal/configuration/__init__.py | 4 ++-- .../container/frontend/dockerfile/templates/base_v2.j2 | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/_bentoml_sdk/images.py b/src/_bentoml_sdk/images.py index 72b2cd141b7..1f394734b54 100644 --- a/src/_bentoml_sdk/images.py +++ b/src/_bentoml_sdk/images.py @@ -191,7 +191,6 @@ def get_image_from_build_config(build_config: BentoBuildConfig) -> Image | None: "conda options are not supported by bento v2, fallback to bento v1" ) return None - image = PythonImage() docker_options = build_config.docker if docker_options.cuda_version is not None: logger.warning( @@ -208,12 +207,14 @@ def get_image_from_build_config(build_config: BentoBuildConfig) -> Image | None: "docker.setup_script is not supported by bento v2, fallback to bento v1" ) return None + image_params = {} if docker_options.base_image is not None: - image.base_image = docker_options.base_image + image_params["base_image"] = docker_options.base_image if docker_options.distro is not None: - image.distro = docker_options.distro + image_params["distro"] = docker_options.distro if docker_options.python_version is not None: - image.python_version = docker_options.python_version + image_params["python_version"] = docker_options.python_version + image = PythonImage(**image_params) if docker_options.system_packages: image.system_packages(*docker_options.system_packages) diff --git a/src/bentoml/_internal/configuration/__init__.py b/src/bentoml/_internal/configuration/__init__.py index 2ec6d91385f..dbee03250cf 100644 --- a/src/bentoml/_internal/configuration/__init__.py +++ b/src/bentoml/_internal/configuration/__init__.py @@ -71,7 +71,7 @@ def is_editable_bentoml() -> bool: dist = importlib.metadata.distribution("bentoml") direct_url_file = next( - (f for f in (dist.files or []) if f.name == "direct_url.json"), None + (f for f in (dist.files or []) if str(f).endswith("direct_url.json")), None ) if direct_url_file is None: return False @@ -84,7 +84,7 @@ def get_bentoml_requirement() -> str | None: """Returns the requirement string for BentoML.""" dist = importlib.metadata.distribution("bentoml") direct_url_file = next( - (f for f in (dist.files or []) if f.name == "direct_url.json"), None + (f for f in (dist.files or []) if str(f).endswith("direct_url.json")), None ) if direct_url_file is None: return f"bentoml=={BENTOML_VERSION}" diff --git a/src/bentoml/_internal/container/frontend/dockerfile/templates/base_v2.j2 b/src/bentoml/_internal/container/frontend/dockerfile/templates/base_v2.j2 index 6db979a7e0b..b668ccae0f3 100644 --- a/src/bentoml/_internal/container/frontend/dockerfile/templates/base_v2.j2 +++ b/src/bentoml/_internal/container/frontend/dockerfile/templates/base_v2.j2 @@ -59,7 +59,7 @@ WORKDIR $BENTO_PATH RUN {{ command }} {% endfor %} -RUN pip install uv && uv venv --python {{ __options__python_version }} /app/.venv +RUN pip install uv && UV_PYTHON_INSTALL_DIR=/app/python/ uv venv --python {{ __options__python_version }} /app/.venv ENV VIRTUAL_ENV=/app/.venv {% set __pip_cache__ = common.mount_cache("/root/.cache/") %} {% if __pip_preheat_packages__ %}