Skip to content

Commit d7b98ae

Browse files
tpellissier-msfttpellissierclaude
authored
Use importlib.metadata for single version source (microsoft#124)
Removes the hardcoded version from `__version__.py` and reads it from package metadata instead, per the [Python Packaging Guide](https://packaging.python.org/en/latest/discussions/versioning/). Only `pyproject.toml` needs to be updated at release time. If the package isn't installed, `PackageNotFoundError` propagates with a clear message. --------- Co-authored-by: tpellissier <tpellissier@microsoft.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 312d758 commit d7b98ae

4 files changed

Lines changed: 5 additions & 9 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,6 @@ published release:
119119

120120
```bash
121121
# After publishing v0.1.0b4, bump to v0.1.0b5 on main
122-
# Update both pyproject.toml and src/PowerPlatform/Dataverse/__version__.py
122+
# Update version in pyproject.toml
123123
# Commit directly to main: "Bump version to 0.1.0b5 for next development cycle"
124124
```
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT license.
33

4-
from .__version__ import __version__
4+
from importlib.metadata import version
5+
6+
__version__ = version("PowerPlatform-Dataverse-Client")
57

68
__all__ = ["__version__"]

src/PowerPlatform/Dataverse/__version__.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/PowerPlatform/Dataverse/data/_odata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
VALIDATION_UNSUPPORTED_CACHE_KIND,
3636
)
3737

38-
from ..__version__ import __version__ as _SDK_VERSION
38+
from .. import __version__ as _SDK_VERSION
3939

4040
_USER_AGENT = f"DataverseSvcPythonClient:{_SDK_VERSION}"
4141
_GUID_RE = re.compile(r"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}")

0 commit comments

Comments
 (0)