Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tensorrt-cu12-libs Package to Use Metadata 2.2 or Later for Improved Dependency Resolution #4352

Open
validatedev opened this issue Feb 9, 2025 · 13 comments
Assignees
Labels
Feature Request Request for new functionality internal-bug-tracked Tracked internally, will be fixed in a future release. Module:OSS Build Issues building open source code triaged Issue has been triaged by maintainers

Comments

@validatedev
Copy link

validatedev commented Feb 9, 2025

Description

I am experiencing an issue with the tensorrt-cu12-libs package available on PyPI. Specifically, the package does not publish any wheels (as seen here), and the source distribution uses Metadata 2.1. This older metadata version lacks essential information that modern package management tools rely on for dependency resolution.

When I use tools like uv to manage dependencies, they attempt to build the tensorrt-cu12-libs package because they cannot read the required metadata without building the package. This leads to build failures unfortunately.

Updating the tensorrt-cu12-libs package to use Metadata 2.2 or later by employing the latest version of setuptools during package creation would allow tools to read the metadata without building the package. This change would improve dependency resolution and prevent build attempts on unsupported platforms.

Environment

TensorRT Version: 10.8.0.43

NVIDIA GPU: Not applicable (issue occurs on systems without NVIDIA GPUs)

NVIDIA Driver Version: Not applicable

CUDA Version: 12.x

CUDNN Version: Not applicable

Operating System:

  • Darwin 24.3.0 arm64 (macOS Sequoia 15.3 24D60)
  • Docker Container based on python:3.12-slim-bookworm

Python Version: Python 3.12.9

TensorFlow Version: Not applicable

PyTorch Version: 2.6.0

Bare Metal or Container: Both bare metal and Docker containers

Relevant Files

A minimal reproducible example (MRE) is available here:

These repositories contain pyproject.toml files that specify tensorrt-cu12-libs as an optional dependency.

Steps To Reproduce

Using Optional Dependencies (Extras)

  1. Clone the MRE repository:

    git clone https://github.com/validatedev/uv-tensorrt-extradep-issue-mre.git
    cd uv-tensorrt-extradep-issue-mre
  2. Attempt to synchronize dependencies for an extra that does not include tensorrt-cu12-libs (e.g., macos):

    uv sync --extra macos
  3. Observe that uv tries to build tensorrt-cu12-libs even though it's not part of the macos extra. The build fails with an error similar to:

    × Failed to build `tensorrt-cu12-libs==10.8.0.43`
    ├─▶ The build backend returned an error
    ╰─▶ Call to `wheel_stub.buildapi.build_wheel` failed (exit status: 1)
    
  4. Observe that uv tries to build tensorrt-cu12-libs even though it is not requested.

docker build -f linux-cpu.Dockerfile -t uv-test-extra .

[+] Building 12.2s (11/12) 
 => [internal] load build definition from linux-cpu.Dockerfile                                                                                                            0.1s
 => => transferring dockerfile: 571B                                                                                                                                      0.0s
 => [internal] load metadata for docker.io/library/python:3.12-slim-bookworm                                                                                              2.0s
 => [internal] load .dockerignore                                                                                                                                         0.0s
 => => transferring context: 2B                                                                                                                                           0.0s
 => [1/7] FROM docker.io/library/python:3.12-slim-bookworm@sha256:34656cd90456349040784165b9decccbcee4de66f3ead0a1168ba893455afd1e                                        0.0s
 => [3/7] ADD https://astral.sh/uv/0.5.29/install.sh /uv-installer.sh                                                                                                     1.6s
 => [internal] load build context                                                                                                                                         0.0s
 => => transferring context: 1.36kB                                                                                                                                       0.0s
 => CACHED [2/7] RUN apt-get update && apt-get upgrade -y     && apt-get install -y curl                                                                                  0.0s
 => CACHED [3/7] ADD https://astral.sh/uv/0.5.29/install.sh /uv-installer.sh                                                                                              0.0s
 => CACHED [4/7] RUN sh /uv-installer.sh && rm /uv-installer.sh                                                                                                           0.0s
 => CACHED [5/7] WORKDIR /app                                                                                                                                             0.0s
 => [6/7] COPY pyproject.toml hello.py /app/                                                                                                                              0.1s
 => [7/7] RUN uv --version     && uv sync --extra linux --extra linux-cpu                                                                                                 8.3s
 => => # uv 0.5.29                                                                                                                                                            
 => => # Using CPython 3.12.9 interpreter at: /usr/local/bin/python3                                                                                                          
 => => # Creating virtual environment at: .venv                                                                                                                               
 => => #    Building tensorrt-cu12-libs==10.8.0.43  

