Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
use rapids-build-backend
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Jun 4, 2024
1 parent 00365ee commit 244d516
Show file tree
Hide file tree
Showing 17 changed files with 82 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ repos:
types_or: [c, c++, cuda]
args: ["-fallback-style=none", "-style=file", "-i"]
- repo: https://github.com/rapidsai/dependency-file-generator
rev: v1.11.0
rev: v1.13.11
hooks:
- id: rapids-dependency-file-generator
args: ["--clean"]
Expand Down
6 changes: 5 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,11 @@ if buildAll || hasArg pylibwholegraph; then
if ! hasArg --compile-cmd; then
cd ${REPODIR}/python/pylibwholegraph
env LIBWHOLEGRAPH_DIR=${LIBWHOLEGRAPH_DIR} \
SKBUILD_CMAKE_ARGS="-DCMAKE_BUILD_TYPE=${BUILD_TYPE};${EXTRA_CMAKE_ARGS/ /;}" ${PYTHON} -m pip install --no-build-isolation --no-deps .
SKBUILD_CMAKE_ARGS="-DCMAKE_BUILD_TYPE=${BUILD_TYPE};${EXTRA_CMAKE_ARGS/ /;}" ${PYTHON} -m pip install \
--no-build-isolation \
--no-deps \
--config-settings rapidsai.disable-cuda=true \
.

else
# just invoke cmake without going through scikit-build-core
Expand Down
2 changes: 1 addition & 1 deletion ci/build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ rapids-logger "Create test conda environment"

rapids-dependency-file-generator \
--output conda \
--file_key docs \
--file-key docs \
--matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee env.yaml

rapids-mamba-retry env create --yes -f env.yaml -n docs
Expand Down
11 changes: 3 additions & 8 deletions ci/build_python.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
# Copyright (c) 2022-2024, NVIDIA CORPORATION.

set -euo pipefail

Expand All @@ -17,19 +17,14 @@ PACKAGES="libwholegraph"

CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp)

version=$(rapids-generate-version)
git_commit=$(git rev-parse HEAD)
export RAPIDS_PACKAGE_VERSION=${version}
echo "${version}" > VERSION
rapids-generate-version > ./VERSION

rapids-logger "Begin py build"

# TODO: Remove `--no-test` flags once importing on a CPU
# node works correctly
rapids-logger "Begin pylibwholegraph build"
version_file_pylibwholegraph="python/pylibwholegraph/pylibwholegraph/_version.py"
sed -i "/^__git_commit__/ s/= .*/= \"${git_commit}\"/g" ${version_file_pylibwholegraph}
rapids-conda-retry mambabuild \
RAPIDS_PACKAGE_VERSION=$(head -1 ./VERSION) rapids-conda-retry mambabuild \
--no-test \
--channel "${CPP_CHANNEL}" \
conda/recipes/pylibwholegraph
Expand Down
24 changes: 1 addition & 23 deletions ci/build_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,10 @@ package_dir="python/pylibwholegraph"
source rapids-configure-sccache
source rapids-date-string

version=$(rapids-generate-version)
git_commit=$(git rev-parse HEAD)
rapids-generate-version > ./VERSION

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 and version override.
pyproject_file="${package_dir}/pyproject.toml"
version_file="${package_dir}/${package_name}/_version.py"

sed -i "s/name = \"${package_name}\"/name = \"${package_name}${PACKAGE_CUDA_SUFFIX}\"/g" ${pyproject_file}
echo "${version}" > VERSION
sed -i "/^__git_commit__ / s/= .*/= \"${git_commit}\"/g" ${version_file}

# For nightlies we want to ensure that we're pulling in alphas as well. The
# easiest way to do so is to augment the spec with a constraint containing a
# min alpha version that doesn't affect the version bounds but does allow usage
# of alpha versions for that dependency without --pre
alpha_spec=''
if ! rapids-is-release-build; then
alpha_spec=',>=0.0.0a0'
fi

