From 722bdc5a0570939ffd905b8c3a2c546b0e7bfe6a Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Thu, 16 Jan 2025 09:05:10 +0800 Subject: [PATCH] fix: use a specific manylinux version as build platform for better compatibility (#5185) * fix: use a specific manylinux version as build platform for better compatibility Signed-off-by: Frost Ming --- src/_bentoml_sdk/images.py | 3 ++- src/bentoml/_internal/bento/build_config.py | 3 ++- .../_internal/configuration/__init__.py | 2 ++ src/bentoml_cli/bentos.py | 18 ++++++++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/_bentoml_sdk/images.py b/src/_bentoml_sdk/images.py index 1f394734b54..f43f6742fd2 100644 --- a/src/_bentoml_sdk/images.py +++ b/src/_bentoml_sdk/images.py @@ -11,6 +11,7 @@ from bentoml._internal.bento.bento import ImageInfo from bentoml._internal.bento.build_config import BentoBuildConfig +from bentoml._internal.configuration import DEFAULT_LOCK_PLATFORM from bentoml._internal.configuration import get_bentoml_requirement from bentoml._internal.configuration import get_debug_mode from bentoml._internal.configuration import get_quiet_mode @@ -132,7 +133,7 @@ def _freeze_python_requirements(self, platform_: str | None = None) -> str: "Locking packages for x86_64-unknown-linux-gnu. " "Pass `--platform` option to specify the platform." ) - lock_args.extend(["--python-platform", "linux"]) + lock_args.extend(["--python-platform", DEFAULT_LOCK_PLATFORM]) cmd = [sys.executable, "-m", "uv", "pip", "compile", *lock_args] try: subprocess.check_call( diff --git a/src/bentoml/_internal/bento/build_config.py b/src/bentoml/_internal/bento/build_config.py index e5925b6b983..be66efedfa4 100644 --- a/src/bentoml/_internal/bento/build_config.py +++ b/src/bentoml/_internal/bento/build_config.py @@ -20,6 +20,7 @@ from ...exceptions import BentoMLException from ...exceptions import InvalidArgument +from ..configuration import DEFAULT_LOCK_PLATFORM from ..configuration import clean_bentoml_version from ..configuration import get_bentoml_requirement from ..configuration import get_debug_mode @@ -670,7 +671,7 @@ def write_to_bento( "Locking packages for x86_64-unknown-linux-gnu. " "Pass `--platform` option to specify the platform." ) - pip_compile_args.extend(["--python-platform", "linux"]) + pip_compile_args.extend(["--python-platform", DEFAULT_LOCK_PLATFORM]) cmd = [sys.executable, "-m", "uv", "pip", "compile"] cmd.extend(pip_compile_args) try: diff --git a/src/bentoml/_internal/configuration/__init__.py b/src/bentoml/_internal/configuration/__init__.py index dbee03250cf..2e5ba99d993 100644 --- a/src/bentoml/_internal/configuration/__init__.py +++ b/src/bentoml/_internal/configuration/__init__.py @@ -28,6 +28,8 @@ CONFIG_OVERRIDE_JSON_ENV_VAR = "BENTOML_CONFIG_OVERRIDES" # https://github.com/grpc/grpc/blob/master/doc/environment_variables.md GRPC_DEBUG_ENV_VAR = "GRPC_VERBOSITY" +# The glibc version of python:3.11-slim image +DEFAULT_LOCK_PLATFORM = "x86_64-manylinux_2_36" def get_bentoml_version() -> str: diff --git a/src/bentoml_cli/bentos.py b/src/bentoml_cli/bentos.py index 847fb93cbb7..7cfc8e5a15e 100644 --- a/src/bentoml_cli/bentos.py +++ b/src/bentoml_cli/bentos.py @@ -50,9 +50,27 @@ "x86_64-manylinux_2_17", "x86_64-manylinux_2_28", "x86_64-manylinux_2_31", + "x86_64-manylinux_2_32", + "x86_64-manylinux_2_33", + "x86_64-manylinux_2_34", + "x86_64-manylinux_2_35", + "x86_64-manylinux_2_36", + "x86_64-manylinux_2_37", + "x86_64-manylinux_2_38", + "x86_64-manylinux_2_39", + "x86_64-manylinux_2_40", "aarch64-manylinux_2_17", "aarch64-manylinux_2_28", "aarch64-manylinux_2_31", + "aarch64-manylinux_2_32", + "aarch64-manylinux_2_33", + "aarch64-manylinux_2_34", + "aarch64-manylinux_2_35", + "aarch64-manylinux_2_36", + "aarch64-manylinux_2_37", + "aarch64-manylinux_2_38", + "aarch64-manylinux_2_39", + "aarch64-manylinux_2_40", ]