Skip to content

Commit

Permalink
Update build.sh to build rust bindings (#53)
Browse files Browse the repository at this point in the history
* Update build.sh to build the rust bindings
* update ci/release/update-version.sh to keep the rust version up to date
* remove references to the cuvs-rs conda package from the README
* Remove temporary copy of rust documentation from `docs/source/_static` - just copy directly to output folder

Authors:
  - Ben Frederickson (https://github.com/benfred)

Approvers:
  - Corey J. Nolet (https://github.com/cjnolet)
  - Jake Awe (https://github.com/AyodeAwe)

URL: #53
  • Loading branch information
benfred authored Mar 14, 2024
1 parent 5b8393f commit b4e6a9e
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 15 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ cuVS contains state-of-the-art implementations of several algorithms for running

cuVS comes with pre-built packages that can be installed through [conda](https://conda.io/projects/conda/en/latest/user-guide/getting-started.html#managing-python). Different packages are available for the different languages supported by cuVS:

| Python | C++ | C | Rust |
|--------|-----|---|------|
| `pycuvs`| `libcuvs` | `libcuvs_c` | `cuvs-rs` |
| Python | C++ | C |
|--------|-----|---|
| `pycuvs`| `libcuvs` | `libcuvs_c` |

### Stable release

Expand Down Expand Up @@ -172,7 +172,7 @@ fn cagra_example() -> Result<()> {

## Contributing

If you are interested in contributing to the cuVS library, please read our [Contributing guidelines](docs/source/contributing.md). Refer to the [Developer Guide](docs/source/developer_guide.md) for details on the developer guidelines, workflows, and principals.
If you are interested in contributing to the cuVS library, please read our [Contributing guidelines](docs/source/contributing.md). Refer to the [Developer Guide](docs/source/developer_guide.md) for details on the developer guidelines, workflows, and principles.

## References

Expand Down
21 changes: 15 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ ARGS=$*
# scripts, and that this script resides in the repo dir!
REPODIR=$(cd $(dirname $0); pwd)

VALIDARGS="clean libcuvs python docs tests examples clean --uninstall -v -g -n --compile-static-lib --allgpuarch --no-nvtx --show_depr_warn --incl-cache-stats --time -h"
VALIDARGS="clean libcuvs python rust docs tests examples --uninstall -v -g -n --compile-static-lib --allgpuarch --no-nvtx --show_depr_warn --incl-cache-stats --time -h"
HELP="$0 [<target> ...] [<flag> ...] [--cmake-args=\"<args>\"] [--cache-tool=<tool>] [--limit-tests=<targets>] [--build-metrics=<filename>]
where <target> is:
clean - remove all existing build artifacts and configuration (start over)
libcuvs - build the cuvs C++ code only. Also builds the C-wrapper library
around the C++ code.
python - build the cuvs Python package
rust - build the cuvs Rust bindings
docs - build the documentation
tests - build the tests
examples - build the examples
Expand Down Expand Up @@ -54,8 +55,8 @@ LIBCUVS_BUILD_DIR=${LIBCUVS_BUILD_DIR:=${REPODIR}/cpp/build}
SPHINX_BUILD_DIR=${REPODIR}/docs
DOXYGEN_BUILD_DIR=${REPODIR}/cpp/doxygen
PYTHON_BUILD_DIR=${REPODIR}/python/cuvs/_skbuild
RUST_BUILD_DIR=${REPODIR}/rust
BUILD_DIRS="${LIBCUVS_BUILD_DIR} ${PYTHON_BUILD_DIR}"
RUST_BUILD_DIR=${REPODIR}/rust/target
BUILD_DIRS="${LIBCUVS_BUILD_DIR} ${PYTHON_BUILD_DIR} ${RUST_BUILD_DIR}"

# Set defaults for vars modified by flags to this script
CMAKE_LOG_LEVEL=""
Expand All @@ -77,6 +78,7 @@ CLEAN=0
UNINSTALL=0
DISABLE_DEPRECATION_WARNINGS=ON
CMAKE_TARGET=""
EXTRA_CMAKE_ARGS=""

# Set defaults for vars that may not have been defined externally
INSTALL_PREFIX=${INSTALL_PREFIX:=${PREFIX:=${CONDA_PREFIX:=$LIBCUVS_BUILD_DIR/install}}}
Expand Down Expand Up @@ -392,18 +394,25 @@ if (( ${NUMARGS} == 0 )) || hasArg python; then
python -m pip install --no-build-isolation --no-deps -vvv ${REPODIR}/python/cuvs
fi

# Build the cuvs Rust bindings
if (( ${NUMARGS} == 0 )) || hasArg rust; then
cd ${REPODIR}/rust
cargo build --examples --lib
cargo test
fi

export RAPIDS_VERSION="$(sed -E -e 's/^([0-9]{2})\.([0-9]{2})\.([0-9]{2}).*$/\1.\2.\3/' "${REPODIR}/VERSION")"
export RAPIDS_VERSION_MAJOR_MINOR="$(sed -E -e 's/^([0-9]{2})\.([0-9]{2})\.([0-9]{2}).*$/\1.\2/' "${REPODIR}/VERSION")"

if hasArg docs; then
set -x
cd ${DOXYGEN_BUILD_DIR}
doxygen Doxyfile
cd ${RUST_BUILD_DIR}
cargo doc -p cuvs --no-deps
rsync -av ${RUST_BUILD_DIR}/target/doc/ ${SPHINX_BUILD_DIR}/source/_static/rust
cd ${SPHINX_BUILD_DIR}
sphinx-build -b html source _html
cd ${REPODIR}/rust
cargo doc -p cuvs --no-deps
rsync -av ${RUST_BUILD_DIR}/doc/ ${SPHINX_BUILD_DIR}/_html/_static/rust
fi

################################################################################
Expand Down
5 changes: 2 additions & 3 deletions ci/build_rust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,5 @@ rapids-mamba-retry install \
libcuvs \
libraft

# build and test the rust bindings
cd rust
cargo test
export EXTRA_CMAKE_ARGS=""
bash ./build.sh rust
7 changes: 6 additions & 1 deletion ci/release/update-version.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# Copyright (c) 2020-2024, NVIDIA CORPORATION.
########################
# RAFT Version Updater #
# CUVS Version Updater #
########################

## Usage
Expand All @@ -21,6 +21,7 @@ CURRENT_SHORT_TAG=${CURRENT_MAJOR}.${CURRENT_MINOR}
#Get <major>.<minor> for next version
NEXT_MAJOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[1]}')
NEXT_MINOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[2]}')
NEXT_PATCH=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[3]}')
NEXT_SHORT_TAG=${NEXT_MAJOR}.${NEXT_MINOR}
NEXT_UCX_PY_SHORT_TAG="$(curl -sL https://version.gpuci.io/rapids/${NEXT_SHORT_TAG})"
NEXT_UCX_PY_VERSION="${NEXT_UCX_PY_SHORT_TAG}.*"
Expand Down Expand Up @@ -81,6 +82,10 @@ sed_runner "s|:[0-9][0-9].[0-9][0-9]|:${NEXT_SHORT_TAG}|g" docs/source/raft_ann_

sed_runner "s|branch-[0-9][0-9].[0-9][0-9]|branch-${NEXT_SHORT_TAG}|g" README.md

# rust can't handle leading 0's in the major/minor/patch version - remove
NEXT_FULL_RUST_TAG=$(printf "%d.%d.%d" $((10#$NEXT_MAJOR)) $((10#$NEXT_MINOR)) $((10#$NEXT_PATCH)))
sed_runner "s/version = \".*\"/version = \"${NEXT_FULL_RUST_TAG}\"/g" rust/Cargo.toml

# .devcontainer files
find .devcontainer/ -type f -name devcontainer.json -print0 | while IFS= read -r -d '' filename; do
sed_runner "s@rapidsai/devcontainers:[0-9.]*@rapidsai/devcontainers:${NEXT_SHORT_TAG}@g" "${filename}"
Expand Down
6 changes: 6 additions & 0 deletions docs/source/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ The Python packages can also be uninstalled using the `build.sh` script:
Rust library
^^^^^^^^^^^^

The Rust bindings can be built with

.. code-block:: bash
./build.sh rust
Using CMake directly
^^^^^^^^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [
resolver = "2"

[workspace.package]
version = "0.1.0"
version = "24.4.0"
edition = "2021"
repository = "https://github.com/rapidsai/cuvs"
homepage = "https://github.com/rapidsai/cuvs"
Expand Down

0 comments on commit b4e6a9e

Please sign in to comment.