Skip to content

Conversation

@jcyang43
Copy link
Contributor

@jcyang43 jcyang43 commented Oct 21, 2025

Purpose

Patch tpu wheel build script to resolve metadata issue described here

Test Plan

E2E test to verify built python wheel.

Test Result

Successful.


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

@mergify mergify bot added the ci/build label Oct 21, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly addresses a metadata issue in TPU wheel builds by properly using setuptools-scm for version overriding in setup.py. The accompanying changes in the build.sh script to patch hardcoded package names are also appropriate. My feedback focuses on improving the robustness of the patching mechanism within the build script to make it safer and more resilient to future code changes.

Comment on lines +42 to +53
sed -i \
-e "s/importlib.metadata.version(\(['\"]\)vllm\1)/importlib.metadata.version(\1vllm-tpu\1)/" \
-e "s/importlib.metadata.metadata(\(['\"]\)vllm\1)/importlib.metadata.metadata(\1vllm-tpu\1)/" \
-e "s/version(\(['\"]\)vllm\1)/version(\1vllm-tpu\1)/" \
"${CHANGE_FILE_LIST[@]}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

For improved robustness and safety, I recommend two changes to this sed command:

  1. Global Replacement: Add the g flag to each substitution. This ensures that all occurrences of the pattern on a single line are replaced, not just the first. While the current files may only have one occurrence per line, this makes the script more resilient to future changes.

  2. Safer Patching: Use sed -i.bak to create backup files. This is more robust than relying on a second sed command in the cleanup function to revert changes, especially if the script is terminated abruptly (e.g., with kill -9). The cleanup function should then be updated to restore from these .bak files, which is consistent with how pyproject.toml is handled in this script.

Suggested change
sed -i \
-e "s/importlib.metadata.version(\(['\"]\)vllm\1)/importlib.metadata.version(\1vllm-tpu\1)/" \
-e "s/importlib.metadata.metadata(\(['\"]\)vllm\1)/importlib.metadata.metadata(\1vllm-tpu\1)/" \
-e "s/version(\(['\"]\)vllm\1)/version(\1vllm-tpu\1)/" \
"${CHANGE_FILE_LIST[@]}"
sed -i.bak \
-e "s/importlib.metadata.version(\(['\"]\)vllm\1)/importlib.metadata.version(\1vllm-tpu\1)/g" \
-e "s/importlib.metadata.metadata(\(['\"]\)vllm\1)/importlib.metadata.metadata(\1vllm-tpu\1)/g" \
-e "s/version(\(['\"]\)vllm\1)/version(\1vllm-tpu\1)/g" \
"${CHANGE_FILE_LIST[@]}"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you at least leave a comment for what these edits are doing? I don't naturally read sed :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks for the reminder :)

Comment on lines +63 to +75
echo "Restoring vllm code..."
sed -i \
-e "s/importlib.metadata.version(\(['\"]\)vllm-tpu\1)/importlib.metadata.version(\1vllm\1)/" \
-e "s/importlib.metadata.metadata(\(['\"]\)vllm-tpu\1)/importlib.metadata.metadata(\1vllm\1)/" \
-e "s/version(\(['\"]\)vllm-tpu\1)/version(\1vllm\1)/" \
"${CHANGE_FILE_LIST[@]}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

To complement the use of sed -i.bak for patching, the cleanup logic should be updated to restore files from their backups. This is a more robust and safer approach than running another sed command to revert the changes, as it protects against incomplete reversions if the script is forcefully terminated.

Suggested change
echo "Restoring vllm code..."
sed -i \
-e "s/importlib.metadata.version(\(['\"]\)vllm-tpu\1)/importlib.metadata.version(\1vllm\1)/" \
-e "s/importlib.metadata.metadata(\(['\"]\)vllm-tpu\1)/importlib.metadata.metadata(\1vllm\1)/" \
-e "s/version(\(['\"]\)vllm-tpu\1)/version(\1vllm\1)/" \
"${CHANGE_FILE_LIST[@]}"
echo "Restoring vllm code..."
for file in "${CHANGE_FILE_LIST[@]}"; do
if [ -f "${file}.bak" ]; then
mv "${file}.bak" "${file}"
fi
done

setup.py Outdated
# wheels (e.g. CPU, TPU) without modifying the source.
if env_version := os.getenv("VLLM_VERSION_OVERRIDE"):
return env_version
print(f"Overriding VLLM-TPU version with: {env_version}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print(f"Overriding VLLM-TPU version with: {env_version}")
print(f"Overriding VLLM version with {env_version} from VLLM_VERSION_OVERRIDE")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks

Comment on lines +42 to +53
sed -i \
-e "s/importlib.metadata.version(\(['\"]\)vllm\1)/importlib.metadata.version(\1vllm-tpu\1)/" \
-e "s/importlib.metadata.metadata(\(['\"]\)vllm\1)/importlib.metadata.metadata(\1vllm-tpu\1)/" \
-e "s/version(\(['\"]\)vllm\1)/version(\1vllm-tpu\1)/" \
"${CHANGE_FILE_LIST[@]}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you at least leave a comment for what these edits are doing? I don't naturally read sed :)

Signed-off-by: Johnny Yang <johnnyyang@google.com>
@mgoin mgoin enabled auto-merge (squash) November 12, 2025 22:47
@mgoin mgoin added tpu Related to Google TPUs ready ONLY add when PR is ready to merge/full CI is needed labels Nov 12, 2025
@mergify mergify bot removed the tpu Related to Google TPUs label Nov 12, 2025
@vllm-bot vllm-bot merged commit fdfd507 into vllm-project:main Nov 13, 2025
88 of 91 checks passed
elizabetht pushed a commit to elizabetht/vllm that referenced this pull request Nov 13, 2025
…oject#27279)

Signed-off-by: Johnny Yang <johnnyyang@google.com>
Signed-off-by: Elizabeth Thomas <email2eliza@gmail.com>
geodavic pushed a commit to geodavic/vllm that referenced this pull request Nov 16, 2025
…oject#27279)

Signed-off-by: Johnny Yang <johnnyyang@google.com>
Signed-off-by: George D. Torres <gdavtor@gmail.com>
bwasti pushed a commit to bwasti/vllm that referenced this pull request Nov 17, 2025
…oject#27279)

Signed-off-by: Johnny Yang <johnnyyang@google.com>
Signed-off-by: Bram Wasti <bwasti@meta.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/build ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants