diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 9e54aa39..6b77c6ae 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -30,7 +30,7 @@ jobs: deps: "bandit" # packaging (CheeseShop) compliance - tool: "pyroma" - command: "pyroma ." + command: "python ci/pyroma-version-fixer.py && pyroma ." deps: "pyroma" # type checking - tool: "mypy" diff --git a/ci/pyroma-version-fixer.py b/ci/pyroma-version-fixer.py new file mode 100644 index 00000000..96ff198c --- /dev/null +++ b/ci/pyroma-version-fixer.py @@ -0,0 +1,11 @@ +from pathlib import Path + +Path(__file__, "..", "version.txt").resolve().write_text( + # read version file + Path(__file__, "..", "..", "compass", "core", "__version__.py").resolve().read_text(encoding="utf-8") + # get first line + .split("\n")[0] + # remove lead and tail + .removeprefix('__version__ = "').removesuffix('"'), + encoding="utf-8", +) diff --git a/compass/core/__init__.py b/compass/core/__init__.py index 0c93e85a..413a2395 100644 --- a/compass/core/__init__.py +++ b/compass/core/__init__.py @@ -5,6 +5,8 @@ from __future__ import annotations from compass.core import logger +from compass.core.__version__ import __version__ +from compass.core.__version__ import __version_info__ from compass.core.errors import CompassAuthenticationError from compass.core.errors import CompassError from compass.core.errors import CompassNetworkError @@ -63,6 +65,9 @@ def login(username: str, password: str, /, *, role: str | None = None, location: __all__ = ( + # public metadata + "__version__", + "__version_info__", # public sub-modules "logger", # public classes diff --git a/compass/core/__version__.py b/compass/core/__version__.py new file mode 100644 index 00000000..35c56f1f --- /dev/null +++ b/compass/core/__version__.py @@ -0,0 +1,2 @@ +__version__ = "0.20.0" +__version_info__ = (0, 20, 0) diff --git a/environment.yml b/environment.yml index 69f93143..50e8f992 100644 --- a/environment.yml +++ b/environment.yml @@ -35,7 +35,7 @@ dependencies: - pep8-naming - pydocstyle - bandit - - pyroma +# - pyroma (outdated on CF as at 2021-09-24) - mypy - lxml-stubs @@ -45,3 +45,6 @@ dependencies: - pip: # Type validation - phonenumberslite + + # Linting + - pyroma diff --git a/pyproject.toml b/pyproject.toml index 05f56cec..901cc085 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,15 @@ # Build system requirements. [build-system] -requires = ["setuptools>=41.0", "wheel"] #"setuptools-scm", +requires = ["setuptools>=45.0", "wheel", "setuptools-scm>=6.2"] build-backend = "setuptools.build_meta" +[tool.setuptools_scm] +write_to = "compass/core/__version__.py" +write_to_template = """\ +__version__ = "{version}" +__version_info__ = {version_tuple} +""" + # Black configuration [tool.black] line-length = 132 # 120*1.1 diff --git a/setup.cfg b/setup.cfg index a5fdcc09..16769a1c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,8 +1,9 @@ # setuptools metadata [metadata] name = compass-interface-core -version = 0.20.0 -# version = attr: src.VERSION +# this is only needed for pyroma linting and is generated by `ci/pyroma-version-fixer.py` +# the actual package version is set by setuptools-scm +version = file: ci/version.txt description = The unofficial API to the TSA Compass membership database long_description = file: README.md long_description_content_type = text/markdown