From 38675277c615590be7e5acae72498ba0906b05e2 Mon Sep 17 00:00:00 2001 From: Mihai Cara Date: Sat, 11 Nov 2023 04:44:57 -0500 Subject: [PATCH] Use importlib instead of deprecated pkg_resources (#25) Use importlib instead of deprecated pkg_resources --- azure-pipelines.yml | 2 ++ azure-templates.yml | 7 ++++--- setup.py | 2 +- wiimatch/__init__.py | 7 +++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 64b9cb5..0c1b964 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -53,6 +53,8 @@ jobs: architecture: 'x64' - script: | + python -m pip install setuptools + python -m pip install setuptools_scm python -m pip install astropy python setup.py sdist displayName: 'Build sdist' diff --git a/azure-templates.yml b/azure-templates.yml index 2cd87bd..96a71b5 100644 --- a/azure-templates.yml +++ b/azure-templates.yml @@ -10,12 +10,14 @@ jobs: strategy: matrix: - Python38: - python.version: '3.8' Python39: python.version: '3.9' Python310: python.version: '3.10' + Python311: + python.version: '3.11' + Python312: + python.version: '3.12' maxParallel: 4 steps: @@ -69,4 +71,3 @@ jobs: inputs: testResultsFiles: '**/test-*.xml' testRunTitle: 'Python $(python.version)-${{ format(parameters.name) }}' - diff --git a/setup.py b/setup.py index de98f3c..7ecf061 100755 --- a/setup.py +++ b/setup.py @@ -91,7 +91,7 @@ ], use_scm_version=True, setup_requires=SETUP_REQUIRES, - python_requires='>=3.5', + python_requires='>=3.7', install_requires=INSTALL_REQUIRES, tests_require=TESTS_REQUIRE, packages=find_packages(), diff --git a/wiimatch/__init__.py b/wiimatch/__init__.py index deaf3f0..9aa000f 100755 --- a/wiimatch/__init__.py +++ b/wiimatch/__init__.py @@ -1,15 +1,14 @@ """wiimatch""" -from pkg_resources import get_distribution, DistributionNotFound __docformat__ = 'restructuredtext en' __author__ = 'Mihai Cara' +from importlib.metadata import PackageNotFoundError, version try: - __version__ = get_distribution(__name__).version -except DistributionNotFound: - # package is not installed + __version__ = version(__name__) +except PackageNotFoundError: __version__ = 'UNKNOWN'