From 206227af426d4928f0bbff29b1a3c26b39fe5f8d Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Tue, 19 Apr 2022 15:09:30 +0200 Subject: [PATCH 1/7] Use importlib instead of pkg_resources Use importlib_metadata for Python < 3.8. --- .gitignore | 2 +- pnoise/__init__.py | 7 +++++-- setup.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index b6e4761..8690c8f 100644 --- a/.gitignore +++ b/.gitignore @@ -105,7 +105,7 @@ celerybeat.pid .env .venv env/ -venv/ +venv*/ ENV/ env.bak/ venv.bak/ diff --git a/pnoise/__init__.py b/pnoise/__init__.py index d988735..701eeca 100644 --- a/pnoise/__init__.py +++ b/pnoise/__init__.py @@ -2,9 +2,12 @@ def _get_version() -> str: - import pkg_resources + try: + from importlib.metadata import version + except ModuleNotFoundError: + from importlib_metadata import version - return pkg_resources.get_distribution("pnoise").version + return version(__name__) __version__ = _get_version() diff --git a/setup.py b/setup.py index 4e4fc9f..25df51f 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ python_requires=">=3.6", install_requires=[ "numpy>=1.19", - "setuptools", + "importlib_metadata;python_version<'3.8'", ], classifiers=[ "License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)", From 4d166ea982f9fe4f30c1d1bc42e173c5d5088ff6 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Tue, 19 Apr 2022 15:18:29 +0200 Subject: [PATCH 2/7] Pinned black to 22.3.0 to fix CI --- dev-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 8917883..1abc22a 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,4 +1,4 @@ -black +black>=22.3.0 isort mypy pytest From b898b54d46ca8b8e0029f60a0e4016f1338b18b1 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Tue, 19 Apr 2022 15:20:59 +0200 Subject: [PATCH 3/7] Pinned click to <8.1 --- dev-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dev-requirements.txt b/dev-requirements.txt index 1abc22a..518cd27 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,4 +1,5 @@ black>=22.3.0 +click<8.1 # fix error with black isort mypy pytest From 81c5fcf3c20c0675c5c1067bd9068f6f4985b9c6 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Tue, 19 Apr 2022 15:31:10 +0200 Subject: [PATCH 4/7] Cleaned up CI --- .github/workflows/python-lint-tests.yml | 58 ++++++++----------------- 1 file changed, 17 insertions(+), 41 deletions(-) diff --git a/.github/workflows/python-lint-tests.yml b/.github/workflows/python-lint-tests.yml index caa254f..623dd16 100644 --- a/.github/workflows/python-lint-tests.yml +++ b/.github/workflows/python-lint-tests.yml @@ -11,50 +11,11 @@ on: - release/* jobs: - - ########### - # LINTING # - ########### - linting: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.9 - # Cache pip - - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip - restore-keys: ${{ runner.os }}-pip - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install . - python -m pip install mypy black isort - - name: Python Code Quality and Lint - uses: abey79/python-lint@master - with: - python-root-list: "pnoise tests" - use-pylint: false - use-pycodestyle: false - use-flake8: false - use-black: true - extra-black-options: --diff - use-mypy: true - use-isort: true - - ######### - # TESTS # - ######### - tests: - needs: linting + lint-and-tests: strategy: fail-fast: true matrix: - python-version: [3.7, 3.8, 3.9] + python-version: [3.6, 3.7, 3.8, 3.9, 3.10] os: [ubuntu-latest, macos-latest, windows-latest] defaults: run: @@ -63,14 +24,29 @@ jobs: steps: - uses: actions/checkout@v2 + name: Checkout code + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + + - name: Cache + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-${{ matrix.python-version }}-pip + - name: Install dependencies run: | pip install . pip install -r dev-requirements.txt + + - name: Lint + run: | + black --diff pnoise tests + isort --check --diff pnoise tests + - name: Pytest run: | pytest From 924b62478810aa0fded8326bc4d74246f60bde43 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Tue, 19 Apr 2022 15:31:49 +0200 Subject: [PATCH 5/7] fixed for 3.10 --- .github/workflows/python-lint-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-lint-tests.yml b/.github/workflows/python-lint-tests.yml index 623dd16..0ad470f 100644 --- a/.github/workflows/python-lint-tests.yml +++ b/.github/workflows/python-lint-tests.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: true matrix: - python-version: [3.6, 3.7, 3.8, 3.9, 3.10] + python-version: [3.6, 3.7, 3.8, 3.9, "3.10"] os: [ubuntu-latest, macos-latest, windows-latest] defaults: run: From 8fc1375f88399a87b2e5a3fd7fd4f5b9cdbfe60e Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Tue, 19 Apr 2022 15:36:27 +0200 Subject: [PATCH 6/7] cleaned dev-requirements and removed cache --- .github/workflows/python-lint-tests.yml | 6 ------ dev-requirements.txt | 3 +-- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/python-lint-tests.yml b/.github/workflows/python-lint-tests.yml index 0ad470f..fcae88c 100644 --- a/.github/workflows/python-lint-tests.yml +++ b/.github/workflows/python-lint-tests.yml @@ -31,12 +31,6 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Cache - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-${{ matrix.python-version }}-pip - - name: Install dependencies run: | pip install . diff --git a/dev-requirements.txt b/dev-requirements.txt index 518cd27..8917883 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,5 +1,4 @@ -black>=22.3.0 -click<8.1 # fix error with black +black isort mypy pytest From ac05e244a2c28b461f10ac3d22f03490e3ca10fc Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Tue, 19 Apr 2022 15:40:37 +0200 Subject: [PATCH 7/7] final fix --- .github/workflows/python-lint-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-lint-tests.yml b/.github/workflows/python-lint-tests.yml index fcae88c..e8713c4 100644 --- a/.github/workflows/python-lint-tests.yml +++ b/.github/workflows/python-lint-tests.yml @@ -38,7 +38,7 @@ jobs: - name: Lint run: | - black --diff pnoise tests + black --check --diff pnoise tests isort --check --diff pnoise tests - name: Pytest