From 2a2767bfb32b53da476253aa52df1293a9216cee Mon Sep 17 00:00:00 2001 From: Chessing234 Date: Sat, 30 May 2026 13:25:35 +0530 Subject: [PATCH] fix: fall back to source build on non-PEP-440 version strings in get_wheel_url packaging.version.parse raises InvalidVersion when torch.__version__ or torch.version.cuda contains a vendor build string (e.g. 'gpgpu.') 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. --- setup.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index f9c33204f..41bcb44c4 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ import re import ast from pathlib import Path -from packaging.version import parse, Version +from packaging.version import parse, Version, InvalidVersion import platform import shutil @@ -337,7 +337,12 @@ def run(self): if FORCE_BUILD: return super().run() - wheel_url, wheel_filename = get_wheel_url() + try: + wheel_url, wheel_filename = get_wheel_url() + except InvalidVersion: + print("Non-PEP-440 version string detected. Building from source...") + super().run() + return print("Guessing wheel URL: ", wheel_url) try: urllib.request.urlretrieve(wheel_url, wheel_filename)