Skip to content

Validate wheel name before trying to use it#27

Open
ppham-nv wants to merge 1 commit into
wheelnext:mainfrom
ppham-nv:validate-wheel-name
Open

Validate wheel name before trying to use it#27
ppham-nv wants to merge 1 commit into
wheelnext:mainfrom
ppham-nv:validate-wheel-name

Conversation

@ppham-nv

@ppham-nv ppham-nv commented Nov 3, 2025

Copy link
Copy Markdown

Overview

This PR adds logic to filter out invalid wheel file names first before trying to use it in get_compatible_wheel. This change help resolves an issue where a pypi index repo could have "generic package" with invalid wheel names.

Example of this bug

There may be a case where a gitlab package registry has a combination of both pypi compatible wheel names and "generic package" wheels where it doesn't match the expected file name required by get_compatible_wheel.

Even though my wheel stub is pointed to vllm-0.10.2+9dd9ca32.nv25.10.cu130 I am unable to install it. The reason is due to our gitlab registry contains an invalid wheel file name in the generic repo: vllm-0.10.0+c02c4027.25.6.eclair.cu129 but wheel-stub collect all wheels name in WheelFilter via HTML parsing but then will run into error when it tries to call get_compatible_wheel against an invalid wheel name.

  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [68 lines of output]
        File "/tmp/pip-build-env-k3xvvyh9/overlay/local/lib/python3.12/dist-packages/wheel_stub/wheel.py", line 249, in download_wheel
          return download_manual(wheel_directory, distribution, version, config)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-k3xvvyh9/overlay/local/lib/python3.12/dist-packages/wheel_stub/wheel.py", line 181, in download_manual
          wheel_url, wheel_filename, (scheme, hash) = get_compatible_wheel(
                                                      ^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-k3xvvyh9/overlay/local/lib/python3.12/dist-packages/wheel_stub/wheel.py", line 145, in get_compatible_wheel
          _name, ver, _build_num, tags = parse_wheel_filename(wheel_filename)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-k3xvvyh9/overlay/local/lib/python3.12/dist-packages/wheel_stub/_vendor/packaging/utils.py", line 116, in parse_wheel_filename
          raise InvalidWheelFilename(
      Traceback (most recent call last):
        File "/tmp/pip-build-env-k3xvvyh9/overlay/local/lib/python3.12/dist-packages/wheel_stub/wheel.py", line 249, in download_wheel
          return download_manual(wheel_directory, distribution, version, config)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-k3xvvyh9/overlay/local/lib/python3.12/dist-packages/wheel_stub/wheel.py", line 181, in download_manual
          wheel_url, wheel_filename, (scheme, hash) = get_compatible_wheel(
                                                      ^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-k3xvvyh9/overlay/local/lib/python3.12/dist-packages/wheel_stub/wheel.py", line 145, in get_compatible_wheel
          _name, ver, _build_num, tags = parse_wheel_filename(wheel_filename)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-k3xvvyh9/overlay/local/lib/python3.12/dist-packages/wheel_stub/_vendor/packaging/utils.py", line 116, in parse_wheel_filename
          raise InvalidWheelFilename(
      wheel_stub._vendor.packaging.utils.InvalidWheelFilename: Invalid wheel filename (wrong number of parts): vllm-0.10.0+c02c4027.25.6.eclair.cu129

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "/usr/local/lib/python3.12/dist-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
          main()
        File "/usr/local/lib/python3.12/dist-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
          json_out["return_val"] = hook(**hook_input["kwargs"])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/local/lib/python3.12/dist-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 178, in prepare_metadata_for_build_wheel
          whl_basename = backend.build_wheel(metadata_directory, config_settings)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-k3xvvyh9/overlay/local/lib/python3.12/dist-packages/wheel_stub/buildapi.py", line 29, in build_wheel
          return download_wheel(pathlib.Path(wheel_directory), config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-k3xvvyh9/overlay/local/lib/python3.12/dist-packages/wheel_stub/wheel.py", line 251, in download_wheel
          report_install_failure(distribution, version, config, exception_context)
        File "/tmp/pip-build-env-k3xvvyh9/overlay/local/lib/python3.12/dist-packages/wheel_stub/error.py", line 67, in report_install_failure
          raise InstallFailedError(
      wheel_stub.error.InstallFailedError:
      *******************************************************************************

      The installation of vllm for version 0.10.2+9dd9ca32.nv25.10.cu130 failed.

      This is a special placeholder package which downloads a real wheel package
      from https://gitlab-master.nvidia.com/api/v4/projects/100660/packages/pypi/simple. If https://gitlab-master.nvidia.com/api/v4/projects/100660/packages/pypi/simple is not reachable, we
      cannot download the real wheel file to install.

      You might try installing this package via
      ```
      $ pip install --extra-index-url https://[REDACTED]/packages/pypi/simple vllm
      ```

Using the suggestion to do pip install --extra-index-url https://[REDACTED]/packages/pypi/simple vllm==0.10.2+9dd9ca32.nv25.10.cu130 works just fine.

…a gitlab package registry may have generic package registry wheel where its file name is not following a standard
Comment thread src/wheel_stub/wheel.py
# Validate wheel filename before adding it
try:
parse_wheel_filename(wheel_filename)
except Exception as e:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
except Exception as e:
except InvalidWheelFilename as e:

Let's only catch InvalidWheelFilename here. You'll also need to import it above.

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.

2 participants