fix: fall back to source build when version string is not PEP 440#961
Open
Chessing234 wants to merge 1 commit into
Open
fix: fall back to source build when version string is not PEP 440#961Chessing234 wants to merge 1 commit into
Chessing234 wants to merge 1 commit into
Conversation
…wheel_url packaging.version.parse raises InvalidVersion when torch.__version__ or torch.version.cuda contains a vendor build string (e.g. 'gpgpu.<build-id>') that does not conform to PEP 440. The exception propagated uncaught out of get_wheel_url(), aborting the install entirely instead of falling back to a source build. Catch InvalidVersion at the call site and invoke super().run() so the build proceeds from source, consistent with the existing HTTPError path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
CachedWheelsCommand.run()callsget_wheel_url()without catchingInvalidVersion. In vendor PyTorch containers (e.g. NGC images with internal build IDs),torch.__version__ortorch.version.cudacan be a non-PEP-440 string such asgpgpu.<build-id>.packaging.version.parseraisesInvalidVersionon those strings, which propagates uncaught and aborts the install entirely.Reported in #947.
Root cause
get_wheel_url()callsparse(torch.__version__)andparse(torch.version.cuda). Both raiseInvalidVersionfor non-standard version strings. Theexcept urllib.error.HTTPErrorblock that falls back to source build is never reached.Fix
Import
InvalidVersionfrompackaging.versionand wrapget_wheel_url()in a try/except at the call site. When caught, fall back tosuper().run()(source build), consistent with howurllib.error.HTTPErroris already handled.Why this fix is correct
The existing
except urllib.error.HTTPErrorpath already expresses the intent: if the prebuilt wheel cannot be obtained for any reason, fall back to a source build.InvalidVersionis another such reason. The fix keeps the same fallback behavior and does not change what wheels are downloaded or how they are built.