uv icon indicating copy to clipboard operation
uv copied to clipboard

`uv pip install cudaq` fails first time perhaps due to dynamic install_requires

Open PhilReinhold opened this issue 7 months ago • 4 comments

Summary

In a fresh venv from uv venv.

$ uv pip install cudaq
Resolved 1 package in 2ms
Installed 1 package in 1ms
 + cudaq==0.10.0

# missing all dependencies!
# Just run it twice though...

$ uv pip install cudaq
Resolved 24 packages in 9ms
Installed 23 packages in 69ms
 + astpretty==3.0.0
 + certifi==2025.1.31
 + charset-normalizer==3.4.1
 + cuda-quantum-cu12==0.10.0
 + cudensitymat-cu12==0.1.0
 + cupy-cuda12x==13.4.1
 + cuquantum-python-cu12==25.3.0
 + custatevec-cu12==1.8.0
 + cutensor-cu12==2.2.0
 + cutensornet-cu12==2.7.0
 + fastrlock==0.8.3
 + idna==3.10
 + numpy==2.2.4
 + nvidia-cublas-cu12==12.8.4.1
 + nvidia-cuda-nvrtc-cu12==12.8.93
 + nvidia-cuda-runtime-cu12==12.8.90
 + nvidia-curand-cu12==10.3.9.90
 + nvidia-cusolver-cu12==11.7.3.90
 + nvidia-cusparse-cu12==12.5.8.93
 + nvidia-nvjitlink-cu12==12.8.93
 + requests==2.32.3
 + scipy==1.15.2
 + urllib3==2.3.0

If I instead use regular pip install (with or without --use-pep517), it works the first time.

This appears to manifest in uv add as well, although I haven't tested as much there. I suspect this has something to do with the fact that cudaq only provides an sdist, with a setup.py that dynamically calculates install_requires based on environment, see https://github.com/NVIDIA/cuda-quantum/tree/main/python/metapackages.

Platform

Linux 6.1.119-129.201.amzn2023.x86_64 x86_64 GNU/Linux

Version

uv 0.5.20

Python version

Python 3.11.11

PhilReinhold avatar Apr 08 '25 19:04 PhilReinhold

Hmm, I think this is a problem with the package. If you look at the sdist's PKG-INFO file:

Metadata-Version: 2.2
Name: cudaq
Version: 0.10.0
Summary: Python bindings for the CUDA-Q toolkit for heterogeneous quantum-classical workflows.
Author: NVIDIA Corporation & Affiliates
Maintainer: NVIDIA Corporation & Affiliates
License: Apache License Version 2.0
        
        Copyright (c) 2023 - 2025 NVIDIA Corporation & Affiliates
        All rights reserved.
        
        Licensed under the Apache License, Version 2.0 (the "License");
        you may not use this file except in compliance with the License.
        You may obtain a copy of the License at
        
            http://www.apache.org/licenses/LICENSE-2.0
        
        Unless required by applicable law or agreed to in writing, software
        distributed under the License is distributed on an "AS IS" BASIS,
        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        See the License for the specific language governing permissions and
        limitations under the License.
        
Project-URL: Homepage, https://developer.nvidia.com/cuda-q
Project-URL: Documentation, https://nvidia.github.io/cuda-quantum
Project-URL: Repository, https://github.com/NVIDIA/cuda-quantum
Project-URL: Releases, https://nvidia.github.io/cuda-quantum/latest/releases.html
Keywords: cudaq,cuda-quantum,cuda,quantum,quantum computing,nvidia,high-performance computing
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Environment :: GPU :: NVIDIA CUDA
Classifier: Environment :: GPU :: NVIDIA CUDA :: 11
Classifier: Environment :: GPU :: NVIDIA CUDA :: 12
Classifier: Topic :: Software Development
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
License-File: CITATION.cff
Provides-Extra: chemistry
Requires-Dist: scipy==1.10.1; extra == "chemistry"
Requires-Dist: openfermionpyscf==0.5; extra == "chemistry"
Requires-Dist: h5py<3.11; extra == "chemistry"
Provides-Extra: visualization
Requires-Dist: qutip<5; extra == "visualization"
Requires-Dist: matplotlib>=3.5; extra == "visualization"

It uses Metadata 2.2, so we are "allowed" to trust it. But it doens't include the dependencies. And it doesn't declare the requires-dist as dynamic.

After we build the wheel, subsequent invocations use the metdata from the built wheel, which does include the dependencies.

I think the source distribution should be marking its requirements as dynamic?

charliermarsh avatar Apr 08 '25 20:04 charliermarsh

Question. I'm having this issue (I think) in my PR. https://github.com/unitaryfoundation/mitiq/pull/2839

Anything I can do to get cudaq to install on the Ubuntu venv? It's a Linux x86 only wheel by the way, so won't work on macos nor windows.

ACE07-Sev avatar Nov 16 '25 09:11 ACE07-Sev

You can use https://docs.astral.sh/uv/reference/settings/#dependency-metadata as escape hatch, but really it's something cudaq needs to fix.

konstin avatar Nov 18 '25 15:11 konstin

Thanks for reporting it. I'll see about fixing this in cudaq.

lmondada avatar Nov 19 '25 16:11 lmondada