cd "${package_dir}"

# Hardcode the output dir
Expand Down
2 changes: 1 addition & 1 deletion ci/check_style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ rapids-logger "Create checks conda environment"

rapids-dependency-file-generator \
--output conda \
--file_key checks \
--file-key checks \
--matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee env.yaml

rapids-mamba-retry env create --yes -f env.yaml -n checks
Expand Down
6 changes: 3 additions & 3 deletions ci/release/update-version.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (c) 2018-2023, NVIDIA CORPORATION.
# Copyright (c) 2018-2024, NVIDIA CORPORATION.
# 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
Expand Down Expand Up @@ -68,10 +68,10 @@ DEPENDENCIES=(
)
for DEP in "${DEPENDENCIES[@]}"; do
for FILE in dependencies.yaml conda/environments/*.yaml; do
sed_runner "/-.* ${DEP}\(-cu[[:digit:]]\{2\}\)\{0,1\}==/ s/==.*/==${NEXT_SHORT_TAG_PEP440}.*/g" ${FILE}
sed_runner "/-.* ${DEP}\(-cu[[:digit:]]\{2\}\)\{0,1\}==/ s/==.*/==${NEXT_SHORT_TAG_PEP440}.*,>=0.0.0a0/g" ${FILE}
done
for FILE in python/**/pyproject.toml; do
sed_runner "/\"${DEP}\(-cu[[:digit:]]\{2\}\)\{0,1\}==/ s/==.*\"/==${NEXT_SHORT_TAG_PEP440}.*\"/g" ${FILE}
sed_runner "/\"${DEP}\(-cu[[:digit:]]\{2\}\)\{0,1\}==/ s/==.*\"/==${NEXT_SHORT_TAG_PEP440}.*,>=0.0.0a0\"/g" ${FILE}
done
done

Expand Down
2 changes: 1 addition & 1 deletion ci/test_clang_tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ rapids-logger "Create clang-tidy conda environment"
rapids-logger "Generate clang-tidy testing dependencies"
rapids-dependency-file-generator \
--output conda \
--file_key clang_tidy \
--file-key clang_tidy \
--matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch)" | tee env.yaml

rapids-mamba-retry env create --yes -f env.yaml -n clang_tidy
Expand Down
2 changes: 1 addition & 1 deletion ci/test_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../
rapids-logger "Generate C++ testing dependencies"
rapids-dependency-file-generator \
--output conda \
--file_key test_cpp \
--file-key test_cpp \
--matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch)" | tee env.yaml

rapids-mamba-retry env create --yes -f env.yaml -n test
Expand Down
2 changes: 1 addition & 1 deletion ci/test_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fi
rapids-logger "Generate Python testing dependencies"
rapids-dependency-file-generator \
--output conda \
--file_key test_python \
--file-key test_python \
--matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=${ARCH};py=${RAPIDS_PY_VERSION}" | tee env.yaml

