From d317d9fbc271248c77a6a45e4257bee3b61d1797 Mon Sep 17 00:00:00 2001 From: Karthik Vanabhojana Date: Tue, 29 Sep 2026 21:50:10 -0500 Subject: [PATCH] fix: install setuptools into model venvs so bentoml can be imported `uv venv` seeds no setuptools, and packages bentoml depends on still call `__import__("pkg_resources")` at module scope, so running a model in a fresh venv failed with ModuleNotFoundError: No module named 'pkg_resources' Install setuptools next to bentoml. pkg_resources was dropped in setuptools 81, so it is pinned below that. Fixes #1221 --- src/openllm/venv.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/openllm/venv.py b/src/openllm/venv.py index 7c7cfda32..99b12c1f8 100644 --- a/src/openllm/venv.py +++ b/src/openllm/venv.py @@ -49,8 +49,11 @@ def _ensure_venv(venv_spec: VenvSpec) -> pathlib.Path: ['python', '-m', 'uv', 'venv', venv.__fspath__(), '-p', venv_spec.python_version], silent=VERBOSE_LEVEL.get() < 10, ) + # `uv venv` seeds no setuptools, yet bentoml pulls in packages that still + # import pkg_resources at module scope. setuptools dropped pkg_resources + # in 81, so pin below that to keep the import working. run_command( - ['python', '-m', 'uv', 'pip', 'install', '-p', str(venv_py), 'bentoml'], + ['python', '-m', 'uv', 'pip', 'install', '-p', str(venv_py), 'bentoml', 'setuptools<81'], silent=VERBOSE_LEVEL.get() < 10, env=venv_spec.envs, )