Skip to content

Commit

Permalink
fix: version should be set by pyproject.toml
Browse files Browse the repository at this point in the history
`aries_cloudagent.version.__version__` was out of sync with the version
listed in the pyproject.toml file. The pyproject.toml file should be the
source of truth as it will be used when publishing using poetry.
However, `__version__` is used in code for some operations. To ensure
that the pyproject file and the `__version__` can't get out of sync,
`aries_cloudagent.version` will now read the version from the pyproject
file. This read will only take place once on first import.

To acheive this, I added `tomli` as a dependency, but only if the python
version is < 3.11. If 3.11 is in use, the `tomlib` library will be used,
which was added as a python standard library module in 3.11.

Signed-off-by: Daniel Bluhm <dbluhm@pm.me>
  • Loading branch information
dbluhm committed Sep 6, 2023
1 parent 294919d commit d1dc71e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
10 changes: 9 additions & 1 deletion aries_cloudagent/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
"""Library version information."""

__version__ = "0.10.1"
try:
import tomlib
except ModuleNotFoundError:
import tomli as tomlib

with open("pyproject.toml", "rb") as pyproject_file:
pyproject = tomlib.load(pyproject_file)

__version__ = pyproject["tool"]["poetry"]["version"]
RECORD_TYPE_ACAPY_VERSION = "acapy_version"
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "aries_cloudagent"
version = "0.10.0-rc0"
description = ""
version = "0.10.1"
description = "Hyperledger Aries Cloud Agent Python (ACA-Py) is a foundation for building decentralized identity applications and services running in non-mobile environments. "
authors = ["Hyperledger Aries <aries@lists.hyperledger.org>"]
license = "Apache-2.0"
readme = "README.md"
Expand Down Expand Up @@ -51,6 +51,7 @@ unflatten="~0.1"
asyncpg = ">=0.25.0,<0.26.0"
web-py = ">=0.62,<1.0"
pygments = ">=2.10,<3.0"
tomli = {version = "^2.0.1", python = "<3.11"}

# askar
aries-askar= { version = "~0.2.5", optional = true }
Expand Down

0 comments on commit d1dc71e

Please sign in to comment.