diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 97b2fd4..e98b6fc 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -13,6 +13,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: actions/setup-python@v5 with: diff --git a/.gitignore b/.gitignore index 1b8b313..3452029 100644 --- a/.gitignore +++ b/.gitignore @@ -175,4 +175,5 @@ cython_debug/ .DS_Store -.vscode \ No newline at end of file +.vscode +matrix/_version.py \ No newline at end of file diff --git a/matrix/__init__.py b/matrix/__init__.py index 2ad8ae1..966bd09 100644 --- a/matrix/__init__.py +++ b/matrix/__init__.py @@ -1,6 +1,11 @@ """A simple, developer-friendly library to create powerful Matrix bots.""" -__version__ = "1.0.4-alpha" +from importlib.metadata import version, PackageNotFoundError + +try: + __version__ = version("matrix-python") +except PackageNotFoundError: + from matrix._version import version as __version__ from .bot import Bot from .group import Group diff --git a/pyproject.toml b/pyproject.toml index 791584c..43d9e14 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=64", "setuptools_scm>=8"] [project] name = "matrix-python" -version = "1.0.4-alpha" +dynamic = ["version"] authors = [ { name="Simon Roy" }, { name=" Chris Dedman Rollet " } @@ -42,3 +42,6 @@ dev = [ [tool.setuptools] packages = ["matrix"] license-files = [] + +[tool.setuptools_scm] +write_to = "matrix/_version.py" \ No newline at end of file