diff --git a/eligibility_server/__init__.py b/eligibility_server/__init__.py index 1eb05ef3..3aa921e5 100644 --- a/eligibility_server/__init__.py +++ b/eligibility_server/__init__.py @@ -1,3 +1,7 @@ -__version__ = "2023.08.2" +from importlib.metadata import version, PackageNotFoundError -VERSION = __version__ +try: + __version__ = version("eligibility-server") +except PackageNotFoundError: + # package is not installed + pass diff --git a/pyproject.toml b/pyproject.toml index b3d65a34..b4d15f67 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,11 @@ -[build-system] -requires = ["setuptools>=65", "wheel"] -build-backend = "setuptools.build_meta" - [project] -classifiers = ["Programming Language :: Python :: 3 :: Only"] +name = "eligibility-server" +version = "2023.09.1" description = "Server implementation of the Eligibility Verification API" +readme = "README.md" +license = { file = "LICENSE" } +classifiers = ["Programming Language :: Python :: 3 :: Only"] +requires-python = ">=3.9" dependencies = [ "eligibility-api==2023.9.1", "Flask==2.3.3", @@ -12,12 +13,6 @@ dependencies = [ "Flask-SQLAlchemy==3.1.1", "requests==2.31.0" ] -dynamic = ["version"] -keywords = ["flask"] -license = { file = "LICENSE" } -name = "eligibility-server" -readme = "README.md" -requires-python = ">=3.9" [project.optional-dependencies] dev = [ @@ -36,7 +31,10 @@ Code = "https://github.com/cal-itp/eligibility-server" Documentation = "https://docs.calitp.org/eligibility-server" Issues = "https://github.com/cal-itp/eligibility-server/issues" -# Configuration for black +[build-system] +requires = ["setuptools>=65", "wheel"] +build-backend = "setuptools.build_meta" + [tool.black] line-length = 127 target-version = ['py310'] diff --git a/tests/test_app.py b/tests/test_app.py index 341e9700..ea8e6850 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -1,6 +1,7 @@ """ Test app """ +import re from eligibility_server.settings import APP_NAME from eligibility_server.keypair import get_server_public_key @@ -31,3 +32,10 @@ def test_publickey(client): assert response.status_code == 200 assert response.mimetype == "text/plain" assert response.text == get_server_public_key().decode("utf-8") + + +def test_version(): + from eligibility_server import __version__ + + assert __version__ is not None + assert re.match(r"\d{4}\.\d{1,2}\.\d+", __version__)