From 6428666e79e71e685db637cd3a2e63121a796f43 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 13 Oct 2023 14:59:40 -0700 Subject: [PATCH] Update versioning strategy --- ci/build_python.sh | 9 ++++++++- ci/build_wheel.sh | 9 +++++---- conda/recipes/ucx-py/meta.yaml | 4 ++-- pyproject.toml | 5 ++++- ucp/__init__.py | 2 +- ucp/_version.py | 16 ++++++++++++++++ 6 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 ucp/_version.py diff --git a/ci/build_python.sh b/ci/build_python.sh index de97365a4..e90ae5b69 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -7,9 +7,16 @@ source rapids-env-update rapids-print-env +version=$(rapids-generate-version) +commit=$(git rev-parse HEAD) + +version_file="ucp/_version.py" +sed -i "/^__version__/ s/= .*/= ${version}/g" ${version_file} +sed -i "/^__git_commit__/ s/= .*/= \"${commit}\"/g" ${version_file} + rapids-logger "Begin py build" -rapids-conda-retry mambabuild \ +RAPIDS_PACKAGE_VERSION=${version} rapids-conda-retry mambabuild \ conda/recipes/ucx-py rapids-upload-conda-to-s3 python diff --git a/ci/build_wheel.sh b/ci/build_wheel.sh index e7592f289..2c96897df 100755 --- a/ci/build_wheel.sh +++ b/ci/build_wheel.sh @@ -9,9 +9,8 @@ underscore_package_name=$(echo "${package_name}" | tr "-" "_") 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})" @@ -21,9 +20,11 @@ PACKAGE_CUDA_SUFFIX="-${RAPIDS_PY_CUDA_SUFFIX}" # Patch project metadata files to include the CUDA version suffix and version override. pyproject_file="pyproject.toml" +version_file="ucp/_version.py" -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} +sed -i "/^__version__/ s/= .*/= ${version}/g" ${version_file} +sed -i "/^__git_commit__/ s/= .*/= \"${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 diff --git a/conda/recipes/ucx-py/meta.yaml b/conda/recipes/ucx-py/meta.yaml index 1b88500a7..2448e4077 100644 --- a/conda/recipes/ucx-py/meta.yaml +++ b/conda/recipes/ucx-py/meta.yaml @@ -2,7 +2,7 @@ {% set data = load_file_data("pyproject.toml") %} -{% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') %} +{% set version = environ.get('RAPIDS_PACKAGE_VERSION', '0.0.0.dev').strip('"').lstrip('v') %} {% set py_version = environ['CONDA_PY'] %} {% set cuda_version = '.'.join(environ['RAPIDS_CUDA_VERSION'].split('.')[:2]) %} {% set date_string = environ['RAPIDS_DATE_STRING'] %} @@ -12,7 +12,7 @@ package: version: {{ version }} source: - git_url: ../../.. + path: ../../.. build: number: {{ GIT_DESCRIBE_NUMBER }} diff --git a/pyproject.toml b/pyproject.toml index 1109cd8f0..d9b8b1010 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ requires = [ [project] name = "ucx-py" -version = "0.35.0" +dynamic = ["version"] description = "Python Bindings for the Unified Communication X library (UCX)" readme = { file = "README.md", content-type = "text/markdown" } authors = [ @@ -117,3 +117,6 @@ zip-safe = false [tool.setuptools.packages.find] exclude=["tests*"] + +[tool.setuptools.dynamic] +version = {attr = "ucp._version.__version__"} diff --git a/ucp/__init__.py b/ucp/__init__.py index 89ac836ee..791860b1d 100644 --- a/ucp/__init__.py +++ b/ucp/__init__.py @@ -20,6 +20,7 @@ from .core import get_ucx_version # noqa from .utils import get_ucxpy_logger # noqa from ._libs.utils import get_address # noqa +from ._version import __git_commit__, __version__ try: import pynvml @@ -90,7 +91,6 @@ def _is_mig_device(handle): os.environ["UCX_MAX_RNDV_RAILS"] = "1" -__version__ = "0.35.0" __ucx_version__ = "%d.%d.%d" % get_ucx_version() if get_ucx_version() < (1, 11, 1): diff --git a/ucp/_version.py b/ucp/_version.py new file mode 100644 index 000000000..bdafc7e45 --- /dev/null +++ b/ucp/_version.py @@ -0,0 +1,16 @@ +# 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. + +__version__ = "23.12.00" +__git_commit__ = ""