diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 77961428..25f7b715 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -51,7 +51,7 @@ jobs: - name: Build wheels env: CIBW_ARCHS_LINUX: ${{matrix.arch}} - CIBW_BUILD: cp36-* cp37-* cp38-* cp39-* + CIBW_BUILD: cp37-* cp38-* cp39-* cp310-* CIBW_SKIP: '*-musllinux*' CIBW_BEFORE_BUILD_LINUX: pip install -r requirements-cython.txt && yum install -y zlib-devel # On windows and mac we should have z library preinstalled @@ -74,19 +74,14 @@ jobs: strategy: matrix: - python: [3.6, 3.7, 3.8, 3.9] + # 3.10 is excluded because docker's dependency on pywin32==227 + python: ["3.7", "3.8", "3.9"] include: - - python: 3.6 - snappy_whl: tools/python_snappy-0.5.4-cp36-cp36m-win_amd64.whl - aiokafka_whl: dist/aiokafka-*-cp36-cp36m-win_amd64.whl - - python: 3.7 - snappy_whl: tools/python_snappy-0.5.4-cp37-cp37m-win_amd64.whl + - python: "3.7" aiokafka_whl: dist/aiokafka-*-cp37-cp37m-win_amd64.whl - - python: 3.8 - snappy_whl: tools/python_snappy-0.5.4-cp38-cp38-win_amd64.whl + - python: "3.8" aiokafka_whl: dist/aiokafka-*-cp38-cp38-win_amd64.whl - - python: 3.9 - snappy_whl: tools/python_snappy-0.5.4-cp39-cp39-win_amd64.whl + - python: "3.9" aiokafka_whl: dist/aiokafka-*-cp39-cp39-win_amd64.whl steps: @@ -104,7 +99,6 @@ jobs: - name: Install python dependencies run: | pip install --upgrade pip setuptools wheel - pip install ${{ matrix.snappy_whl }} pip install -r requirements-win-test.txt pip install ${{ matrix.aiokafka_whl }} shell: bash @@ -122,16 +116,16 @@ jobs: strategy: matrix: - python: [3.6, 3.7, 3.8, 3.9] + python: ["3.7", "3.8", "3.9", "3.10"] include: - - python: 3.6 - aiokafka_whl: dist/aiokafka-*-cp36-cp36m-macosx_10_9_x86_64.whl - - python: 3.7 + - python: "3.7" aiokafka_whl: dist/aiokafka-*-cp37-cp37m-macosx_10_9_x86_64.whl - - python: 3.8 + - python: "3.8" aiokafka_whl: dist/aiokafka-*-cp38-cp38-macosx_10_9_x86_64.whl - - python: 3.9 + - python: "3.9" aiokafka_whl: dist/aiokafka-*-cp39-cp39-macosx_10_9_x86_64.whl + - python: "3.10" + aiokafka_whl: dist/aiokafka-*-cp310-cp310-macosx_10_9_x86_64.whl steps: - uses: actions/checkout@v2 @@ -166,16 +160,16 @@ jobs: strategy: matrix: - python: [3.6, 3.7, 3.8.5, 3.9] + python: ["3.7", "3.8", "3.9", "3.10"] include: - - python: 3.6 - aiokafka_whl: dist/aiokafka-*-cp36-cp36m-manylinux*_x86_64.whl - - python: 3.7 + - python: "3.7" aiokafka_whl: dist/aiokafka-*-cp37-cp37m-manylinux*_x86_64.whl - - python: 3.8.5 + - python: "3.8" aiokafka_whl: dist/aiokafka-*-cp38-cp38-manylinux*_x86_64.whl - - python: 3.9 + - python: "3.9" aiokafka_whl: dist/aiokafka-*-cp39-cp39-manylinux*_x86_64.whl + - python: "3.10" + aiokafka_whl: dist/aiokafka-*-cp310-cp310-manylinux*_x86_64.whl steps: - uses: actions/checkout@v2 @@ -200,8 +194,6 @@ jobs: pip install ${{ matrix.aiokafka_whl }} - name: Run Unit Tests - # FIXME 3.8.6 and 3.9.0 have broken `wait_for` - if: ${{ matrix.python != '3.9' }} run: | # Remove source code to be sure we use wheel code rm -rf aiokafka @@ -217,14 +209,14 @@ jobs: strategy: matrix: include: - - pyver: cp36-cp36m - aiokafka_whl: dist/aiokafka-*-cp36-cp36m-manylinux*_aarch64.whl - pyver: cp37-cp37m aiokafka_whl: dist/aiokafka-*-cp37-cp37m-manylinux*_aarch64.whl - pyver: cp38-cp38 aiokafka_whl: dist/aiokafka-*-cp38-cp38-manylinux*_aarch64.whl - pyver: cp39-cp39 aiokafka_whl: dist/aiokafka-*-cp39-cp39-manylinux*_aarch64.whl + - pyver: cp310-cp310 + aiokafka_whl: dist/aiokafka-*-cp310-cp310-manylinux*_aarch64.whl steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fd4f864a..2604f2f4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -73,7 +73,8 @@ jobs: strategy: matrix: - python: [3.6, 3.7, 3.8, 3.9] + # 3.10 is excluded because docker's dependency on pywin32==227 + python: ["3.7", "3.8", "3.9"] steps: - uses: actions/checkout@v2 @@ -141,7 +142,7 @@ jobs: strategy: matrix: - python: [3.6, 3.7, 3.8, 3.9] + python: ["3.7", "3.8", "3.9", "3.10"] steps: - uses: actions/checkout@v2 @@ -214,53 +215,53 @@ jobs: strategy: matrix: include: - - python: 3.9 + - python: "3.10" kafka: "2.8.1" scala: "2.13" # Older python versions against latest broker - - python: 3.6 + - python: "3.7" kafka: "2.8.1" scala: "2.13" - - python: 3.7 + - python: "3.8" kafka: "2.8.1" scala: "2.13" - - python: 3.8 + - python: "3.9" kafka: "2.8.1" scala: "2.13" - # Older/newer brokers against latest python version - - python: 3.9 + # Older brokers against latest python version + - python: "3.10" kafka: "0.9.0.1" scala: "2.11" - - python: 3.9 + - python: "3.10" kafka: "0.10.2.1" scala: "2.11" - - python: 3.9 + - python: "3.10" kafka: "0.11.0.3" scala: "2.12" - - python: 3.9 + - python: "3.10" kafka: "1.1.1" scala: "2.12" - - python: 3.9 + - python: "3.10" kafka: "2.1.1" scala: "2.12" - - python: 3.9 + - python: "3.10" kafka: "2.2.2" scala: "2.12" - - python: 3.9 + - python: "3.10" kafka: "2.3.1" scala: "2.12" - - python: 3.9 + - python: "3.10" kafka: "2.4.1" scala: "2.12" - - python: 3.9 + - python: "3.10" kafka: "2.5.1" scala: "2.12" - - python: 3.9 + - python: "3.10" kafka: "2.6.3" scala: "2.12" - - python: 3.9 + - python: "3.10" kafka: "2.7.2" scala: "2.13" fail-fast: false diff --git a/CHANGES/841.feature b/CHANGES/841.feature new file mode 100644 index 00000000..6694b9fc --- /dev/null +++ b/CHANGES/841.feature @@ -0,0 +1,2 @@ +Drop support for Python 3.6, add support and pre-built packages for Python 3.10 +(pr #841) diff --git a/Makefile b/Makefile index ba4e4211..71010993 100644 --- a/Makefile +++ b/Makefile @@ -27,20 +27,20 @@ lint: mypy --install-types --non-interactive $(FORMATTED_AREAS) test: flake - py.test -s --show-capture=no --docker-image $(DOCKER_IMAGE) $(FLAGS) tests + pytest -s --show-capture=no --docker-image $(DOCKER_IMAGE) $(FLAGS) tests vtest: flake - py.test -s -v --log-level INFO --docker-image $(DOCKER_IMAGE) $(FLAGS) tests + pytest -s -v --log-level INFO --docker-image $(DOCKER_IMAGE) $(FLAGS) tests cov cover coverage: flake - py.test -s --cov aiokafka --cov-report html --docker-image $(DOCKER_IMAGE) $(FLAGS) tests + pytest -s --cov aiokafka --cov-report html --docker-image $(DOCKER_IMAGE) $(FLAGS) tests @echo "open file://`pwd`/htmlcov/index.html" ci-test-unit: - py.test -s --log-format="%(asctime)s %(levelname)s %(message)s" --log-level DEBUG --cov aiokafka --cov-report xml --color=yes $(FLAGS) tests + pytest -s --log-format="%(asctime)s %(levelname)s %(message)s" --log-level DEBUG --cov aiokafka --cov-report xml --color=yes $(FLAGS) tests ci-test-all: - py.test -s -v --log-format="%(asctime)s %(levelname)s %(message)s" --log-level DEBUG --cov aiokafka --cov-report xml --color=yes --docker-image $(DOCKER_IMAGE) $(FLAGS) tests + pytest -s -v --log-format="%(asctime)s %(levelname)s %(message)s" --log-level DEBUG --cov aiokafka --cov-report xml --color=yes --docker-image $(DOCKER_IMAGE) $(FLAGS) tests coverage.xml: .coverage coverage xml diff --git a/aiokafka/util.py b/aiokafka/util.py index 58398666..38a08baf 100644 --- a/aiokafka/util.py +++ b/aiokafka/util.py @@ -1,7 +1,7 @@ import asyncio import os from asyncio import AbstractEventLoop -from typing import Awaitable, Dict, Tuple, TypeVar, Union, cast +from typing import Any, Awaitable, Coroutine, Dict, Tuple, TypeVar, Union, cast import async_timeout from packaging.version import Version @@ -21,7 +21,7 @@ T = TypeVar("T") -def create_task(coro: Awaitable[T]) -> "asyncio.Task[T]": +def create_task(coro: Coroutine[Any, Any, T]) -> "asyncio.Task[T]": loop = get_running_loop() return loop.create_task(coro) diff --git a/pytest.ini b/pytest.ini index c3d76d9c..6cef3385 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,10 +1,15 @@ [pytest] filterwarnings = error + # FIXME Until we fix socket leaks in tests + default:unclosed event loop:ResourceWarning # https://github.com/docker/docker-py/issues/1293 ignore:.*docker.sock.*:ResourceWarning - ignore:distutils Version classes are deprecated:DeprecationWarning:docker + ignore:distutils .* deprecated:DeprecationWarning:docker + # From gssapi, but with improper stack + ignore:_SixMetaPathImporter.*not found:ImportWarning # Actually comes from docker importing distutils on Windows ignore:the imp module is deprecated in favour of importlib:DeprecationWarning:pywintypes markers = ssl: Tests that require SSL certificates to run +asyncio_mode = auto diff --git a/requirements-ci.txt b/requirements-ci.txt index aed194a7..7fd06fc0 100644 --- a/requirements-ci.txt +++ b/requirements-ci.txt @@ -1,19 +1,18 @@ -r requirements-cython.txt flake8==4.0.1 black==22.3.0 -mypy==0.910 +mypy==0.961 isort[colors]==5.10.0 -pytest==6.1.2 +pytest==7.1.2 pytest-cov==3.0.0 -pytest-asyncio==0.16.0 +pytest-asyncio==0.18.3 docker==5.0.3 +chardet==4.0.0 # Until fixed requests is released lz4==3.1.3 xxhash==2.0.2 -python-snappy==0.6.0 +python-snappy==0.6.1 docutils==0.17.1 Pygments==2.10.0 -gssapi==1.7.2 -dataclasses==0.8; python_version<"3.7" -async_generator==1.10; python_version<"3.7" +gssapi==1.7.3 async-timeout==4.0.1 zstandard==0.16.0 diff --git a/requirements-cython.txt b/requirements-cython.txt index 5e539661..ba59537d 100644 --- a/requirements-cython.txt +++ b/requirements-cython.txt @@ -1 +1 @@ -Cython==0.29.24 +Cython==0.29.30 diff --git a/requirements-win-test.txt b/requirements-win-test.txt index 3a7b4db7..8d010641 100644 --- a/requirements-win-test.txt +++ b/requirements-win-test.txt @@ -1,15 +1,14 @@ -r requirements-cython.txt flake8==4.0.1 black==22.3.0 -mypy==0.910 +mypy==0.961 isort[colors]==5.10.0 -pytest==6.1.2 +pytest==7.1.2 pytest-cov==3.0.0 -pytest-asyncio==0.16.0 +pytest-asyncio==0.18.3 docker==5.0.3 +chardet==4.0.0 # Until fixed requests is released lz4==3.1.3 xxhash==2.0.2 -python-snappy==0.6.0 -dataclasses==0.8; python_version<"3.7" -async_generator==1.10; python_version<"3.7" +python-snappy==0.6.1 zstandard==0.16.0 diff --git a/setup.py b/setup.py index d4194c71..dfae7d45 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,6 @@ import os import platform import re -import sys from setuptools import Extension, setup from setuptools.command.bdist_rpm import bdist_rpm as _bdist_rpm @@ -114,15 +113,9 @@ def build_extension(self, ext): install_requires = [ "async-timeout", "kafka-python>=2.0.2", - "dataclasses>=0.5; python_version<'3.7'", "packaging", ] -PY_VER = sys.version_info - -if PY_VER < (3, 6): - raise RuntimeError("aiokafka doesn't support Python earlier than 3.6") - def read(f): return open(os.path.join(os.path.dirname(__file__), f)).read().strip() @@ -153,10 +146,10 @@ def read_version(): "License :: OSI Approved :: Apache Software License", "Intended Audience :: Developers", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Operating System :: OS Independent", "Topic :: System :: Networking", "Topic :: System :: Distributed Computing", @@ -181,6 +174,7 @@ def read_version(): download_url="https://pypi.python.org/pypi/aiokafka", license="Apache 2", packages=["aiokafka"], + python_requires=">=3.7", install_requires=install_requires, extras_require=extras_require, include_package_data=True, diff --git a/tests/conftest.py b/tests/conftest.py index 8d8767a6..7a1338ab 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -124,7 +124,7 @@ def ssl_folder(docker_ip_address, docker, kafka_image): container = docker.containers.run( image=kafka_image, - command="sleep 120", + command="sleep 300", volumes={ pathlib.Path("gen-ssl-certs.sh").resolve(): { "bind": "/gen-ssl-certs.sh", diff --git a/tests/test_fetcher.py b/tests/test_fetcher.py index 9b7368f3..2d204910 100644 --- a/tests/test_fetcher.py +++ b/tests/test_fetcher.py @@ -56,10 +56,7 @@ def test_fetch_result_and_error(loop): # Python3.7 got rid of trailing comma in exceptions, which makes the line # different between 3.6 and 3.7. - assert repr(error) in [ - "", - "" - ] + assert repr(error) == "" @pytest.mark.usefixtures('setup_test_class_serverless') diff --git a/tests/test_subscription_state.py b/tests/test_subscription_state.py index de217ce8..44c77719 100644 --- a/tests/test_subscription_state.py +++ b/tests/test_subscription_state.py @@ -6,9 +6,6 @@ from aiokafka.structs import TopicPartition from aiokafka.abc import ConsumerRebalanceListener -# All test coroutines will be treated as marked. -pytestmark = pytest.mark.asyncio - @pytest.fixture async def subscription_state(): diff --git a/tests/test_transaction_manager.py b/tests/test_transaction_manager.py index bbe7ed7f..1630e89f 100644 --- a/tests/test_transaction_manager.py +++ b/tests/test_transaction_manager.py @@ -8,10 +8,8 @@ @pytest.fixture -def txn_manager(loop): - async def init(): - return TransactionManager("txn_id", 20000) - return loop.run_until_complete(init()) +async def txn_manager(): + return TransactionManager("txn_id", 20000) def test_txn_manager(txn_manager):