rapids-mamba-retry env create --yes -f env.yaml -n test
Expand Down
4 changes: 2 additions & 2 deletions conda/environments/all_cuda-118_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ dependencies:
- graphviz
- ipykernel
- ipython
- libraft-headers==24.8.*
- librmm==24.8.*
- libraft-headers==24.8.*,>=0.0.0a0
- librmm==24.8.*,>=0.0.0a0
- nanobind>=0.2.0
- nbsphinx
- nccl
Expand Down
4 changes: 2 additions & 2 deletions conda/environments/all_cuda-122_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ dependencies:
- graphviz
- ipykernel
- ipython
- libraft-headers==24.8.*
- librmm==24.8.*
- libraft-headers==24.8.*,>=0.0.0a0
- librmm==24.8.*,>=0.0.0a0
- nanobind>=0.2.0
- nbsphinx
- nccl
Expand Down
1 change: 1 addition & 0 deletions conda/recipes/pylibwholegraph/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ requirements:
- cython
- libwholegraph ={{ version }}
- python
- rapids-build-backend >=0.3.0,<0.4.0.dev0
- scikit-build-core {{ scikit_build_core_version }}
run:
- {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }}
Expand Down
26 changes: 22 additions & 4 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ files:
pyproject_dir: python/pylibwholegraph
extras:
table: build-system
includes:
- rapids_build_skbuild
py_rapids_build_pylibwholegraph:
output: pyproject
pyproject_dir: python/pylibwholegraph
extras:
table: tool.rapids-build-backend
key: requires
includes:
- python_build_wheel
channels:
Expand All @@ -74,11 +82,11 @@ dependencies:
- cxx-compiler
- cython>=3.0.0
- &doxygen doxygen==1.9.1
- libraft-headers==24.8.*
- librmm==24.8.*
- libraft-headers==24.8.*,>=0.0.0a0
- librmm==24.8.*,>=0.0.0a0
- nanobind>=0.2.0
- nccl
- scikit-build-core>=0.7.0
- &scikit_build_core_conda scikit-build-core>=0.7.0
specific:
- output_types: conda
matrices:
Expand Down Expand Up @@ -315,11 +323,21 @@ dependencies:
packages:
- clangxx==16.0.6
- clang-tools==16.0.6
rapids_build_skbuild:
common:
- output_types: [conda, requirements, pyproject]
packages:
- rapids-build-backend>=0.3.0,<0.4.0.dev0
- output_types: conda
packages:
- *scikit_build_core_conda
- output_types: [requirements, pyproject]
packages:
- scikit-build-core[pyproject]>=0.7.0
python_build_wheel:
common:
- output_types: [pyproject]
packages:
- cmake>=3.26.4
- cython>=3.0.0
- ninja
- scikit-build-core[pyproject]>=0.7.0
16 changes: 13 additions & 3 deletions python/pylibwholegraph/pylibwholegraph/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023, NVIDIA CORPORATION.
# Copyright (c) 2023-2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,16 @@
import importlib.resources

__version__ = (
importlib.resources.files("pylibwholegraph").joinpath("VERSION").read_text().strip()
importlib.resources.files(__package__).joinpath("VERSION").read_text().strip()
)
__git_commit__ = ""
try:
__git_commit__ = (
importlib.resources.files(__package__)
.joinpath("GIT_COMMIT")
.read_text()
.strip()
)
except FileNotFoundError:
__git_commit__ = ""

__all__ = ["__git_commit__", "__version__"]
12 changes: 12 additions & 0 deletions python/pylibwholegraph/pylibwholegraph/tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) 2024, NVIDIA CORPORATION.

import pylibwholegraph


def test_version_constants_are_populated():
# __git_commit__ will only be non-empty in a built distribution
assert isinstance(pylibwholegraph.__git_commit__, str)

# __version__ should always be non-empty
assert isinstance(pylibwholegraph__version__, str)
assert len(pylibwholegraph.__version__) > 0
16 changes: 12 additions & 4 deletions python/pylibwholegraph/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
# limitations under the License.

[build-system]
build-backend = "scikit_build_core.build"
build-backend = "rapids_build_backend.build"
requires = [
"cmake>=3.26.4",
"cython>=3.0.0",
"ninja",
"rapids-build-backend>=0.3.0,<0.4.0.dev0",
"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`.

Expand All @@ -42,6 +40,16 @@ classifiers = [
"Programming Language :: Python :: 3.11",
]

[tool.rapids-build-backend]
build-backend = "scikit_build_core.build"
commit-file = "pylibwholegraph/GIT_COMMIT"
dependencies-file = "../../dependencies.yaml"
requires = [
"cmake>=3.26.4",
"cython>=3.0.0",
"ninja",
] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.

[tool.scikit-build]
build-dir = "build/{wheel_tag}"
cmake.build-type = "Release"
Expand Down

0 comments on commit 244d516

Please sign in to comment.