Skip to content

Commit b0ccd75

Browse files
authored
fix: Ignore python.packages when requirements_txt is provided (#5421)
issue 5380 fix
1 parent 86ee5dd commit b0ccd75

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/_bentoml_sdk/images.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def populate_image_from_build_config(
397397
image.requirements_file(
398398
resolve_user_filepath(python_options.requirements_txt, build_ctx)
399399
)
400-
if python_options.packages:
400+
elif python_options.packages:
401401
image.python_packages(*python_options.packages)
402402
if docker_options.setup_script:
403403
image.run_script(docker_options.setup_script)

src/bentoml/_internal/cloud/deployment.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,8 +1570,9 @@ def _build_requirements_txt(bento_dir: str, image: Image | None) -> bytes:
15701570
if filename and os.path.exists(fullpath := os.path.join(bento_dir, filename)):
15711571
with open(fullpath, "rb") as f:
15721572
content = f.read().rstrip(b"\n") + b"\n"
1573-
for package in config.python.packages or []:
1574-
content += f"{package}\n".encode()
1573+
elif config.python.packages:
1574+
for package in config.python.packages:
1575+
content += f"{package}\n".encode()
15751576
if image and image.python_requirements:
15761577
content += image.python_requirements.encode()
15771578
bentoml_requirement = get_bentoml_requirement()

0 commit comments

Comments
 (0)