Skip to content

Commit c175815

Browse files
authored
Use importlib instead of pkg_resources (#49)
* Add setuptools to dependencies, update dependencies * Use importlib instead of pkg_resources * Fix flake8 errors
1 parent ecde835 commit c175815

File tree

10 files changed

+20
-15
lines changed

10 files changed

+20
-15
lines changed

.github/workflows/python-package.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@ jobs:
1919
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
2020

2121
steps:
22-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
2323
- name: Set up Python ${{ matrix.python-version }}
2424
uses: actions/setup-python@v4
2525
with:
2626
python-version: ${{ matrix.python-version }}
2727
- name: Install dependencies
2828
run: |
2929
python -m pip install --upgrade pip
30-
python -m pip install flake8
3130
pip install -r requirements.txt -r dev-requirements.txt
3231
pip install -e .
3332
- name: Lint with flake8
@@ -36,6 +35,8 @@ jobs:
3635
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
3736
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
3837
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
38+
- name: Lint with PyLint
39+
run: pylint --rcfile=.pylintrc src/aws_secretsmanager_caching
3940
- name: Test with pytest
4041
run: |
4142
pytest test/unit/

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ To use this client you must have:
2323
This library requires the following standard dependencies:
2424
* botocore
2525
* setuptools_scm
26+
* setuptools
2627

2728
For development and testing purposes, this library requires the following additional dependencies:
2829
* pytest
@@ -31,6 +32,8 @@ For development and testing purposes, this library requires the following additi
3132
* codecov
3233
* pylint
3334
* sphinx
35+
* flake8
36+
* tox
3437

3538
Please review the `requirements.txt` and `dev-requirements.txt` file for specific version requirements.
3639

dev-requirements.txt

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
pytest
2-
pytest-cov
3-
pytest-sugar
1+
pytest>=8
2+
pytest-cov>=5
3+
pytest-sugar>=1
44
codecov>=1.4.0
55
pylint>1.9.4
66
sphinx>=1.8.4
7+
tox>=4
8+
flake8>=7

doc/conf.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
from importlib.metadata import version
12
from datetime import datetime
2-
from pkg_resources import get_distribution
33
import os
44
import shutil
55

6-
version = get_distribution('aws_secretsmanager_caching').version
76
project = u'AWS Secrets Manager Python Caching Client'
87

98
# If you use autosummary, this ensures that any stale autogenerated files are
@@ -32,7 +31,7 @@
3231
copyright = u'%s, Amazon.com' % datetime.now().year
3332

3433
# The full version, including alpha/beta/rc tags.
35-
release = version
34+
release = version('aws_secretsmanager_caching')
3635

3736
# List of directories, relative to source directory, that shouldn't be searched
3837
# for source files.

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
botocore>=1.12
22
setuptools_scm>=3.2
3+
setuptools>=69

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ description-file = README.md
1616
license_file = LICENSE
1717

1818
[flake8]
19-
max-line-length = 120
19+
max-line-length = 127
2020
select = C,E,F,W,B
2121
# C812, W503 clash with black
2222
ignore = C812,W503

src/aws_secretsmanager_caching/cache/items.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def get_secret_value(self, version_stage=None):
123123
if not value and self._exception:
124124
raise self._exception
125125
return deepcopy(value)
126-
126+
127127
def refresh_secret_now(self):
128128
"""Force a refresh of the cached secret.
129129
:rtype: None

src/aws_secretsmanager_caching/secret_cache.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
"""High level AWS Secrets Manager caching client."""
1414
from copy import deepcopy
1515

16+
from importlib.metadata import version, PackageNotFoundError
1617
import botocore.config
1718
import botocore.session
18-
from pkg_resources import DistributionNotFound, get_distribution
1919

2020
from .cache import LRUCache, SecretCacheItem
2121
from .config import SecretCacheConfig
@@ -25,8 +25,8 @@ class SecretCache:
2525
"""Secret Cache client for AWS Secrets Manager secrets"""
2626

2727
try:
28-
__version__ = get_distribution('aws_secretsmanager_caching').version
29-
except DistributionNotFound:
28+
__version__ = version('aws_secretsmanager_caching')
29+
except PackageNotFoundError:
3030
__version__ = '0.0.0'
3131

3232
def __init__(self, config=SecretCacheConfig(), client=None):

test/unit/test_items.py

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ def test_refresh_now(self):
7373
# The new refresh time will be between now + ttl and now + (ttl / 2) if the secret was immediately refreshed
7474
self.assertTrue(new_refresh_time < old_refresh_time and new_refresh_time < datetime.now(timezone.utc) + timedelta(ttl))
7575

76-
7776
def test_datetime_fix_is_refresh_needed(self):
7877
secret_cached_object = TestSecretCacheObject.TestObject(SecretCacheConfig(), None, None)
7978

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
[tox]
8-
envlist = py36, py37, flake8, pylint
8+
envlist = py38, py39, py310, py311, py312, flake8, pylint
99
skip_missing_interpreters = true
1010

1111
[testenv]

0 commit comments

Comments
 (0)