Using Dependency Groups

  1. Clone the MRE repository:

    git clone https://github.com/validatedev/uv-tensorrt-groupdep-issue-mre.git
    cd uv-tensorrt-groupdep-issue-mre
  2. Attempt to synchronize dependencies for a group that does not include tensorrt-cu12-libs (e.g., macos):

    uv sync --group macos
  3. Observe that uv tries to build tensorrt-cu12-libs. The build fails with an error.

Error Output

× Failed to build `tensorrt-cu12-libs==10.8.0.43`
├─▶ The build backend returned an error
╰─▶ Call to `wheel_stub.buildapi.build_wheel` failed (exit status: 1)

[stderr]
...
RuntimeError: Didn't find wheel for tensorrt-cu12-libs 10.8.0.43

...
  1. Observe that uv tries to build tensorrt-cu12-libs even though it is not requested.
docker build -f linux-cpu.Dockerfile -t uv-test-group .

[+] Building 8.2s (11/12)                                                                                                                                      docker:orbstack
 => [internal] load build definition from linux-cpu.Dockerfile                                                                                                            0.0s
 => => transferring dockerfile: 587B                                                                                                                                      0.0s
 => [internal] load metadata for docker.io/library/python:3.12-slim-bookworm                                                                                              0.8s
 => [internal] load .dockerignore                                                                                                                                         0.0s
 => => transferring context: 2B                                                                                                                                           0.0s
 => [1/7] FROM docker.io/library/python:3.12-slim-bookworm@sha256:34656cd90456349040784165b9decccbcee4de66f3ead0a1168ba893455afd1e                                        0.0s
 => [internal] load build context                                                                                                                                         0.0s
 => => transferring context: 137B                                                                                                                                         0.0s
 => [3/7] ADD https://astral.sh/uv/0.5.29/install.sh /uv-installer.sh                                                                                                     0.7s
 => CACHED [2/7] RUN apt-get update && apt-get upgrade -y     && apt-get install -y curl                                                                                  0.0s
 => CACHED [3/7] ADD https://astral.sh/uv/0.5.29/install.sh /uv-installer.sh                                                                                              0.0s
 => CACHED [4/7] RUN sh /uv-installer.sh && rm /uv-installer.sh                                                                                                           0.0s
 => CACHED [5/7] WORKDIR /app                                                                                                                                             0.0s
 => CACHED [6/7] COPY pyproject.toml hello.py /app/                                                                                                                       0.0s
 => [7/7] RUN uv --version     && uv sync --group linux --group linux-cpu --no-group cuda                                                                                 6.6s
 => => # uv 0.5.29                                                                                                                                                            
 => => # Using CPython 3.12.9 interpreter at: /usr/local/bin/python3                                                                                                          
 => => # Creating virtual environment at: .venv                                                                                                                               
 => => #    Building tensorrt-cu12-libs==10.8.0.43                                                                                                                            

Commands or Scripts:

  • uv sync --extra macos
  • uv sync --group macos
  • docker build -f linux-cpu.Dockerfile -t uv-test-extra .
  • docker build -f linux-cpu.Dockerfile -t uv-test-group .

Have you tried the latest release?

Yes, the issue persists with the latest release of TensorRT.

Can this model run on other frameworks?

Not applicable. The issue is related to package metadata and dependency resolution, not model execution.

Suggested Solution

Please consider updating the build process for tensorrt-cu12-libs to use the latest version of setuptools, which generates Metadata 2.2 or later. This update would include the enhanced metadata within the source distribution, allowing tools to read dependency information without building the package.

This change would improve compatibility with modern package management tools and prevent unnecessary build attempts on unsupported platforms.

Linked issue on repository uv: astral-sh/uv#11363

@charliermarsh
Copy link

