From 42180137e04b876d958045d01754032a84d4c566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Raimbault?= Date: Fri, 2 Sep 2022 17:23:45 +0200 Subject: [PATCH] Don't duplicate version in __init__.py and pyproject.toml Support of Python <= 3.7 is a bit more complicated. To simplify when the support will be dropped. --- django_auth_adfs/__init__.py | 15 +++++++++------ pyproject.toml | 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/django_auth_adfs/__init__.py b/django_auth_adfs/__init__.py index 6a74b3d..ed49459 100644 --- a/django_auth_adfs/__init__.py +++ b/django_auth_adfs/__init__.py @@ -1,7 +1,10 @@ -""" -Don't put imports or code here -This file is imported by setup.py -Adding imports here will break setup.py -""" +import sys -__version__ = '1.11.0' +if sys.version_info[:2] >= (3, 8): + from importlib import metadata +else: + import importlib_metadata as metadata + +__version__ = metadata.version(__package__) + +del metadata # optional, avoids polluting the results of dir(__package__) diff --git a/pyproject.toml b/pyproject.toml index b114b1e..65aa001 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = 'django-auth-adfs' -version = "1.11.0" # Remember to also change __init__.py version +version = "1.11.0" description = 'A Django authentication backend for Microsoft ADFS and AzureAD' authors = ['Joris Beckers '] maintainers = ['Jonas Krüger Svensson ', 'Sondre Lillebø Gundersen '] @@ -43,6 +43,7 @@ requests = '^1 || ^2' urllib3 = '^1.26.0' cryptography = '>=1.7,<39.0' PyJWT = "^2.4.0" +importlib-metadata = {version = ">=1.7.0", python = "<3.8"} [tool.poetry.dev-dependencies] responses = '*'