From 23d48a9d762ca5a444c4815fa7406d113ef8b915 Mon Sep 17 00:00:00 2001 From: Keith Kraus Date: Thu, 15 May 2025 10:12:48 -0400 Subject: [PATCH 1/6] Move dependencies from requirements.txt to an optional packaging extra Signed-off-by: Keith Kraus --- .github/workflows/test-wheel-linux.yml | 2 +- .github/workflows/test-wheel-windows.yml | 2 +- cuda_bindings/README.md | 2 +- cuda_bindings/pyproject.toml | 9 ++++++++- cuda_bindings/requirements.txt | 11 ----------- 5 files changed, 11 insertions(+), 15 deletions(-) delete mode 100644 cuda_bindings/requirements.txt diff --git a/.github/workflows/test-wheel-linux.yml b/.github/workflows/test-wheel-linux.yml index 037adf71db..4763846229 100644 --- a/.github/workflows/test-wheel-linux.yml +++ b/.github/workflows/test-wheel-linux.yml @@ -324,8 +324,8 @@ jobs: fi popd + pip install $(ls *.whl)[test] pushd ./cuda_bindings - pip install -r requirements.txt ${SANITIZER_CMD} pytest -rxXs -v tests/ # It is a bit convoluted to run the Cython tests against CTK wheels, diff --git a/.github/workflows/test-wheel-windows.yml b/.github/workflows/test-wheel-windows.yml index 4473ad8392..8ff06af7cc 100644 --- a/.github/workflows/test-wheel-windows.yml +++ b/.github/workflows/test-wheel-windows.yml @@ -252,8 +252,8 @@ jobs: } Pop-Location + pip install "$((Get-ChildItem -Filter *.whl).FullName)[test]" Push-Location ./cuda_bindings - pip install -r requirements.txt pytest -rxXs -v tests/ # skip Cython tests for now (NVIDIA/cuda-python#466) Pop-Location diff --git a/cuda_bindings/README.md b/cuda_bindings/README.md index 800de17f7a..a0657706d0 100644 --- a/cuda_bindings/README.md +++ b/cuda_bindings/README.md @@ -12,7 +12,7 @@ This subpackage adheres to the developing practices described in the parent meta ## Testing -Latest dependencies can be found in [requirements.txt](https://github.com/NVIDIA/cuda-python/blob/main/cuda_bindings/requirements.txt). +Testing dependencies can be installed using the `[test]` optional dependency identifier. For example, `pip install -v -e .[test]`. Multiple testing options are available: diff --git a/cuda_bindings/pyproject.toml b/cuda_bindings/pyproject.toml index e13dc015c7..e2020437ac 100644 --- a/cuda_bindings/pyproject.toml +++ b/cuda_bindings/pyproject.toml @@ -2,7 +2,7 @@ # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE [build-system] -requires = ["setuptools>=77.0.0", "cython", "pyclibrary"] +requires = ["setuptools>=77.0.0", "cython>=3.0", "pyclibrary>=0.1.7"] build-backend = "setuptools.build_meta" [project] @@ -37,6 +37,13 @@ all = [ "nvidia-nvjitlink-cu12>=12.3", ] +tests = [ + "numpy>=1.21.1", + "pytest>=6.2.4", + "pytest-benchmark>=3.4.1", + "llvmlite" +] + [project.urls] Repository = "https://github.com/NVIDIA/cuda-python" Documentation = "https://nvidia.github.io/cuda-python/" diff --git a/cuda_bindings/requirements.txt b/cuda_bindings/requirements.txt deleted file mode 100644 index 09041ba1ff..0000000000 --- a/cuda_bindings/requirements.txt +++ /dev/null @@ -1,11 +0,0 @@ -Cython>=3.0.0 -pytest>=6.2.4 -pytest-benchmark>=3.4.1 -numpy>=1.21.1 -pyclibrary>=0.1.7 -setuptools -tomli; python_version < "3.11" -versioneer==0.29 -wheel -pywin32; sys_platform == 'win32' -# llvmlite # Uncomment to generate MINIMAL_NVVMIR_BITCODE_STATIC for test_nvvm.py (see PR #443). From 6018239b0e4dbbbf23b73d4c1ca22b209d39470c Mon Sep 17 00:00:00 2001 From: Keith Kraus Date: Thu, 15 May 2025 11:09:38 -0400 Subject: [PATCH 2/6] move cuda_core test requirements to pyproject.toml optional dependencies as well Signed-off-by: Keith Kraus --- .github/workflows/test-wheel-linux.yml | 8 +++----- .github/workflows/test-wheel-windows.yml | 8 +++----- cuda_bindings/pyproject.toml | 2 +- cuda_core/pyproject.toml | 3 +++ cuda_core/tests/requirements-cu11.txt | 4 ---- cuda_core/tests/requirements-cu12.txt | 4 ---- 6 files changed, 10 insertions(+), 19 deletions(-) delete mode 100644 cuda_core/tests/requirements-cu11.txt delete mode 100644 cuda_core/tests/requirements-cu12.txt diff --git a/.github/workflows/test-wheel-linux.yml b/.github/workflows/test-wheel-linux.yml index 4763846229..11c6460890 100644 --- a/.github/workflows/test-wheel-linux.yml +++ b/.github/workflows/test-wheel-linux.yml @@ -318,13 +318,12 @@ jobs: pushd "${CUDA_BINDINGS_ARTIFACTS_DIR}" if [[ "${{ matrix.LOCAL_CTK }}" == 1 ]]; then ls $CUDA_PATH - pip install *.whl + pip install *.whl[test] else - pip install $(ls *.whl)[all] + pip install $(ls *.whl)[all,test] fi popd - pip install $(ls *.whl)[test] pushd ./cuda_bindings ${SANITIZER_CMD} pytest -rxXs -v tests/ @@ -356,11 +355,10 @@ jobs: fi TEST_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${{ matrix.CUDA_VER }})" pushd "${CUDA_CORE_ARTIFACTS_DIR}" - pip install $(ls *.whl)["cu${TEST_CUDA_MAJOR}"] + pip install $(ls *.whl)["cu${TEST_CUDA_MAJOR}","test-cu${TEST_CUDA_MAJOR}"] popd pushd ./cuda_core - pip install -r "tests/requirements-cu${TEST_CUDA_MAJOR}.txt" ${SANITIZER_CMD} pytest -rxXs -v tests/ # It is a bit convoluted to run the Cython tests against CTK wheels, diff --git a/.github/workflows/test-wheel-windows.yml b/.github/workflows/test-wheel-windows.yml index 8ff06af7cc..09b2b69adc 100644 --- a/.github/workflows/test-wheel-windows.yml +++ b/.github/workflows/test-wheel-windows.yml @@ -246,13 +246,12 @@ jobs: if ('${{ matrix.LOCAL_CTK }}' -eq '1') { Get-ChildItem $env:CUDA_PATH echo $PATH - pip install (Get-ChildItem -Filter *.whl).FullName + pip install "$((Get-ChildItem -Filter *.whl).FullName)[test]" } else { - pip install "$((Get-ChildItem -Filter *.whl).FullName)[all]" + pip install "$((Get-ChildItem -Filter *.whl).FullName)[all,test]" } Pop-Location - pip install "$((Get-ChildItem -Filter *.whl).FullName)[test]" Push-Location ./cuda_bindings pytest -rxXs -v tests/ # skip Cython tests for now (NVIDIA/cuda-python#466) @@ -273,11 +272,10 @@ jobs: } $TEST_CUDA_MAJOR = '${{ matrix.CUDA_VER }}' -split '\.' | Select-Object -First 1 Push-Location $env:CUDA_CORE_ARTIFACTS_DIR - pip install "$((Get-ChildItem -Filter *.whl).FullName)[cu${TEST_CUDA_MAJOR}]" + pip install "$((Get-ChildItem -Filter *.whl).FullName)[cu${TEST_CUDA_MAJOR},test-cu${TEST_CUDA_MAJOR}]" Pop-Location Push-Location ./cuda_core - pip install -r "tests/requirements-cu${TEST_CUDA_MAJOR}.txt" pytest -rxXs -v tests/ Pop-Location diff --git a/cuda_bindings/pyproject.toml b/cuda_bindings/pyproject.toml index e2020437ac..bd8f05ade5 100644 --- a/cuda_bindings/pyproject.toml +++ b/cuda_bindings/pyproject.toml @@ -37,7 +37,7 @@ all = [ "nvidia-nvjitlink-cu12>=12.3", ] -tests = [ +test = [ "numpy>=1.21.1", "pytest>=6.2.4", "pytest-benchmark>=3.4.1", diff --git a/cuda_core/pyproject.toml b/cuda_core/pyproject.toml index 40b4130983..c828c512da 100644 --- a/cuda_core/pyproject.toml +++ b/cuda_core/pyproject.toml @@ -48,6 +48,9 @@ dependencies = [ [project.optional-dependencies] cu11 = ["cuda-bindings==11.8.*"] cu12 = ["cuda-bindings==12.*"] +test = ["pytest>=6.2.4"] +test-cu11 = ["cuda-core[test]", "cupy-cuda11x", "nvidia-cuda-runtime-cu11"] # runtime headers needed by CuPy +test-cu12 = ["cuda-core[test]", "cupy-cuda12x", "nvidia-cuda-runtime-cu12"] # runtime headers needed by CuPy [project.urls] homepage = "https://nvidia.github.io/cuda-python/" diff --git a/cuda_core/tests/requirements-cu11.txt b/cuda_core/tests/requirements-cu11.txt deleted file mode 100644 index d9bd566c76..0000000000 --- a/cuda_core/tests/requirements-cu11.txt +++ /dev/null @@ -1,4 +0,0 @@ -pytest -# TODO: remove this hack once cupy has a cp313 build -cupy-cuda11x; python_version < "3.13" -nvidia-cuda-runtime-cu11 # headers consumed by CuPy diff --git a/cuda_core/tests/requirements-cu12.txt b/cuda_core/tests/requirements-cu12.txt deleted file mode 100644 index 18f6736033..0000000000 --- a/cuda_core/tests/requirements-cu12.txt +++ /dev/null @@ -1,4 +0,0 @@ -pytest -# TODO: remove this hack once cupy has a cp313 build -cupy-cuda12x; python_version < "3.13" -nvidia-cuda-runtime-cu12 # headers consumed by CuPy From c5a4956b529621f7737502292288efe617c9fb14 Mon Sep 17 00:00:00 2001 From: Keith Kraus Date: Thu, 15 May 2025 13:01:12 -0400 Subject: [PATCH 3/6] Need to expand wildcard to use the bracket syntax Co-authored-by: Leo Fang --- .github/workflows/test-wheel-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-wheel-linux.yml b/.github/workflows/test-wheel-linux.yml index 11c6460890..a78a9d6117 100644 --- a/.github/workflows/test-wheel-linux.yml +++ b/.github/workflows/test-wheel-linux.yml @@ -318,7 +318,7 @@ jobs: pushd "${CUDA_BINDINGS_ARTIFACTS_DIR}" if [[ "${{ matrix.LOCAL_CTK }}" == 1 ]]; then ls $CUDA_PATH - pip install *.whl[test] + pip install $(ls *.whl)[test] else pip install $(ls *.whl)[all,test] fi From 4e5ea46713091e82f1a348f1b2951af870dc6d2a Mon Sep 17 00:00:00 2001 From: Keith Kraus Date: Thu, 15 May 2025 15:02:37 -0400 Subject: [PATCH 4/6] Add cython to test dependencies for now --- cuda_bindings/pyproject.toml | 1 + cuda_core/pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cuda_bindings/pyproject.toml b/cuda_bindings/pyproject.toml index bd8f05ade5..284448accb 100644 --- a/cuda_bindings/pyproject.toml +++ b/cuda_bindings/pyproject.toml @@ -38,6 +38,7 @@ all = [ ] test = [ + "cython>=3.0", "numpy>=1.21.1", "pytest>=6.2.4", "pytest-benchmark>=3.4.1", diff --git a/cuda_core/pyproject.toml b/cuda_core/pyproject.toml index c828c512da..d988741ced 100644 --- a/cuda_core/pyproject.toml +++ b/cuda_core/pyproject.toml @@ -48,7 +48,7 @@ dependencies = [ [project.optional-dependencies] cu11 = ["cuda-bindings==11.8.*"] cu12 = ["cuda-bindings==12.*"] -test = ["pytest>=6.2.4"] +test = ["cython>=3.0", "pytest>=6.2.4"] test-cu11 = ["cuda-core[test]", "cupy-cuda11x", "nvidia-cuda-runtime-cu11"] # runtime headers needed by CuPy test-cu12 = ["cuda-core[test]", "cupy-cuda12x", "nvidia-cuda-runtime-cu12"] # runtime headers needed by CuPy From eb077246ca214db824a3b6fbaf1f5933cb87fc1c Mon Sep 17 00:00:00 2001 From: Keith Kraus Date: Thu, 15 May 2025 16:04:25 -0400 Subject: [PATCH 5/6] add missing distutils dependency, used in cython files directives --- cuda_bindings/pyproject.toml | 1 + cuda_core/pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cuda_bindings/pyproject.toml b/cuda_bindings/pyproject.toml index 284448accb..8118cc2a2c 100644 --- a/cuda_bindings/pyproject.toml +++ b/cuda_bindings/pyproject.toml @@ -39,6 +39,7 @@ all = [ test = [ "cython>=3.0", + "distutils", "numpy>=1.21.1", "pytest>=6.2.4", "pytest-benchmark>=3.4.1", diff --git a/cuda_core/pyproject.toml b/cuda_core/pyproject.toml index d988741ced..9faede16c0 100644 --- a/cuda_core/pyproject.toml +++ b/cuda_core/pyproject.toml @@ -48,7 +48,7 @@ dependencies = [ [project.optional-dependencies] cu11 = ["cuda-bindings==11.8.*"] cu12 = ["cuda-bindings==12.*"] -test = ["cython>=3.0", "pytest>=6.2.4"] +test = ["cython>=3.0", "distutils", "pytest>=6.2.4"] test-cu11 = ["cuda-core[test]", "cupy-cuda11x", "nvidia-cuda-runtime-cu11"] # runtime headers needed by CuPy test-cu12 = ["cuda-core[test]", "cupy-cuda12x", "nvidia-cuda-runtime-cu12"] # runtime headers needed by CuPy From d5e0d313c0a73d8713193d4fab9018d60ca04588 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Thu, 15 May 2025 20:26:34 -0400 Subject: [PATCH 6/6] distutils is part of setuptools --- cuda_bindings/pyproject.toml | 2 +- cuda_core/pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cuda_bindings/pyproject.toml b/cuda_bindings/pyproject.toml index 8118cc2a2c..f1a97e8069 100644 --- a/cuda_bindings/pyproject.toml +++ b/cuda_bindings/pyproject.toml @@ -39,7 +39,7 @@ all = [ test = [ "cython>=3.0", - "distutils", + "setuptools", "numpy>=1.21.1", "pytest>=6.2.4", "pytest-benchmark>=3.4.1", diff --git a/cuda_core/pyproject.toml b/cuda_core/pyproject.toml index 9faede16c0..8518a2e282 100644 --- a/cuda_core/pyproject.toml +++ b/cuda_core/pyproject.toml @@ -48,7 +48,7 @@ dependencies = [ [project.optional-dependencies] cu11 = ["cuda-bindings==11.8.*"] cu12 = ["cuda-bindings==12.*"] -test = ["cython>=3.0", "distutils", "pytest>=6.2.4"] +test = ["cython>=3.0", "setuptools", "pytest>=6.2.4"] test-cu11 = ["cuda-core[test]", "cupy-cuda11x", "nvidia-cuda-runtime-cu11"] # runtime headers needed by CuPy test-cu12 = ["cuda-core[test]", "cupy-cuda12x", "nvidia-cuda-runtime-cu12"] # runtime headers needed by CuPy