Skip to content

Commit 3339f13

Browse files
committed
Dynamic library version from package
Why these changes are being introduced: Formerly, the python library version number was set via the pyproject.toml file. This worked, as the actual package itself could provide the version by reading the installed package metadata. However, some best practices discourage this, as it relies on the packing and metadata reading. We may choose to revisit this approach as we get farther along, particularly if installing via a Github tag or release is important. How this addresses that need: * Version is set in timdex_dataset_api.__init__.__version__, allowing it to be read directly from the library * Packaging via pyproject.toml uses this version number via a "dynamic" metadata field Side effects of this change: * None at this time Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/TIMX-414
1 parent 117040e commit 3339f13

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "timdex_dataset_api"
7-
version = "0.1.0"
7+
dynamic = ["version"]
88
description = "Python library for interacting with a TIMDEX parquet dataset"
99
readme = "README.md"
1010
requires-python = ">=3.12"
@@ -116,3 +116,6 @@ max-doc-length = 90
116116

117117
[tool.ruff.lint.pydocstyle]
118118
convention = "google"
119+
120+
[tool.setuptools.dynamic]
121+
version = {attr = "timdex_dataset_api.__version__"}

timdex_dataset_api/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
"""timdex_dataset_api/__init__.py"""
22

3-
from importlib.metadata import PackageNotFoundError, version
4-
5-
try:
6-
__version__ = version("timdex_dataset_api")
7-
except PackageNotFoundError:
8-
__version__ = "unknown"
3+
__version__ = "0.1.0"

0 commit comments

Comments
 (0)