I'm happy to try and bump the setuptools version. It looks like it's encoded in python/packaging/requirements.txt, but I can't find any context on how the given versions were chosen.

@LeoZDong LeoZDong added Module:OSS Build Issues building open source code triaged Issue has been triaged by maintainers labels Feb 10, 2025
@kevinch-nv kevinch-nv added Feature Request Request for new functionality internal-bug-tracked Tracked internally, will be fixed in a future release. labels Feb 12, 2025
@kevinch-nv
Copy link
Collaborator

These wheels are published internally. I'll open up a request internally for this.

@zeroepoch
Copy link
Contributor

@validatedev,

When I use tools like uv to manage dependencies, they attempt to build the tensorrt-cu12-libs package because they cannot read the required metadata without building the package. This leads to build failures unfortunately.

This package tensorrt-cu12-libs has to be "built" even in normal situations since the real wheel package lives on pypi.nvidia.com. The wheel-stub package does this redirection.

Bare Metal or Container: Both bare metal and Docker containers

It's unclear how this would work on bare metal using a Mac based on arm64 since we only have Linux x86 and Linux ARM SBSA packages available. Can you be sure it's not unable to find the required dependencies because it's simply not available?

@zeroepoch
Copy link
Contributor

I just tried your repo (running the commands manually so I could debug if needed) and it works for me on Fedora 41 (CPU: AMD Ryzen 9 5900x). I'm using the python:3.12-slim-bookworm container.

root@76f52c9f205b:~/uv-tensorrt-extradep-issue-mre# uv sync --extra cuda
Using CPython 3.12.9 interpreter at: /usr/local/bin/python3.12
Creating virtual environment at: .venv
      Built tensorrt-cu12-libs==10.8.0.43
Resolved 39 packages in 31.82s
      Built tensorrt==10.8.0.43
      Built tensorrt-cu12==10.8.0.43
Prepared 6 packages in 53.81s
Installed 6 packages in 3ms
 + attrs==25.1.0
 + nvidia-cuda-runtime-cu12==12.4.127
 + tensorrt==10.8.0.43
 + tensorrt-cu12==10.8.0.43
 + tensorrt-cu12-bindings==10.8.0.43
 + tensorrt-cu12-libs==10.8.0.43

@zeroepoch
Copy link
Contributor

zeroepoch commented Feb 13, 2025

Works with the Dockerfile you provided with the output I would expect to see.

