From e9d34abca14e27200698298c12a9e05b0000dfc8 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 10 Jun 2024 11:35:10 -0500 Subject: [PATCH] use rapids-build-backend (#88) Contributes to https://github.com/rapidsai/build-planning/issues/31 Contributes to https://github.com/rapidsai/dependency-file-generator/issues/89 Proposes introducing `rapids-build-backend` as this project's build backend, to reduce the complexity of various CI/build scripts. --------- Co-authored-by: Bradley Dice --- .github/workflows/build.yaml | 8 ++++---- .github/workflows/pr.yaml | 14 +++++++------- ci/build_wheel.sh | 7 ------- conda/recipes/pynvjitlink/meta.yaml | 1 + dependencies.yaml | 1 + pynvjitlink/__init__.py | 9 +++++++-- pynvjitlink/_version.py | 14 +++++++++++++- pynvjitlink/tests/test_version.py | 12 ++++++++++++ pyproject.toml | 7 ++++++- 9 files changed, 51 insertions(+), 22 deletions(-) create mode 100644 pynvjitlink/tests/test_version.py diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index bff8737..e4fd194 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -23,7 +23,7 @@ jobs: build-wheels: needs: - compute-matrix - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.08 with: build_type: branch script: "ci/build_wheel.sh" @@ -31,7 +31,7 @@ jobs: build-conda: needs: - compute-matrix - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.08 with: build_type: branch script: "ci/build_conda.sh" @@ -40,7 +40,7 @@ jobs: needs: - build-wheels secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -51,7 +51,7 @@ jobs: needs: - build-conda secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index b609a27..4179058 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -21,10 +21,10 @@ jobs: - test-wheels - test-patch secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.08 checks: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.08 with: enable_check_generated_files: false compute-matrix: @@ -40,7 +40,7 @@ jobs: build-conda: needs: - compute-matrix - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.08 with: build_type: pull-request script: "ci/build_conda.sh" @@ -49,7 +49,7 @@ jobs: needs: - build-conda - compute-matrix - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.08 with: build_type: pull-request script: "ci/test_conda.sh" @@ -58,7 +58,7 @@ jobs: needs: - build-conda - compute-matrix - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.08 with: build_type: pull-request script: "ci/test_patch.sh" @@ -67,7 +67,7 @@ jobs: build-wheels: needs: - compute-matrix - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.08 with: build_type: pull-request script: "ci/build_wheel.sh" @@ -76,7 +76,7 @@ jobs: needs: - build-wheels - compute-matrix - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.08 with: build_type: pull-request script: "ci/test_wheel.sh" diff --git a/ci/build_wheel.sh b/ci/build_wheel.sh index ce6a8c0..3c5cc86 100755 --- a/ci/build_wheel.sh +++ b/ci/build_wheel.sh @@ -8,13 +8,6 @@ source "$(dirname "$0")/install_latest_cuda_toolkit.sh" RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" -# This is the version of the suffix with a preceding hyphen. It's used -# everywhere except in the final wheel name. -PACKAGE_CUDA_SUFFIX="-${RAPIDS_PY_CUDA_SUFFIX}" - -# Patch project metadata files to include the CUDA version suffix. -sed -i "s/^name = \"pynvjitlink\"/name = \"pynvjitlink${PACKAGE_CUDA_SUFFIX}\"/g" pyproject.toml - rapids-logger "Build wheel" mkdir -p ./dist python -m pip wheel . --wheel-dir=./dist -vvv --disable-pip-version-check --no-deps diff --git a/conda/recipes/pynvjitlink/meta.yaml b/conda/recipes/pynvjitlink/meta.yaml index 094cd32..3154a23 100644 --- a/conda/recipes/pynvjitlink/meta.yaml +++ b/conda/recipes/pynvjitlink/meta.yaml @@ -36,6 +36,7 @@ requirements: - cuda-version {{ cuda_compiler_version }} - python - pip + - rapids-build-backend >=0.3.0,<0.4.0dev0 - scikit-build-core run: - python diff --git a/dependencies.yaml b/dependencies.yaml index d5fd5f6..b27ea0d 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -43,6 +43,7 @@ dependencies: common: - output_types: [requirements, pyproject] packages: + - rapids-build-backend >=0.3.0,<0.4.0dev0 - scikit-build-core[pyproject]>=0.7.0 checks: common: diff --git a/pynvjitlink/__init__.py b/pynvjitlink/__init__.py index f56442f..bd761ce 100644 --- a/pynvjitlink/__init__.py +++ b/pynvjitlink/__init__.py @@ -1,6 +1,11 @@ # Copyright (c) 2023-2024, NVIDIA CORPORATION. from pynvjitlink.api import NvJitLinker, NvJitLinkError -from pynvjitlink._version import __version__ +from pynvjitlink._version import __git_commit__, __version__ -__all__ = ["NvJitLinker", "NvJitLinkError", "__version__"] +__all__ = [ + "NvJitLinkError", + "NvJitLinker", + "__git_commit__", + "__version__", +] diff --git a/pynvjitlink/_version.py b/pynvjitlink/_version.py index ef63329..4aa14fa 100644 --- a/pynvjitlink/_version.py +++ b/pynvjitlink/_version.py @@ -15,5 +15,17 @@ import importlib.resources __version__ = ( - importlib.resources.files("pynvjitlink").joinpath("VERSION").read_text().strip() + importlib.resources.files(__package__).joinpath("VERSION").read_text().strip() ) + +try: + __git_commit__ = ( + importlib.resources.files(__package__) + .joinpath("GIT_COMMIT") + .read_text() + .strip() + ) +except FileNotFoundError: + __git_commit__ = "" + +__all__ = ["__git_commit__", "__version__"] diff --git a/pynvjitlink/tests/test_version.py b/pynvjitlink/tests/test_version.py new file mode 100644 index 0000000..a281691 --- /dev/null +++ b/pynvjitlink/tests/test_version.py @@ -0,0 +1,12 @@ +# Copyright (c) 2024, NVIDIA CORPORATION. + +import pynvjitlink + + +def test_version_constants_are_populated(): + # __git_commit__ will only be non-empty in a built distribution + assert isinstance(pynvjitlink.__git_commit__, str) + + # __version__ should always be non-empty + assert isinstance(pynvjitlink.__version__, str) + assert len(pynvjitlink.__version__) > 0 diff --git a/pyproject.toml b/pyproject.toml index fddf3fa..282026b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,9 @@ # Copyright (c) 2023-2024, NVIDIA CORPORATION. All rights reserved. +[tool.rapids-build-backend] +build-backend = "scikit_build_core.build" +dependencies-file = "dependencies.yaml" + [tool.scikit-build] cmake.minimum-version = "3.26.4" cmake.verbose = true @@ -9,9 +13,10 @@ wheel.packages = ["pynvjitlink"] [build-system] requires = [ + "rapids-build-backend >=0.3.0,<0.4.0dev0", "scikit-build-core[pyproject]>=0.7.0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit dependencies.yaml and run `rapids-dependency-file-generator`. -build-backend = "scikit_build_core.build" +build-backend = "rapids_build_backend.build" [project] name = "pynvjitlink"