Skip to content

Commit 5637e1d

Browse files
author
Ylang Tsou
committed
add conftest.py
Signed-off-by: Ylang Tsou <ylangt@google.com>
1 parent f121e07 commit 5637e1d

File tree

2 files changed

+42
-15
lines changed

2 files changed

+42
-15
lines changed

docker/Dockerfile.pypi

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,19 @@ RUN apt-get update && apt-get install -y \
1515
WORKDIR /workspace/tpu_inference
1616
COPY . .
1717
RUN export TPU_INFERENCE_VERSION=$(pip index versions tpu-inference --pre 2>/dev/null | grep -oE "[0-9]+\.[0-9]+\.[0-9]+\.dev[0-9]+" | head -n 1) && \
18-
echo -n "$TPU_INFERENCE_VERSION" > /tmp/tpu_inference_version && \
19-
echo "Installing tpu-inference version: $TPU_INFERENCE_VERSION"
18+
echo -n "${TPU_INFERENCE_VERSION}" > /tmp/tpu_inference_version
2019

2120
# Clone vLLM
22-
WORKDIR /workspace/vllm_build
21+
WORKDIR /workspace/vllm
2322
ARG VLLM_REPO=https://github.com/vllm-project/vllm.git
24-
RUN git clone $VLLM_REPO /workspace/vllm_build
23+
RUN git clone $VLLM_REPO /workspace/vllm
2524
RUN pip install build
2625
RUN export TPU_INFERENCE_VERSION=$(cat /tmp/tpu_inference_version) && \
27-
echo "Using tpu-inference version: ${TPU_INFERENCE_VERSION}" && \
2826
sed -i "s/^tpu-inference==.*/tpu-inference==${TPU_INFERENCE_VERSION}/" requirements/tpu.txt && \
29-
echo "Starting build.sh" && \
3027
bash tools/vllm-tpu/build.sh ${TPU_INFERENCE_VERSION}
3128

3229
# Install vllm-tpu from wheel
33-
RUN echo "pip installing vllm-tpu" && \
34-
pip install --no-cache-dir dist/*.whl
35-
# RUN export TPU_INFERENCE_VERSION=$(cat /tmp/tpu_inference_version) && \
36-
# export PIP_VERSION=$(echo "$TPU_INFERENCE_VERSION" | sed 's/^v//') && \
37-
# echo "Installing vllm-tpu version: $PIP_VERSION" && \
38-
# python3 -m pip install -v --no-cache-dir "vllm-tpu==$PIP_VERSION"
30+
RUN pip install --no-cache-dir dist/*.whl
3931

4032
# Install test dependencies
4133
RUN python3 -m pip install -e tests/vllm_test_utils
@@ -46,8 +38,7 @@ RUN python3 -m pip install --no-cache-dir \
4638
pytest-cov \
4739
tblib
4840

49-
# Preventing shadowing
50-
# WORKDIR /workspace
51-
# RUN mv /workspace/vllm /workspace/vllm_backup
41+
# Set environment variable to use site-packages
42+
ENV FORCE_USE_SITE_PACKAGES=1
5243

5344
CMD ["/bin/bash"]

tests/conftest.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import os
2+
import site
3+
import sys
4+
5+
6+
def pytest_configure(config):
7+
if os.environ.get("FORCE_USE_SITE_PACKAGES", "0") != "1":
8+
print("[DEBUG] Running in Repo Mode. Using local source code.",
9+
file=sys.stderr)
10+
return
11+
12+
print("\n[DEBUG] conftest.py is fixing sys.path...", file=sys.stderr)
13+
14+
local_vllm_path = os.path.abspath("/workspace/vllm")
15+
16+
removed = False
17+
for path in list(sys.path):
18+
if local_vllm_path in os.path.abspath(path):
19+
sys.path.remove(path)
20+
removed = True
21+
print(f"[DEBUG] Removed local source from path: {path}",
22+
file=sys.stderr)
23+
24+
site_packages = site.getsitepackages()
25+
for sp in site_packages:
26+
if sp not in sys.path:
27+
sys.path.insert(0, sp)
28+
else:
29+
sys.path.remove(sp)
30+
sys.path.insert(0, sp)
31+
32+
if removed:
33+
print("Path fix applied successfully.", file=sys.stderr)
34+
else:
35+
print("Local vllm path not found in sys.path (maybe already clean?)",
36+
file=sys.stderr)

0 commit comments

Comments
 (0)