Skip to content

Commit

Permalink
Add pycrdt.__version__ (#223)
Browse files Browse the repository at this point in the history
* Add pycrdt.__version__

* Fix typing

* Fix coverage

* Fix typing
  • Loading branch information
davidbrochart authored Jan 22, 2025
1 parent 4439d70 commit a8736c0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ classifiers = [

dependencies = [
"anyio >=4.4.0,<5.0.0",
"importlib_metadata >=3.6; python_version<'3.10'",
]

[project.optional-dependencies]
Expand Down
1 change: 1 addition & 0 deletions python/pycrdt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from ._update import get_state as get_state
from ._update import get_update as get_update
from ._update import merge_updates as merge_updates
from ._version import __version__ as __version__
from ._xml import XmlElement as XmlElement
from ._xml import XmlEvent as XmlEvent
from ._xml import XmlFragment as XmlFragment
Expand Down
12 changes: 12 additions & 0 deletions python/pycrdt/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
try:
from importlib.metadata import PackageNotFoundError, version
except ImportError: # pragma: no cover
from importlib_metadata import ( # type: ignore[assignment, import-not-found, no-redef]
PackageNotFoundError,
version,
)

try:
__version__ = version("pycrdt")
except PackageNotFoundError: # pragma: no cover
__version__ = "uninstalled"

0 comments on commit a8736c0

Please sign in to comment.