From 4d3b322a7d33f3ec4905ae493d05de17352a069e Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Thu, 18 Dec 2025 17:06:13 -0500 Subject: [PATCH 1/5] Backport #1411 --- .github/ISSUE_TEMPLATE/release_checklist.yml | 1 - .gitignore | 3 +++ cuda_bindings/cuda/bindings/_version.py | 4 ---- cuda_bindings/pyproject.toml | 15 ++++++++++++-- cuda_core/cuda/core/_version.py | 5 ----- cuda_core/pyproject.toml | 14 +++++++++++-- cuda_pathfinder/cuda/pathfinder/_version.py | 4 ---- cuda_pathfinder/pyproject.toml | 9 ++++++++- cuda_python/pyproject.toml | 6 +++++- cuda_python/setup.py | 21 ++++++++++++-------- 10 files changed, 54 insertions(+), 28 deletions(-) delete mode 100644 cuda_bindings/cuda/bindings/_version.py delete mode 100644 cuda_core/cuda/core/_version.py delete mode 100644 cuda_pathfinder/cuda/pathfinder/_version.py diff --git a/.github/ISSUE_TEMPLATE/release_checklist.yml b/.github/ISSUE_TEMPLATE/release_checklist.yml index 2007c3b067..0fa2765797 100644 --- a/.github/ISSUE_TEMPLATE/release_checklist.yml +++ b/.github/ISSUE_TEMPLATE/release_checklist.yml @@ -20,7 +20,6 @@ body: - label: File an internal nvbug to communicate test plan & release schedule with QA - label: Ensure all pending PRs are reviewed, tested, and merged - label: Check (or update if needed) the dependency requirements - - label: Bump the version - label: Create a public rc tag - label: "Point QA to fetch public artifacts (wheels) from the GHA run ID, example: `gh run download 12323257563 -p \"cuda-core*\" -R NVIDIA/cuda-python`" - label: Wait for QA reports and fix any issues found diff --git a/.gitignore b/.gitignore index 64c77d166e..6060df01c2 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,9 @@ cuda_bindings/cuda/bindings/nvrtc.pxd cuda_bindings/cuda/bindings/nvrtc.pyx cuda_bindings/cuda/bindings/utils/_get_handle.pyx +# Version files from setuptools_scm +_version.py + # Distribution / packaging .Python build/ diff --git a/cuda_bindings/cuda/bindings/_version.py b/cuda_bindings/cuda/bindings/_version.py deleted file mode 100644 index c3bd50f87a..0000000000 --- a/cuda_bindings/cuda/bindings/_version.py +++ /dev/null @@ -1,4 +0,0 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE - -__version__ = "12.9.5" diff --git a/cuda_bindings/pyproject.toml b/cuda_bindings/pyproject.toml index 287a6b9425..38e64851df 100644 --- a/cuda_bindings/pyproject.toml +++ b/cuda_bindings/pyproject.toml @@ -2,7 +2,12 @@ # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE [build-system] -requires = ["setuptools>=77.0.0", "cython>=3.2,<3.3", "pyclibrary>=0.1.7"] +requires = [ + "setuptools>=80.0.0", + "setuptools-scm[simple]>=8", + "cython>=3.2,<3.3", + "pyclibrary>=0.1.7" +] build-backend = "setuptools.build_meta" [project] @@ -55,7 +60,6 @@ Documentation = "https://nvidia.github.io/cuda-python/" include = ["cuda*"] [tool.setuptools.dynamic] -version = { attr = "cuda.bindings._version.__version__" } readme = { file = ["DESCRIPTION.rst"], content-type = "text/x-rst" } [tool.ruff] @@ -113,3 +117,10 @@ exclude = ["cuda/bindings/_version.py"] "UP022", "E402", # module level import not at top of file "F841"] # F841 complains about unused variables, but some assignments have side-effects that could be useful for tests (func calls for example) + +[tool.setuptools_scm] +root = ".." +version_file = "cuda/bindings/_version.py" +# We deliberately do not want to include the version suffixes (a/b/rc) in cuda-bindings versioning +tag_regex = "^(?Pv\\d+\\.\\d+\\.\\d+)" +git_describe_command = ["git", "describe", "--dirty", "--tags", "--long", "--match", "v*[0-9]*"] \ No newline at end of file diff --git a/cuda_core/cuda/core/_version.py b/cuda_core/cuda/core/_version.py deleted file mode 100644 index 3ba92949c5..0000000000 --- a/cuda_core/cuda/core/_version.py +++ /dev/null @@ -1,5 +0,0 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# -# SPDX-License-Identifier: Apache-2.0 - -__version__ = "0.3.1" diff --git a/cuda_core/pyproject.toml b/cuda_core/pyproject.toml index 6b1f959ebb..0bc8c2dc80 100644 --- a/cuda_core/pyproject.toml +++ b/cuda_core/pyproject.toml @@ -3,7 +3,11 @@ # SPDX-License-Identifier: Apache-2.0 [build-system] -requires = ["setuptools>=77.0.0", "Cython>=3.1"] +requires = [ + "setuptools>=80.0.0", + "setuptools_scm[simple]>=8", + "Cython>=3.1" +] build-backend = "setuptools.build_meta" @@ -65,7 +69,6 @@ include = ["cuda.core*"] "cuda.core.experimental.include" = ["*.h", "*.hpp", "*.cuh"] [tool.setuptools.dynamic] -version = { attr = "cuda.core._version.__version__" } readme = { file = ["DESCRIPTION.rst"], content-type = "text/x-rst" } [tool.ruff] @@ -106,3 +109,10 @@ exclude = ["cuda/core/_version.py"] [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"] "setup.py" = ["F401"] + +[tool.setuptools_scm] +root = ".." +version_file = "cuda/core/_version.py" +# We deliberately do not want to include the version suffixes (a/b/rc) in cuda-core versioning +tag_regex = "^cuda-core-(?Pv\\d+\\.\\d+\\.\\d+)" +git_describe_command = ["git", "describe", "--dirty", "--tags", "--long", "--match", "cuda-core-v*[0-9]*"] diff --git a/cuda_pathfinder/cuda/pathfinder/_version.py b/cuda_pathfinder/cuda/pathfinder/_version.py deleted file mode 100644 index a41dd93edd..0000000000 --- a/cuda_pathfinder/cuda/pathfinder/_version.py +++ /dev/null @@ -1,4 +0,0 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -__version__ = "1.1.0" diff --git a/cuda_pathfinder/pyproject.toml b/cuda_pathfinder/pyproject.toml index 62c5ee5154..6a6e822f3a 100644 --- a/cuda_pathfinder/pyproject.toml +++ b/cuda_pathfinder/pyproject.toml @@ -58,9 +58,16 @@ version = { attr = "cuda.pathfinder._version.__version__" } readme = { file = ["DESCRIPTION.rst"], content-type = "text/x-rst" } [build-system] -requires = ["setuptools>=64", "wheel"] +requires = ["setuptools>=80", "setuptools_scm[simple]>=8", "wheel"] build-backend = "setuptools.build_meta" +[tool.setuptools_scm] +root = ".." +version_file = "cuda/pathfinder/_version.py" +# We deliberately do not want to include the version suffixes (a/b/rc) in cuda-pathfinder versioning +tag_regex = "^cuda-pathfinder-(?Pv\\d+\\.\\d+\\.\\d+)" +git_describe_command = [ "git", "describe", "--dirty", "--tags", "--long", "--match", "cuda-pathfinder-v*[0-9]*" ] + [tool.ruff] line-length = 120 preview = true diff --git a/cuda_python/pyproject.toml b/cuda_python/pyproject.toml index 15d9b0f9a3..e0a3542df3 100644 --- a/cuda_python/pyproject.toml +++ b/cuda_python/pyproject.toml @@ -3,7 +3,7 @@ # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE [build-system] -requires = ["setuptools>=77.0.0",] +requires = ["setuptools>=80.0.0", "setuptools_scm[simple]>=8"] build-backend = "setuptools.build_meta" [project] @@ -41,3 +41,7 @@ issues = "https://github.com/NVIDIA/cuda-python/issues/" [tool.ruff] line-length = 120 + +# The [tool.setuptools_scm] section is handled in setup.py since we need to +# dynamically set the dependency to cuda_bindings based on the dynamically +# determinded version \ No newline at end of file diff --git a/cuda_python/setup.py b/cuda_python/setup.py index dd84f5579d..b89071c9a0 100644 --- a/cuda_python/setup.py +++ b/cuda_python/setup.py @@ -2,16 +2,21 @@ # # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE -import ast +from packaging.version import Version from setuptools import setup +from setuptools_scm import get_version + +version = get_version( + root="..", + relative_to=__file__, + # We deliberately do not want to include the version suffixes (a/b/rc) in cuda-python versioning + tag_regex="^(?Pv\\d+\\.\\d+\\.\\d+)", + git_describe_command=["git", "describe", "--dirty", "--tags", "--long", "--match", "v*[0-9]*"], +) + + +version = Version(version).base_version -# We want to keep the version in sync with cuda.bindings, but setuptools would not let -# us to refer to any files outside of the project root, so we have to employ our own -# run-time lookup using setup()... -with open("../cuda_bindings/cuda/bindings/_version.py") as f: - for line in f: - if line.startswith("__version__"): - version = ast.parse(line).body[0].value.value setup( version=version, From 56d8a4d224b0956d6494a5409bf24b88849dd22a Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Fri, 19 Dec 2025 09:22:24 -0500 Subject: [PATCH 2/5] Search for cuda_bindings wheel locally --- .github/workflows/test-wheel-linux.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-wheel-linux.yml b/.github/workflows/test-wheel-linux.yml index 0653f99e52..234dfd1c94 100644 --- a/.github/workflows/test-wheel-linux.yml +++ b/.github/workflows/test-wheel-linux.yml @@ -251,8 +251,10 @@ jobs: - name: Ensure cuda-python installable run: | + echo Showing wheels locally in $PWD + ls *.whl if [[ "${{ matrix.LOCAL_CTK }}" == 1 ]]; then - pip install cuda_python*.whl + pip install cuda_python*.whl --find-links . else - pip install $(ls cuda_python*.whl)[all] + pip install $(ls cuda_python*.whl)[all] --find-links . fi From 496886d2a9a1c3b2b4c67686f25dec01325083d7 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Fri, 19 Dec 2025 12:59:41 -0500 Subject: [PATCH 3/5] Secondary fixes --- .github/workflows/test-wheel-linux.yml | 8 ++------ cuda_python/setup.py | 14 +++++++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test-wheel-linux.yml b/.github/workflows/test-wheel-linux.yml index 234dfd1c94..5087da1b1e 100644 --- a/.github/workflows/test-wheel-linux.yml +++ b/.github/workflows/test-wheel-linux.yml @@ -247,14 +247,10 @@ jobs: LOCAL_CTK: ${{ matrix.LOCAL_CTK }} run: run-tests bindings - - - name: Ensure cuda-python installable run: | - echo Showing wheels locally in $PWD - ls *.whl if [[ "${{ matrix.LOCAL_CTK }}" == 1 ]]; then - pip install cuda_python*.whl --find-links . + pip install cuda_python*.whl else - pip install $(ls cuda_python*.whl)[all] --find-links . + pip install $(ls cuda_python*.whl)[all] fi diff --git a/cuda_python/setup.py b/cuda_python/setup.py index b89071c9a0..19fead35a6 100644 --- a/cuda_python/setup.py +++ b/cuda_python/setup.py @@ -15,15 +15,23 @@ ) -version = Version(version).base_version +base_version = Version(version).base_version + + +if base_version == version: + # Tagged release + matcher = "~=" +else: + # Pre-release version + matcher = "==" setup( version=version, install_requires=[ - f"cuda-bindings~={version}", + f"cuda-bindings{matcher}{version}", ], extras_require={ - "all": [f"cuda-bindings[all]~={version}"], + "all": [f"cuda-bindings[all]{matcher}{version}"], }, ) From af189e78dce2d4be58d5092349433e1ae3d10023 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Fri, 19 Dec 2025 13:01:03 -0500 Subject: [PATCH 4/5] Ruff --- cuda_pathfinder/cuda/pathfinder/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cuda_pathfinder/cuda/pathfinder/__init__.py b/cuda_pathfinder/cuda/pathfinder/__init__.py index 6bdeb151ed..77084fc53d 100644 --- a/cuda_pathfinder/cuda/pathfinder/__init__.py +++ b/cuda_pathfinder/cuda/pathfinder/__init__.py @@ -1,10 +1,11 @@ # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +from cuda.pathfinder._version import __version__ as __version__ + from cuda.pathfinder._dynamic_libs.load_dl_common import DynamicLibNotFoundError as DynamicLibNotFoundError from cuda.pathfinder._dynamic_libs.load_dl_common import LoadedDL as LoadedDL from cuda.pathfinder._dynamic_libs.load_nvidia_dynamic_lib import load_nvidia_dynamic_lib as load_nvidia_dynamic_lib from cuda.pathfinder._dynamic_libs.supported_nvidia_libs import ( SUPPORTED_LIBNAMES as SUPPORTED_NVIDIA_LIBNAMES, # noqa: F401 ) -from cuda.pathfinder._version import __version__ as __version__ From 972d998292ffb773ef4caf4f69ab5e735da9024b Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Fri, 19 Dec 2025 13:27:08 -0500 Subject: [PATCH 5/5] Simplify import --- cuda_pathfinder/cuda/pathfinder/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cuda_pathfinder/cuda/pathfinder/__init__.py b/cuda_pathfinder/cuda/pathfinder/__init__.py index 77084fc53d..97c4b70b72 100644 --- a/cuda_pathfinder/cuda/pathfinder/__init__.py +++ b/cuda_pathfinder/cuda/pathfinder/__init__.py @@ -1,7 +1,7 @@ # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from cuda.pathfinder._version import __version__ as __version__ +from cuda.pathfinder._version import __version__ # noqa: F401 from cuda.pathfinder._dynamic_libs.load_dl_common import DynamicLibNotFoundError as DynamicLibNotFoundError from cuda.pathfinder._dynamic_libs.load_dl_common import LoadedDL as LoadedDL