Skip to content
This repository has been archived by the owner on Nov 14, 2021. It is now read-only.

Commit

Permalink
Merge pull request #120 from the-scouts/scm-versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner authored Sep 24, 2021
2 parents c266eff + 205a812 commit 6f60078
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 11 additions & 0 deletions ci/pyroma-version-fixer.py
Original file line number Diff line number Diff line change
@@ -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",
)
5 changes: 5 additions & 0 deletions compass/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions compass/core/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__version__ = "0.20.0"
__version_info__ = (0, 20, 0)
5 changes: 4 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies:
- pep8-naming
- pydocstyle
- bandit
- pyroma
# - pyroma (outdated on CF as at 2021-09-24)
- mypy
- lxml-stubs

Expand All @@ -45,3 +45,6 @@ dependencies:
- pip:
# Type validation
- phonenumberslite

# Linting
- pyroma
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 6f60078

Please sign in to comment.