-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: better build_wheel.py venv handling #4525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves the virtual environment handling in build_wheel.py by recognizing pre‐existing environments and warning users about potential PyTorch conflicts.
- Introduces a new function create_venv for creating venvs.
- Adds a no-venv option to use the current Python environment as is.
- Updates venv path resolution and incorporates a check/warning for NVIDIA PyTorch issues.
Comments suppressed due to low confidence (1)
scripts/build_wheel.py:76
- [nitpick] The change from using a variable name like venv_dir to venv_prefix could reduce clarity. Consider using a consistent and self-explanatory name (e.g., venv_dir) throughout the code.
venv_prefix = project_dir / f".venv-{py_major}.{py_minor}"
/bot run |
PR_Github #5980 [ run ] triggered by Bot |
PR_Github #5980 [ run ] completed with state |
8da545e
to
976417b
Compare
/bot run |
976417b
to
46f99cb
Compare
PR_Github #5987 [ run ] triggered by Bot |
Signed-off-by: Yuan Tong <13075180+tongyuantongyu@users.noreply.github.com>
46f99cb
to
b1ad203
Compare
/bot run |
PR_Github #5989 [ run ] triggered by Bot |
PR_Github #5987 [ run ] completed with state |
PR_Github #5989 [ run ] completed with state |
if os.environ.get( | ||
"NVIDIA_PYTORCH_VERSION") is not None and has_non_system_pytorch: | ||
warnings.warn( | ||
"You are using the NVIDIA PyTorch container, but not using the provided PyTorch installation. " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refined by Owen:
Using the NVIDIA PyTorch container without leveraging the included PyTorch installation may lead to compatibility issues.
If you encounter any problems, please delete the environment at `{venv_prefix}` so that `build_wheel.py` can recreate the virtual environment.
parser.add_argument( | ||
"--no-venv", | ||
action="store_true", | ||
help="Use current Python interpreter as is, don't create venv.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the current Python interpreter without creating a virtual environment
f"If anything goes wrong, please remove the environment at {venv_prefix} " | ||
"to let build_wheel.py rebuild virtual environment.") | ||
print("^^^^^^^^^^ IMPORTANT WARNING ^^^^^^^^^^", file=sys.stderr) | ||
time.sleep(15) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use some more elegant behaviour instead of time.sleep(15)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of prompting the user to consider taking action, can we just run pip remove torch
inside the venv in this case (before running pip install -r "{requirements_file}"
)?
Some user experience improvements for
build_wheel.py
related to virtual environment handling