$ docker build -f linux-cpu.Dockerfile -t uv-test-group .
STEP 1/10: FROM python:3.12-slim-bookworm
STEP 2/10: ENV UV_VERSION=0.5.29
--> ef9ca9f29033
STEP 3/10: RUN apt-get update && apt-get upgrade -y     && apt-get install -y curl
Get:1 http://deb.debian.org/debian bookworm InRelease [151 kB]
Get:2 http://deb.debian.org/debian bookworm-updates InRelease [55.4 kB]
Get:3 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]
Get:4 http://deb.debian.org/debian bookworm/main amd64 Packages [8792 kB]
Get:5 http://deb.debian.org/debian bookworm-updates/main amd64 Packages [13.5 kB]
Get:6 http://deb.debian.org/debian-security bookworm-security/main amd64 Packages [245 kB]
Fetched 9305 kB in 2s (6105 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
The following packages will be upgraded:
  libtasn1-6
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 48.6 kB of archives.
After this operation, 8192 B disk space will be freed.
Get:1 http://deb.debian.org/debian-security bookworm-security/main amd64 libtasn1-6 amd64 4.19.0-2+deb12u1 [48.6 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 48.6 kB in 0s (938 kB/s)
(Reading database ... 6686 files and directories currently installed.)
Preparing to unpack .../libtasn1-6_4.19.0-2+deb12u1_amd64.deb ...
Unpacking libtasn1-6:amd64 (4.19.0-2+deb12u1) over (4.19.0-2) ...
Setting up libtasn1-6:amd64 (4.19.0-2+deb12u1) ...
Processing triggers for libc-bin (2.36-9+deb12u9) ...
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  libbrotli1 libcurl4 libldap-2.5-0 libldap-common libnghttp2-14 libpsl5
  librtmp1 libsasl2-2 libsasl2-modules libsasl2-modules-db libssh2-1
  publicsuffix
Suggested packages:
  libsasl2-modules-gssapi-mit | libsasl2-modules-gssapi-heimdal
  libsasl2-modules-ldap libsasl2-modules-otp libsasl2-modules-sql
The following NEW packages will be installed:
  curl libbrotli1 libcurl4 libldap-2.5-0 libldap-common libnghttp2-14 libpsl5
  librtmp1 libsasl2-2 libsasl2-modules libsasl2-modules-db libssh2-1
  publicsuffix
0 upgraded, 13 newly installed, 0 to remove and 0 not upgraded.
Need to get 1837 kB of archives.
After this operation, 4548 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bookworm/main amd64 libbrotli1 amd64 1.0.9-2+b6 [275 kB]
Get:2 http://deb.debian.org/debian bookworm/main amd64 libsasl2-modules-db amd64 2.1.28+dfsg-10 [20.3 kB]
Get:3 http://deb.debian.org/debian bookworm/main amd64 libsasl2-2 amd64 2.1.28+dfsg-10 [59.7 kB]
Get:4 http://deb.debian.org/debian bookworm/main amd64 libldap-2.5-0 amd64 2.5.13+dfsg-5 [183 kB]
Get:5 http://deb.debian.org/debian bookworm/main amd64 libnghttp2-14 amd64 1.52.0-1+deb12u2 [73.0 kB]
Get:6 http://deb.debian.org/debian bookworm/main amd64 libpsl5 amd64 0.21.2-1 [58.7 kB]
Get:7 http://deb.debian.org/debian bookworm/main amd64 librtmp1 amd64 2.4+20151223.gitfa8646d.1-2+b2 [60.8 kB]
Get:8 http://deb.debian.org/debian bookworm/main amd64 libssh2-1 amd64 1.10.0-3+b1 [179 kB]
Get:9 http://deb.debian.org/debian bookworm/main amd64 libcurl4 amd64 7.88.1-10+deb12u8 [390 kB]
Get:10 http://deb.debian.org/debian bookworm/main amd64 curl amd64 7.88.1-10+deb12u8 [315 kB]
Get:11 http://deb.debian.org/debian bookworm/main amd64 libldap-common all 2.5.13+dfsg-5 [29.3 kB]
Get:12 http://deb.debian.org/debian bookworm/main amd64 libsasl2-modules amd64 2.1.28+dfsg-10 [66.6 kB]
Get:13 http://deb.debian.org/debian bookworm/main amd64 publicsuffix all 20230209.2326-1 [126 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 1837 kB in 0s (9945 kB/s)
Selecting previously unselected package libbrotli1:amd64.
(Reading database ... 6686 files and directories currently installed.)
Preparing to unpack .../00-libbrotli1_1.0.9-2+b6_amd64.deb ...
Unpacking libbrotli1:amd64 (1.0.9-2+b6) ...
Selecting previously unselected package libsasl2-modules-db:amd64.
Preparing to unpack .../01-libsasl2-modules-db_2.1.28+dfsg-10_amd64.deb ...
Unpacking libsasl2-modules-db:amd64 (2.1.28+dfsg-10) ...
Selecting previously unselected package libsasl2-2:amd64.
Preparing to unpack .../02-libsasl2-2_2.1.28+dfsg-10_amd64.deb ...
Unpacking libsasl2-2:amd64 (2.1.28+dfsg-10) ...
Selecting previously unselected package libldap-2.5-0:amd64.
Preparing to unpack .../03-libldap-2.5-0_2.5.13+dfsg-5_amd64.deb ...
Unpacking libldap-2.5-0:amd64 (2.5.13+dfsg-5) ...
Selecting previously unselected package libnghttp2-14:amd64.
Preparing to unpack .../04-libnghttp2-14_1.52.0-1+deb12u2_amd64.deb ...
Unpacking libnghttp2-14:amd64 (1.52.0-1+deb12u2) ...
Selecting previously unselected package libpsl5:amd64.
Preparing to unpack .../05-libpsl5_0.21.2-1_amd64.deb ...
Unpacking libpsl5:amd64 (0.21.2-1) ...
Selecting previously unselected package librtmp1:amd64.
Preparing to unpack .../06-librtmp1_2.4+20151223.gitfa8646d.1-2+b2_amd64.deb ...
Unpacking librtmp1:amd64 (2.4+20151223.gitfa8646d.1-2+b2) ...
Selecting previously unselected package libssh2-1:amd64.
Preparing to unpack .../07-libssh2-1_1.10.0-3+b1_amd64.deb ...
Unpacking libssh2-1:amd64 (1.10.0-3+b1) ...
Selecting previously unselected package libcurl4:amd64.
Preparing to unpack .../08-libcurl4_7.88.1-10+deb12u8_amd64.deb ...
Unpacking libcurl4:amd64 (7.88.1-10+deb12u8) ...
Selecting previously unselected package curl.
Preparing to unpack .../09-curl_7.88.1-10+deb12u8_amd64.deb ...
Unpacking curl (7.88.1-10+deb12u8) ...
Selecting previously unselected package libldap-common.
Preparing to unpack .../10-libldap-common_2.5.13+dfsg-5_all.deb ...
Unpacking libldap-common (2.5.13+dfsg-5) ...
Selecting previously unselected package libsasl2-modules:amd64.
Preparing to unpack .../11-libsasl2-modules_2.1.28+dfsg-10_amd64.deb ...
Unpacking libsasl2-modules:amd64 (2.1.28+dfsg-10) ...
Selecting previously unselected package publicsuffix.
Preparing to unpack .../12-publicsuffix_20230209.2326-1_all.deb ...
Unpacking publicsuffix (20230209.2326-1) ...
Setting up libpsl5:amd64 (0.21.2-1) ...
Setting up libbrotli1:amd64 (1.0.9-2+b6) ...
Setting up libsasl2-modules:amd64 (2.1.28+dfsg-10) ...
Setting up libnghttp2-14:amd64 (1.52.0-1+deb12u2) ...
Setting up libldap-common (2.5.13+dfsg-5) ...
Setting up libsasl2-modules-db:amd64 (2.1.28+dfsg-10) ...
Setting up librtmp1:amd64 (2.4+20151223.gitfa8646d.1-2+b2) ...
Setting up libsasl2-2:amd64 (2.1.28+dfsg-10) ...
Setting up libssh2-1:amd64 (1.10.0-3+b1) ...
Setting up publicsuffix (20230209.2326-1) ...
Setting up libldap-2.5-0:amd64 (2.5.13+dfsg-5) ...
Setting up libcurl4:amd64 (7.88.1-10+deb12u8) ...
Setting up curl (7.88.1-10+deb12u8) ...
Processing triggers for libc-bin (2.36-9+deb12u9) ...
--> 7e415eff2909
STEP 4/10: ADD https://astral.sh/uv/${UV_VERSION}/install.sh /uv-installer.sh
--> 592425776241
STEP 5/10: RUN sh /uv-installer.sh && rm /uv-installer.sh
downloading uv 0.5.29 x86_64-unknown-linux-gnu
no checksums to verify
installing to /root/.local/bin
  uv
  uvx
everything's installed!

To add $HOME/.local/bin to your PATH, either restart your shell or run:

    source $HOME/.local/bin/env (sh, bash, zsh)
    source $HOME/.local/bin/env.fish (fish)
WARNING: The following commands are shadowed by other commands in your PATH: uv uvx
--> e46b2b49ba38
STEP 6/10: ENV PATH="/root/.local/bin/:$PATH"
--> 0b218dc9658f
STEP 7/10: WORKDIR /app
--> bf073778ab1c
STEP 8/10: COPY pyproject.toml hello.py /app/
--> cd0addc326e7
STEP 9/10: RUN uv --version     && uv sync --extra linux --extra linux-cpu
uv 0.5.29
Using CPython 3.12.9 interpreter at: /usr/local/bin/python3
Creating virtual environment at: .venv
   Building tensorrt-cu12-libs==10.8.0.43
      Built tensorrt-cu12-libs==10.8.0.43
Resolved 39 packages in 31.30s
Downloading nvidia-curand-cu12 (53.7MiB)
Downloading sympy (5.9MiB)
Downloading setuptools (1.2MiB)
Downloading nvidia-cusolver-cu12 (122.0MiB)
Downloading nvidia-cusparse-cu12 (197.8MiB)
Downloading nvidia-cudnn-cu12 (634.0MiB)
Downloading nvidia-nvjitlink-cu12 (20.1MiB)
Downloading nvidia-cuda-nvrtc-cu12 (23.5MiB)
Downloading nvidia-cufft-cu12 (201.7MiB)
Downloading nvidia-cusparselt-cu12 (143.1MiB)
Downloading nvidia-cuda-cupti-cu12 (13.2MiB)
Downloading nvidia-cublas-cu12 (346.6MiB)
Downloading networkx (1.6MiB)
Downloading nvidia-nccl-cu12 (179.9MiB)
Downloading numpy (15.4MiB)
Downloading onnxruntime (12.7MiB)
Downloading triton (241.4MiB)
Downloading torch (731.1MiB)
 Downloaded setuptools
 Downloaded networkx
 Downloaded sympy
 Downloaded onnxruntime
 Downloaded nvidia-cuda-cupti-cu12
 Downloaded numpy
 Downloaded nvidia-nvjitlink-cu12
 Downloaded nvidia-cuda-nvrtc-cu12
 Downloaded nvidia-curand-cu12
 Downloaded nvidia-cusolver-cu12
 Downloaded nvidia-cusparselt-cu12
 Downloaded nvidia-nccl-cu12
 Downloaded nvidia-cusparse-cu12
 Downloaded nvidia-cufft-cu12
 Downloaded triton
 Downloaded nvidia-cublas-cu12
 Downloaded nvidia-cudnn-cu12
 Downloaded torch
Prepared 32 packages in 28.88s
Installed 32 packages in 245ms
 + attrs==25.1.0
 + coloredlogs==15.0.1
 + filelock==3.17.0
 + flatbuffers==25.2.10
 + fsspec==2025.2.0
 + humanfriendly==10.0
 + jinja2==3.1.5
 + markupsafe==3.0.2
 + mpmath==1.3.0
 + networkx==3.4.2
 + numpy==2.2.2
 + nvidia-cublas-cu12==12.4.5.8
 + nvidia-cuda-cupti-cu12==12.4.127
 + nvidia-cuda-nvrtc-cu12==12.4.127
 + nvidia-cuda-runtime-cu12==12.4.127
 + nvidia-cudnn-cu12==9.1.0.70
 + nvidia-cufft-cu12==11.2.1.3
 + nvidia-curand-cu12==10.3.5.147
 + nvidia-cusolver-cu12==11.6.1.9
 + nvidia-cusparse-cu12==12.3.1.170
 + nvidia-cusparselt-cu12==0.6.2
 + nvidia-nccl-cu12==2.21.5
 + nvidia-nvjitlink-cu12==12.4.127
 + nvidia-nvtx-cu12==12.4.127
 + onnxruntime==1.20.1
 + packaging==24.2
 + protobuf==5.29.3
 + setuptools==75.8.0
 + sympy==1.13.1
 + torch==2.6.0
 + triton==3.2.0
 + typing-extensions==4.12.2
--> d64138b1a620
STEP 10/10: CMD ["uv", "run", "python", "hello.py"]
COMMIT uv-test-group
--> aa72113428c4
Successfully tagged localhost/uv-test-group:latest
aa72113428c4c4b112f647d6e97a4bf912b4a8dfef26a1033db1daeb38bb2c20

@validatedev
Copy link
Author

Thanks for trying out the examples @zeroepoch 😊

From @charliermarsh in issue astral-sh/uv#11363

Thanks for the clear reproduction. Unfortunately, this is correct behavior. tensorrt-cu12-libs does not publish any wheels (https://pypi.org/project/tensorrt-cu12-libs/#files). And the source distribution they publish uses Metadata 2.1, which tools are not allowed to rely on. So if a tool wants to figure out its dependencies, it must build the package. That's the only way to get the package metadata. And without the package metadata, we can't resolve the dependencies.

In your first example #4352 (comment), as cuda is requested via --extra cuda, you would expect that the packages tensorrt-cu12-libs, tensorrt, tensorrt-cu12, and tensorrt-cu12-bindings are installed in your environment. If wheels are not available, uv should take responsibility for building and installing the package.

However, with the command docker build -f linux-cpu.Dockerfile -t uv-test-group . (#4352 (comment)), you don't even request tensorrt-cu12-libs to be installed. Because the metadata for the package is missing, it tries to build to determine whether the package should be installed. As you can see from the output, tensorrt-cu12-libs is not installed but built. Notice that the other cuda packages, tensorrt, tensorrt-cu12, and tensorrt-cu12-bindings, are not even built in your second example (even some of them do not have the wheels) because they have up-to-date metadata, and uv can determine that these packages shouldn't be installed/built in first place.

If I don't explicitly request uv to install cuda packages via --extra cuda or --group cuda, any of the package shouldn't even built. The only problematic package here is tensorrt-cu12-libs it seems.

I hope this clarifies things.

@charliermarsh
Copy link

Broadly, the goal here is to enable tools to resolve dependencies for these platforms in a way that's decoupled from being able to build or install the wheel. In uv, for example, we generate a lockfile that works across platforms; so even if a tensorrt-cu12-libs dependency is limited to Linux within a given project, users on macOS still want to be able to resolve the dependencies for that package, even if they'll never install it.

The initial thought here was that you could upgrade to Metadata 2.2, then declare the dependencies directly in the stub package. That way, tools could get the tensorrt-cu12-libs dependencies without having to be on a "supported platform".

@zeroepoch
Copy link
Contributor

I think there is context missing here and why this package is explicitly different. The reason the build package is called wheel-stub is because it's a shim for the real package. If you look inside the source package the entire build depends on sending metadata to the wheel-stub package. Wheel-stub fetches this data from the target package on another index to collect the new metadata. I would say this is by design to allow wheel-stub to be generic and at the same time allow us to make installing packages larger than 1GB close to as seamless as if they were natively hosted on pypi.org. Let me check with the authors of wheel-stub to see what they think about this issue.

@charliermarsh
Copy link

👍 I think I understand the stub design, though I believe the question is still relevant: is it possible to allow users to query for the package metadata without being on a platform that has a compatible wheel? As-is, the build step (which is necessary to extract the metadata) errors out if it can't find a compatible wheel (unless I'm mistaken?); but in these workflows, you're not actually looking to install a compatible wheel, you're just attempting to resolve the dependencies.

@zeroepoch
Copy link
Contributor

@charliermarsh that makes sense. More flexibility is always better than less if we can enable it. I'm starting a conversation internally to see what the options are.

@emmatyping-nv
Copy link

@charliermarsh I have two broad thoughts on this:

If wheel-stub implements prepare_metadata_for_build_wheel by just copying the wheel metadata files that should be a surefire way to resolve this for wheel-stub, as you should get the metadata you need without needing to download/build a wheel. I think this is the best solution as it allows wheel-stub to still raise an error when someone tries to install it on an unsupported platform but still work with uv's locking behavior.

I think there is also a wider issue of platform specific sdists gated behind platform specifiers and locking. You cannot be sure that an sdist will build on all platforms, so there are failure modes here which are important. But that would be a better fit for the uv issue tracker, perhaps we can take this discussion there.

@charliermarsh
Copy link

Thanks @emmatyping-nv (and hi)! Yeah, support for prepare_metadata_for_build_wheel would be great. I guess the tricky piece (which dovetails with your second thought) is that if tensorrt-cu12-libs (or any library served via wheel-stub) doesn't guarantee consistent metadata across wheels (which is a uv assumption and not guaranteed by anything in the standards), then what would wheel-stub serve on an unsupported platform?

I guess the question might be moot, since if the metadata isn't consistent across platforms, then users will have a rough time using it with uv regardless.

@emmatyping-nv
Copy link

@charliermarsh hi! :)

Yeah, wheel-stub doesn't currently work with wheels that have divergent metadata across platforms. This could lead to incorrect dependencies being resolved, but there's not much to be done about it. I can only generate one sdist. Perhaps given all of the wheels I could do something clever with environment markers. I've opened wheelnext/wheel-stub#21 to track that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Request for new functionality internal-bug-tracked Tracked internally, will be fixed in a future release. Module:OSS Build Issues building open source code triaged Issue has been triaged by maintainers
Projects
None yet
Development

No branches or pull requests

6 participants