From fc0a222f7cca58e2f1198587587ec9fcb27c886b Mon Sep 17 00:00:00 2001 From: Greg Lindahl Date: Fri, 16 Aug 2024 20:35:04 +0000 Subject: [PATCH 1/4] add 3.12 and 3.13.0-rc.1 to the matrix --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index edd11ab0..c811db79 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,12 +8,12 @@ jobs: strategy: max-parallel: 3 matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13.0-rc.1'] steps: - name: checkout uses: actions/checkout@v4 - + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: From 52dd0ab454b0fc6ed6e32a0990aced0aa30420c5 Mon Sep 17 00:00:00 2001 From: Greg Lindahl Date: Fri, 16 Aug 2024 20:40:06 +0000 Subject: [PATCH 2/4] Revert "add 3.12 and 3.13.0-rc.1 to the matrix" This reverts commit fc0a222f7cca58e2f1198587587ec9fcb27c886b. --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c811db79..edd11ab0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,12 +8,12 @@ jobs: strategy: max-parallel: 3 matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13.0-rc.1'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] steps: - name: checkout uses: actions/checkout@v4 - + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: From 29da91683a7b88b20d4cd12f9d8a8819dd3531cb Mon Sep 17 00:00:00 2001 From: Natanael Arndt Date: Tue, 20 Aug 2024 10:36:44 +0200 Subject: [PATCH 3/4] feat: use importlib instead of deprecated pkg_resources for version * Add very simple test for version argument * Add python 3.7 compatibility for package metadata version --- test/test_cli.py | 6 ++++++ warcio/cli.py | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/test/test_cli.py b/test/test_cli.py index 04e05887..58edc584 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -12,6 +12,12 @@ import tempfile import os +def test_version(capsys): + with pytest.raises(SystemExit): + main(args=['--version']) + out, err = capsys.readouterr() + print(out, err) + assert len(out) > 0 def test_index(capsys): files = ['example.warc.gz', 'example.warc', 'example.arc.gz', 'example.arc'] diff --git a/warcio/cli.py b/warcio/cli.py index efdf7c50..df6369e5 100644 --- a/warcio/cli.py +++ b/warcio/cli.py @@ -5,6 +5,13 @@ from warcio.extractor import Extractor from warcio.recompressor import Recompressor + +try: + from importlib.metadata import version +except ImportError: + import pkg_resources + def version(package): + return pkg_resources.get_distribution(package).version import sys @@ -57,8 +64,7 @@ def main(args=None): # ============================================================================ def get_version(): - import pkg_resources - return '%(prog)s ' + pkg_resources.get_distribution('warcio').version + return '%(prog)s ' + version('warcio') # ============================================================================ From 12eca8599ac8fa2ef4ce391c8f203211f7991743 Mon Sep 17 00:00:00 2001 From: Natanael Arndt Date: Wed, 21 Aug 2024 08:47:14 +0200 Subject: [PATCH 4/4] fix: Run pytest directly. "setup.py test" was removed in setuptools 72. (#172) --- .github/workflows/ci.yaml | 5 ++++- pytest.ini | 5 +++++ setup.py | 27 +++++++++++---------------- 3 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 pytest.ini diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index edd11ab0..be4f6ab8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,8 +27,11 @@ jobs: - name: Install warcio run: python setup.py install + - name: Install test dependencies + run: pip install -e ".[testing]" + - name: Run tests - run: python setup.py test + run: python -m pytest - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 00000000..e9a23779 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,5 @@ +[pytest] +addopts = -v --cov warcio --doctest-modules +testpaths = + warcio + test diff --git a/setup.py b/setup.py index 922c025c..2859d016 100755 --- a/setup.py +++ b/setup.py @@ -14,13 +14,6 @@ def finalize_options(self): # should work with setuptools <18, 18 18.5 self.test_suite = ' ' - def run_tests(self): - import pytest - import sys - import os - errcode = pytest.main(['--doctest-modules', './warcio', '--cov', 'warcio', '-v', 'test/']) - sys.exit(errcode) - setup( name='warcio', version=__version__, @@ -44,15 +37,17 @@ def run_tests(self): """, cmdclass={'test': PyTest}, test_suite='', - tests_require=[ - 'urllib3==1.25.11', - 'pytest', - 'pytest-cov', - 'httpbin>=0.10.2', - 'requests', - 'wsgiprox', - 'hookdns', - ], + extras_require={ + 'testing': [ + 'urllib3==1.25.11', + 'pytest', + 'pytest-cov', + 'httpbin>=0.10.2', + 'requests', + 'wsgiprox', + 'hookdns', + ] + }, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Web Environment',