From 50d5b2b8bdf1eda6374a52d370f49c7b2de2ec8e Mon Sep 17 00:00:00 2001 From: Taksh Date: Sat, 30 May 2026 13:25:06 +0530 Subject: [PATCH] Catch InvalidVersion in setup.py to fall back to source build get_wheel_url() calls packaging.version.parse() on torch.__version__ and torch.version.cuda, which raises InvalidVersion for non-PEP 440 vendor build strings (e.g. 'gpgpu.'). Wrap the call with try/except InvalidVersion so the install falls back to a source build instead of aborting. Fixes #947 --- setup.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index f9c33204f..6a3232d06 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, InvalidVersion, Version import platform import shutil @@ -337,7 +337,11 @@ 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("Could not determine wheel URL (non-PEP 440 version). Building from source...") + return super().run() print("Guessing wheel URL: ", wheel_url) try: urllib.request.urlretrieve(wheel_url, wheel_filename)