Skip to content

Catch InvalidVersion in setup.py to fall back to source build#960

Closed
Chessing234 wants to merge 1 commit into
state-spaces:mainfrom
Chessing234:fix/setup-invalid-version-fallback
Closed

Catch InvalidVersion in setup.py to fall back to source build#960
Chessing234 wants to merge 1 commit into
state-spaces:mainfrom
Chessing234:fix/setup-invalid-version-fallback

Conversation

@Chessing234

Copy link
Copy Markdown
Contributor

Bug

get_wheel_url() in setup.py calls packaging.version.parse() on torch.__version__ and torch.version.cuda. In vendor PyTorch containers these can be non-PEP 440 strings (e.g. gpgpu.<build-id>), causing parse() to raise InvalidVersion.

Because CachedWheelsCommand.run() has no handler for this exception, the install aborts instead of falling back to a source build.

Root cause

get_wheel_url() (line 281/290) passes raw version strings to packaging.version.parse() without guarding against InvalidVersion. The existing try/except in run() only catches urllib.error.HTTPError from the download step — it never reaches that point.

Fix

Wrap the get_wheel_url() call with try/except InvalidVersion so the build falls back to super().run() (source compilation) when the version string cannot be parsed. This matches the existing fallback behavior for missing prebuilt wheels.

Fixes #947

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.<build-id>').

Wrap the call with try/except InvalidVersion so the install falls
back to a source build instead of aborting.

Fixes state-spaces#947
@Chessing234

Copy link
Copy Markdown
Contributor Author

Closing as duplicate of #961.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mamba-ssm setup.py fails with InvalidVersion for vendor PyTorch/CUDA version strings instead of falling back to source build

1 participant