Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce hard-coding of version #135

Merged
merged 7 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include legateboost/VERSION
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
6 changes: 6 additions & 0 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
16 changes: 15 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---------------------------------------------------
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions legateboost/VERSION
1 change: 1 addition & 0 deletions legateboost/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@
EarlyStopping,
)
from .utils import mod_col_by_idx, pick_col_by_idx, set_col_by_idx
from ._version import __version__
7 changes: 7 additions & 0 deletions legateboost/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import importlib.resources

__version__ = (
importlib.resources.files(__package__).joinpath("VERSION").read_text().strip()
)

__all__ = ["__version__"]
7 changes: 7 additions & 0 deletions legateboost/test/test_version.py
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "legate-boost"
version = "0.1"
dynamic = ["version"]
authors = [
{name = "NVIDIA Corporation"},
]
Expand Down Expand Up @@ -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
Expand Down