Skip to content

Commit 80489c5

Browse files
authored
Use importlib instead of pkg_resources (#2)
- use importlib/importlib_metadata instead of pkg_resource for `__version__` - streamlined CI and added support for 3.6 to 3.10
1 parent 8f47bfd commit 80489c5

File tree

4 files changed

+18
-45
lines changed

4 files changed

+18
-45
lines changed

.github/workflows/python-lint-tests.yml

Lines changed: 11 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,50 +11,11 @@ on:
1111
- release/*
1212

1313
jobs:
14-
15-
###########
16-
# LINTING #
17-
###########
18-
linting:
19-
runs-on: ubuntu-latest
20-
steps:
21-
- uses: actions/checkout@v2
22-
- name: Set up Python
23-
uses: actions/setup-python@v2
24-
with:
25-
python-version: 3.9
26-
# Cache pip
27-
- uses: actions/cache@v2
28-
with:
29-
path: ~/.cache/pip
30-
key: ${{ runner.os }}-pip
31-
restore-keys: ${{ runner.os }}-pip
32-
- name: Install dependencies
33-
run: |
34-
python -m pip install --upgrade pip
35-
python -m pip install .
36-
python -m pip install mypy black isort
37-
- name: Python Code Quality and Lint
38-
uses: abey79/python-lint@master
39-
with:
40-
python-root-list: "pnoise tests"
41-
use-pylint: false
42-
use-pycodestyle: false
43-
use-flake8: false
44-
use-black: true
45-
extra-black-options: --diff
46-
use-mypy: true
47-
use-isort: true
48-
49-
#########
50-
# TESTS #
51-
#########
52-
tests:
53-
needs: linting
14+
lint-and-tests:
5415
strategy:
5516
fail-fast: true
5617
matrix:
57-
python-version: [3.7, 3.8, 3.9]
18+
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
5819
os: [ubuntu-latest, macos-latest, windows-latest]
5920
defaults:
6021
run:
@@ -63,14 +24,23 @@ jobs:
6324

6425
steps:
6526
- uses: actions/checkout@v2
27+
name: Checkout code
28+
6629
- name: Set up Python ${{ matrix.python-version }}
6730
uses: actions/setup-python@v2
6831
with:
6932
python-version: ${{ matrix.python-version }}
33+
7034
- name: Install dependencies
7135
run: |
7236
pip install .
7337
pip install -r dev-requirements.txt
38+
39+
- name: Lint
40+
run: |
41+
black --check --diff pnoise tests
42+
isort --check --diff pnoise tests
43+
7444
- name: Pytest
7545
run: |
7646
pytest

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ celerybeat.pid
105105
.env
106106
.venv
107107
env/
108-
venv/
108+
venv*/
109109
ENV/
110110
env.bak/
111111
venv.bak/

pnoise/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33

44
def _get_version() -> str:
5-
import pkg_resources
5+
try:
6+
from importlib.metadata import version
7+
except ModuleNotFoundError:
8+
from importlib_metadata import version
69

7-
return pkg_resources.get_distribution("pnoise").version
10+
return version(__name__)
811

912

1013
__version__ = _get_version()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
python_requires=">=3.6",
2020
install_requires=[
2121
"numpy>=1.19",
22-
"setuptools",
22+
"importlib_metadata;python_version<'3.8'",
2323
],
2424
classifiers=[
2525
"License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",

0 commit comments

Comments
 (0)