From 064ab969b4136ae23c8800b06510f584f2d314fc Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 5 Jun 2024 15:40:46 -0700 Subject: [PATCH] use rapids-build-backend --- ci/build_wheel.sh | 9 +-------- conda/recipes/pynvjitlink/meta.yaml | 1 + dependencies.yaml | 1 + pynvjitlink/_version.py | 14 +++++++++++++- pynvjitlink/tests/test_version.py | 12 ++++++++++++ pyproject.toml | 7 ++++++- 6 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 pynvjitlink/tests/test_version.py diff --git a/ci/build_wheel.sh b/ci/build_wheel.sh index ce6a8c0..923244d 100755 --- a/ci/build_wheel.sh +++ b/ci/build_wheel.sh @@ -8,14 +8,7 @@ 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" +rapids-logger "Build wheel"s 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/_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"