From 8731137a2833b744e268570a45099d27069c085d Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 31 Oct 2023 09:46:45 -0700 Subject: [PATCH] Update versioning strategy (#1285) See https://github.com/rapidsai/rmm/pull/1347 Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Mark Harris (https://github.com/harrism) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/cuspatial/pull/1285 --- .github/workflows/pr.yaml | 2 +- VERSION | 1 + build.sh | 16 +++++++--------- ci/build_cpp.sh | 4 +++- ci/build_python.sh | 14 ++++++++++++-- ci/build_wheel.sh | 8 ++++---- ci/release/update-version.sh | 9 ++------- conda/recipes/cuproj/meta.yaml | 4 ++-- conda/recipes/cuspatial/meta.yaml | 4 ++-- conda/recipes/libcuspatial/meta.yaml | 4 ++-- python/cuproj/cuproj/VERSION | 1 + python/cuproj/cuproj/__init__.py | 3 +-- python/cuproj/cuproj/_version.py | 20 ++++++++++++++++++++ python/cuproj/pyproject.toml | 5 ++++- python/cuproj/setup.py | 4 +++- python/cuspatial/cuspatial/VERSION | 1 + python/cuspatial/cuspatial/__init__.py | 3 +-- python/cuspatial/cuspatial/_version.py | 23 +++++++++++++++++++++++ python/cuspatial/pyproject.toml | 5 ++++- python/cuspatial/setup.py | 4 +++- 20 files changed, 97 insertions(+), 38 deletions(-) create mode 100644 VERSION create mode 120000 python/cuproj/cuproj/VERSION create mode 100644 python/cuproj/cuproj/_version.py create mode 120000 python/cuspatial/cuspatial/VERSION create mode 100644 python/cuspatial/cuspatial/_version.py diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 20af1df0c..c9e64d9fb 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -97,7 +97,7 @@ jobs: build_type: pull-request script: ci/build_wheel_cuproj.sh wheel-tests-cuproj: - needs: wheel-build-cuproj + needs: [wheel-build-cuspatial, wheel-build-cuproj] secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-23.12 with: diff --git a/VERSION b/VERSION new file mode 100644 index 000000000..a193fff41 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +23.12.00 diff --git a/build.sh b/build.sh index 89d78879e..34a4840d2 100755 --- a/build.sh +++ b/build.sh @@ -28,7 +28,7 @@ HELP="$0 [clean] [libcuspatial] [cuspatial] [tests] [-v] [-g] [-n] [-h] [-l] [-- benchmarks - build benchmarks -v - verbose build mode -g - build for debug - -n - no install step + -n - no install step (does not affect Python) -h - print this text --allgpuarch - build for all supported GPU architectures --show_depr_warn - show cmake deprecation warnings @@ -182,18 +182,16 @@ fi if (( ${NUMARGS} == 0 )) || hasArg cuspatial; then cd ${REPODIR}/python/cuspatial - python setup.py build_ext -j${PARALLEL_LEVEL:-1} --inplace -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} -DCMAKE_LIBRARY_PATH=${LIBCUSPATIAL_BUILD_DIR} ${EXTRA_CMAKE_ARGS} - if [[ ${INSTALL_TARGET} != "" ]]; then - python setup.py install --single-version-externally-managed --record=record.txt -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} -DCMAKE_LIBRARY_PATH=${LIBCUSPATIAL_BUILD_DIR} ${EXTRA_CMAKE_ARGS} - fi + SKBUILD_CONFIGURE_OPTIONS="-DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} -DCMAKE_LIBRARY_PATH=${LIBCUSPATIAL_BUILD_DIR} ${EXTRA_CMAKE_ARGS}" \ + SKBUILD_BUILD_OPTIONS="-j${PARALLEL_LEVEL:-1}" \ + python -m pip install --no-build-isolation --no-deps . fi # Build and install the cuproj Python package if (( ${NUMARGS} == 0 )) || hasArg cuproj; then cd ${REPODIR}/python/cuproj - python setup.py build_ext -j${PARALLEL_LEVEL:-1} --inplace -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} -DCMAKE_LIBRARY_PATH=${LIBCUPROJ_BUILD_DIR} ${EXTRA_CMAKE_ARGS} - if [[ ${INSTALL_TARGET} != "" ]]; then - python setup.py install --single-version-externally-managed --record=record.txt -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} -DCMAKE_LIBRARY_PATH=${LIBCUPROJ_BUILD_DIR} ${EXTRA_CMAKE_ARGS} - fi + SKBUILD_CONFIGURE_OPTIONS="-DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} -DCMAKE_LIBRARY_PATH=${LIBCUPROJ_BUILD_DIR} ${EXTRA_CMAKE_ARGS}" \ + SKBUILD_BUILD_OPTIONS="-j${PARALLEL_LEVEL:-1}" \ + python -m pip install --no-build-isolation --no-deps . fi diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 007eb17ee..cd40c1df0 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -9,9 +9,11 @@ export CMAKE_GENERATOR=Ninja rapids-print-env +version=$(rapids-generate-version) + rapids-logger "Begin cpp build" -rapids-conda-retry mambabuild \ +RAPIDS_PACKAGE_VERSION=${version} rapids-conda-retry mambabuild \ conda/recipes/libcuspatial rapids-upload-conda-to-s3 cpp diff --git a/ci/build_python.sh b/ci/build_python.sh index de5c3fef8..8036ea8eb 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -9,13 +9,23 @@ export CMAKE_GENERATOR=Ninja rapids-print-env +package_dir="python" + +version=$(rapids-generate-version) +commit=$(git rev-parse HEAD) + +echo "${version}" > VERSION +for package_name in cuspatial cuproj; do + sed -i "/^__git_commit__/ s/= .*/= \"${commit}\"/g" "${package_dir}/${package_name}/${package_name}/_version.py" +done + CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) rapids-logger "Begin py build cuSpatial" # TODO: Remove `--no-test` flag once importing on a CPU # node works correctly -rapids-conda-retry mambabuild \ +RAPIDS_PACKAGE_VERSION=${version} rapids-conda-retry mambabuild \ --no-test \ --channel "${CPP_CHANNEL}" \ conda/recipes/cuspatial @@ -24,7 +34,7 @@ rapids-logger "Begin py build cuProj" # TODO: Remove `--no-test` flag once importing on a CPU # node works correctly -rapids-conda-retry mambabuild \ +RAPIDS_PACKAGE_VERSION=${version} rapids-conda-retry mambabuild \ --no-test \ --channel "${CPP_CHANNEL}" \ conda/recipes/cuproj diff --git a/ci/build_wheel.sh b/ci/build_wheel.sh index ff997e245..231b111b2 100755 --- a/ci/build_wheel.sh +++ b/ci/build_wheel.sh @@ -9,9 +9,8 @@ package_dir=$2 source rapids-configure-sccache source rapids-date-string -# Use gha-tools rapids-pip-wheel-version to generate wheel version then -# update the necessary files -version_override="$(rapids-pip-wheel-version ${RAPIDS_DATE_STRING})" +version=$(rapids-generate-version) +commit=$(git rev-parse HEAD) RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" @@ -22,8 +21,9 @@ 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" -sed -i "s/^version = .*/version = \"${version_override}\"/g" ${pyproject_file} sed -i "s/name = \"${package_name}\"/name = \"${package_name}${PACKAGE_CUDA_SUFFIX}\"/g" ${pyproject_file} +echo "${version}" > VERSION +sed -i "/^__git_commit__/ s/= .*/= \"${commit}\"/g" "${package_dir}/${package_name}/_version.py" # 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 diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 22d41e713..416f49fe2 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -42,9 +42,8 @@ sed_runner 's/release = .*/release = '"'${NEXT_FULL_TAG}'"'/g' docs/source/conf. sed_runner 's/version = .*/version = '"'${NEXT_SHORT_TAG}'"'/g' docs/cuproj/source/conf.py sed_runner 's/release = .*/release = '"'${NEXT_FULL_TAG}'"'/g' docs/cuproj/source/conf.py -# Python __init__.py updates -sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/cuspatial/cuspatial/__init__.py -sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/cuproj/cuproj/__init__.py +# Centralized version file update +echo "${NEXT_FULL_TAG}" > VERSION # rapids-cmake version sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' fetch_rapids.cmake @@ -84,10 +83,6 @@ for DEP in "${DEPENDENCIES[@]}"; do sed_runner "s/${DEP}==.*\",/${DEP}==${NEXT_SHORT_TAG_PEP440}.*\",/g" python/cuproj/pyproject.toml done -# Version in pyproject.toml -sed_runner "s/^version = .*/version = \"${NEXT_FULL_TAG}\"/g" python/cuspatial/pyproject.toml -sed_runner "s/^version = .*/version = \"${NEXT_FULL_TAG}\"/g" python/cuproj/pyproject.toml - # Dependency versions in dependencies.yaml sed_runner "/-cu[0-9]\{2\}==/ s/==.*/==${NEXT_SHORT_TAG_PEP440}.*/g" dependencies.yaml diff --git a/conda/recipes/cuproj/meta.yaml b/conda/recipes/cuproj/meta.yaml index 520a0b2de..b2343b926 100644 --- a/conda/recipes/cuproj/meta.yaml +++ b/conda/recipes/cuproj/meta.yaml @@ -1,6 +1,6 @@ # Copyright (c) 2018-2023, NVIDIA CORPORATION. -{% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') %} +{% set version = environ['RAPIDS_PACKAGE_VERSION'].lstrip('v') %} {% set minor_version = version.split('.')[0] + '.' + version.split('.')[1] %} {% set cuda_version = '.'.join(environ['RAPIDS_CUDA_VERSION'].split('.')[:2]) %} {% set cuda_major = cuda_version.split('.')[0] %} @@ -12,7 +12,7 @@ package: version: {{ version }} source: - git_url: ../../.. + path: ../../.. build: number: {{ GIT_DESCRIBE_NUMBER }} diff --git a/conda/recipes/cuspatial/meta.yaml b/conda/recipes/cuspatial/meta.yaml index 125243807..468d0f45f 100644 --- a/conda/recipes/cuspatial/meta.yaml +++ b/conda/recipes/cuspatial/meta.yaml @@ -1,6 +1,6 @@ # Copyright (c) 2018-2023, NVIDIA CORPORATION. -{% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') %} +{% set version = environ['RAPIDS_PACKAGE_VERSION'].lstrip('v') %} {% set minor_version = version.split('.')[0] + '.' + version.split('.')[1] %} {% set cuda_version = '.'.join(environ['RAPIDS_CUDA_VERSION'].split('.')[:2]) %} {% set cuda_major = cuda_version.split('.')[0] %} @@ -12,7 +12,7 @@ package: version: {{ version }} source: - git_url: ../../.. + path: ../../.. build: number: {{ GIT_DESCRIBE_NUMBER }} diff --git a/conda/recipes/libcuspatial/meta.yaml b/conda/recipes/libcuspatial/meta.yaml index 9833b5d92..b543823d5 100644 --- a/conda/recipes/libcuspatial/meta.yaml +++ b/conda/recipes/libcuspatial/meta.yaml @@ -1,6 +1,6 @@ # Copyright (c) 2018-2023, NVIDIA CORPORATION. -{% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') %} +{% set version = environ['RAPIDS_PACKAGE_VERSION'].lstrip('v') %} {% set minor_version = version.split('.')[0] + '.' + version.split('.')[1] %} {% set cuda_version = '.'.join(environ['RAPIDS_CUDA_VERSION'].split('.')[:2]) %} {% set cuda_major = cuda_version.split('.')[0] %} @@ -10,7 +10,7 @@ package: name: libcuspatial-split source: - git_url: ../../.. + path: ../../.. build: script_env: diff --git a/python/cuproj/cuproj/VERSION b/python/cuproj/cuproj/VERSION new file mode 120000 index 000000000..d62dc733e --- /dev/null +++ b/python/cuproj/cuproj/VERSION @@ -0,0 +1 @@ +../../../VERSION \ No newline at end of file diff --git a/python/cuproj/cuproj/__init__.py b/python/cuproj/cuproj/__init__.py index 1935c1d0f..894b77db9 100644 --- a/python/cuproj/cuproj/__init__.py +++ b/python/cuproj/cuproj/__init__.py @@ -1,5 +1,4 @@ # Copyright (c) 2023, NVIDIA CORPORATION. +from ._version import __git_commit__, __version__ from .transformer import Transformer - -__version__ = "23.12.00" diff --git a/python/cuproj/cuproj/_version.py b/python/cuproj/cuproj/_version.py new file mode 100644 index 000000000..e7bd99791 --- /dev/null +++ b/python/cuproj/cuproj/_version.py @@ -0,0 +1,20 @@ +# Copyright (c) 2023, 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import importlib.resources + +__version__ = ( + importlib.resources.files("cuproj").joinpath("VERSION").read_text().strip() +) +__git_commit__ = "" diff --git a/python/cuproj/pyproject.toml b/python/cuproj/pyproject.toml index 811914c86..48f75b442 100644 --- a/python/cuproj/pyproject.toml +++ b/python/cuproj/pyproject.toml @@ -26,7 +26,7 @@ requires = [ [project] name = "cuproj" -version = "23.12.00" +dynamic = ["version"] description = "cuProj: GPU-Accelerated Coordinate Projection" readme = { file = "README.md", content-type = "text/markdown" } authors = [{ name = "NVIDIA Corporation" }] @@ -63,6 +63,9 @@ Documentation = "https://docs.rapids.ai/api/cuproj/stable/" [tool.setuptools] license-files = ["LICENSE"] +[tool.setuptools.dynamic] +version = {file = "cuproj/VERSION"} + [tool.isort] line_length = 79 multi_line_output = 3 diff --git a/python/cuproj/setup.py b/python/cuproj/setup.py index fdd1e9557..bb97c04ec 100644 --- a/python/cuproj/setup.py +++ b/python/cuproj/setup.py @@ -6,6 +6,8 @@ setup( packages=packages, - package_data={key: ["*.pxd", "*.hpp", "*.cuh"] for key in packages}, + package_data={ + key: ["VERSION", "*.pxd", "*.hpp", "*.cuh"] for key in packages + }, zip_safe=False, ) diff --git a/python/cuspatial/cuspatial/VERSION b/python/cuspatial/cuspatial/VERSION new file mode 120000 index 000000000..d62dc733e --- /dev/null +++ b/python/cuspatial/cuspatial/VERSION @@ -0,0 +1 @@ +../../../VERSION \ No newline at end of file diff --git a/python/cuspatial/cuspatial/__init__.py b/python/cuspatial/cuspatial/__init__.py index b9680cf39..069b5454d 100644 --- a/python/cuspatial/cuspatial/__init__.py +++ b/python/cuspatial/cuspatial/__init__.py @@ -1,5 +1,6 @@ # Copyright (c) 2023, NVIDIA CORPORATION. +from ._version import __git_commit__, __version__ from .core.geodataframe import GeoDataFrame from .core.geoseries import GeoSeries from .core.spatial import ( @@ -28,5 +29,3 @@ trajectory_distances_and_speeds, ) from .io.geopandas import from_geopandas - -__version__ = "23.12.00" diff --git a/python/cuspatial/cuspatial/_version.py b/python/cuspatial/cuspatial/_version.py new file mode 100644 index 000000000..e1333b17a --- /dev/null +++ b/python/cuspatial/cuspatial/_version.py @@ -0,0 +1,23 @@ +# Copyright (c) 2023, 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import importlib.resources + +__version__ = ( + importlib.resources.files("cuspatial") + .joinpath("VERSION") + .read_text() + .strip() +) +__git_commit__ = "" diff --git a/python/cuspatial/pyproject.toml b/python/cuspatial/pyproject.toml index a331ade40..f2e464088 100644 --- a/python/cuspatial/pyproject.toml +++ b/python/cuspatial/pyproject.toml @@ -27,7 +27,7 @@ requires = [ [project] name = "cuspatial" -version = "23.12.00" +dynamic = ["version"] description = "cuSpatial: GPU-Accelerated Spatial and Trajectory Data Management and Analytics Library" readme = { file = "README.md", content-type = "text/markdown" } authors = [ @@ -64,6 +64,9 @@ Documentation = "https://docs.rapids.ai/api/cuspatial/stable/" [tool.setuptools] license-files = ["LICENSE"] +[tool.setuptools.dynamic] +version = {file = "cuspatial/VERSION"} + [tool.isort] line_length = 79 multi_line_output = 3 diff --git a/python/cuspatial/setup.py b/python/cuspatial/setup.py index 2ea444b56..1c4d94f37 100644 --- a/python/cuspatial/setup.py +++ b/python/cuspatial/setup.py @@ -6,6 +6,8 @@ setup( packages=packages, - package_data={key: ["*.pxd", "*.hpp", "*.cuh"] for key in packages}, + package_data={ + key: ["VERSION", "*.pxd", "*.hpp", "*.cuh"] for key in packages + }, zip_safe=False, )