diff --git a/CMakeLists.txt b/CMakeLists.txt index 33b23bd8..e6944924 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,18 @@ cmake_minimum_required(VERSION 3.24.0 FATAL_ERROR) -project(legateboost VERSION 1.0 LANGUAGES C CXX CUDA) +# read project version from VERSION file +file(READ "${CMAKE_CURRENT_LIST_DIR}/VERSION" _version_content) +if(_version_content MATCHES [[^([0-9]+)\.([0-9]+)\.([0-9]+)]]) + set(_legateboost_version "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}") +else() + string(REPLACE "\n" "\n " _legateboost_content_formatted " ${_version_content}") + message( + FATAL_ERROR + "Could not determine project version. Contents of VERSION file:\n${_legateboost_content_formatted}" + ) +endif() + +project(legateboost VERSION "${_legateboost_version}" LANGUAGES C CXX CUDA) option(SANITIZE "Build with address sanitizer" OFF) diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..204af9d1 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include legateboost/VERSION diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..6e8bf73a --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0 diff --git a/contributing.md b/contributing.md index e66c3b92..689d4222 100644 --- a/contributing.md +++ b/contributing.md @@ -73,6 +73,12 @@ Run all checks manually. ``` pre-commit run --all-files ``` + +## Change the project version + +The `VERSION` file at the root of the repo is the single source for `legate-boost`'s version. +Modify that file to change the version for wheels, conda packages, the CMake project, etc. + ## Development principles The following general principles should be followed when developing `legate-boost`. diff --git a/docs/source/conf.py b/docs/source/conf.py index b571aad8..0751ae3a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -3,11 +3,15 @@ # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html +from datetime import datetime + +import legateboost + # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information project = "legate-boost" -copyright = "2023, NVIDIA" +copyright = f"2023-{datetime.today().year}, NVIDIA" author = "NVIDIA" # -- General configuration --------------------------------------------------- @@ -27,6 +31,16 @@ source_suffix = {".rst": "restructuredtext", ".md": "markdown"} +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# + +# The short X.Y version. +version = legateboost.__version__ + +# The full version, including alpha/beta/rc tags. +release = version # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output diff --git a/legateboost/VERSION b/legateboost/VERSION new file mode 120000 index 00000000..6ff19de4 --- /dev/null +++ b/legateboost/VERSION @@ -0,0 +1 @@ +../VERSION \ No newline at end of file diff --git a/legateboost/__init__.py b/legateboost/__init__.py index 42ecd102..29f29e57 100644 --- a/legateboost/__init__.py +++ b/legateboost/__init__.py @@ -25,3 +25,4 @@ EarlyStopping, ) from .utils import mod_col_by_idx, pick_col_by_idx, set_col_by_idx +from ._version import __version__ diff --git a/legateboost/_version.py b/legateboost/_version.py new file mode 100644 index 00000000..f2d8aed5 --- /dev/null +++ b/legateboost/_version.py @@ -0,0 +1,7 @@ +import importlib.resources + +__version__ = ( + importlib.resources.files(__package__).joinpath("VERSION").read_text().strip() +) + +__all__ = ["__version__"] diff --git a/legateboost/test/test_version.py b/legateboost/test/test_version.py new file mode 100644 index 00000000..8872b864 --- /dev/null +++ b/legateboost/test/test_version.py @@ -0,0 +1,7 @@ +import legateboost + + +def test_version_constants_are_populated(): + # __version__ should always be non-empty + assert isinstance(legateboost.__version__, str) + assert len(legateboost.__version__) > 0 diff --git a/pyproject.toml b/pyproject.toml index a76371b9..4a9dc20a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta" [project] name = "legate-boost" -version = "0.1" +dynamic = ["version"] authors = [ {name = "NVIDIA Corporation"}, ] @@ -45,6 +45,9 @@ test = [ "xgboost", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit dependencies.yaml and run `rapids-dependency-file-generator`. +[tool.setuptools.dynamic] +version = {file = "legateboost/VERSION"} + [tool.mypy] disallow_untyped_defs = true