diff --git a/.ci/.matrix_exclude.yml b/.ci/.matrix_exclude.yml index db796ee34..524291f20 100644 --- a/.ci/.matrix_exclude.yml +++ b/.ci/.matrix_exclude.yml @@ -5,18 +5,12 @@ exclude: # Django 4.0 requires Python 3.8+ - VERSION: pypy-3 # current pypy-3 is compatible with Python 3.7 FRAMEWORK: django-4.0 - - VERSION: python-3.6 - FRAMEWORK: django-4.0 - VERSION: python-3.7 FRAMEWORK: django-4.0 # Django 4.2 requires Python 3.8+ - - VERSION: python-3.6 - FRAMEWORK: django-4.2 - VERSION: python-3.7 FRAMEWORK: django-4.2 # Django 5.0 requires Python 3.10+ - - VERSION: python-3.6 - FRAMEWORK: django-5.0 - VERSION: python-3.7 FRAMEWORK: django-5.0 - VERSION: python-3.8 @@ -25,12 +19,8 @@ exclude: FRAMEWORK: django-5.0 - VERSION: pypy-3 # current pypy-3 is compatible with Python 3.7 FRAMEWORK: celery-5-django-4 - - VERSION: python-3.6 - FRAMEWORK: celery-5-django-4 - VERSION: python-3.7 FRAMEWORK: celery-5-django-4 - - VERSION: python-3.6 - FRAMEWORK: celery-5-django-5 - VERSION: python-3.7 FRAMEWORK: celery-5-django-5 - VERSION: python-3.8 @@ -40,14 +30,6 @@ exclude: # Flask - VERSION: pypy-3 FRAMEWORK: flask-0.11 # see https://github.com/pallets/flask/commit/6e46d0cd, 0.11.2 was never released - - VERSION: python-3.6 - FRAMEWORK: flask-2.1 - - VERSION: python-3.6 - FRAMEWORK: flask-2.2 - - VERSION: python-3.6 - FRAMEWORK: flask-2.3 - - VERSION: python-3.6 - FRAMEWORK: flask-3.0 - VERSION: python-3.7 FRAMEWORK: flask-2.3 - VERSION: python-3.7 @@ -185,8 +167,6 @@ exclude: # pymssql - VERSION: pypy-3 # currently fails with error on pypy3 FRAMEWORK: pymssql-newest - - VERSION: python-3.6 # dropped support for py3.6 - FRAMEWORK: pymssql-newest # pyodbc - VERSION: pypy-3 FRAMEWORK: pyodbc-newest @@ -210,48 +190,28 @@ exclude: # aiohttp client, only supported in Python 3.7+ - VERSION: pypy-3 FRAMEWORK: aiohttp-3.0 - - VERSION: python-3.6 - FRAMEWORK: aiohttp-3.0 - VERSION: pypy-3 FRAMEWORK: aiohttp-4.0 - - VERSION: python-3.6 - FRAMEWORK: aiohttp-4.0 - VERSION: pypy-3 FRAMEWORK: aiohttp-newest - - VERSION: python-3.6 - FRAMEWORK: aiohttp-newest # tornado, only supported in Python 3.7+ - VERSION: pypy-3 FRAMEWORK: tornado-newest - - VERSION: python-3.6 - FRAMEWORK: tornado-newest # Starlette, only supported in python 3.7+ - VERSION: pypy-3 FRAMEWORK: starlette-0.13 - - VERSION: python-3.6 - FRAMEWORK: starlette-0.13 - VERSION: pypy-3 FRAMEWORK: starlette-0.14 - - VERSION: python-3.6 - FRAMEWORK: starlette-0.14 - VERSION: pypy-3 FRAMEWORK: starlette-newest - - VERSION: python-3.6 - FRAMEWORK: starlette-newest # aiopg - VERSION: pypy-3 FRAMEWORK: aiopg-newest - - VERSION: python-3.6 - FRAMEWORK: aiopg-newest # asyncpg - VERSION: pypy-3 FRAMEWORK: asyncpg-newest - VERSION: pypy-3 FRAMEWORK: asyncpg-0.28 - - VERSION: python-3.6 - FRAMEWORK: asyncpg-newest - - VERSION: python-3.6 - FRAMEWORK: asyncpg-0.28 - VERSION: python-3.13 FRAMEWORK: asyncpg-0.28 # sanic @@ -259,10 +219,6 @@ exclude: FRAMEWORK: sanic-newest - VERSION: pypy-3 FRAMEWORK: sanic-20.12 - - VERSION: python-3.6 - FRAMEWORK: sanic-20.12 - - VERSION: python-3.6 - FRAMEWORK: sanic-newest - VERSION: python-3.8 FRAMEWORK: sanic-newest - VERSION: python-3.13 @@ -270,21 +226,13 @@ exclude: # aioredis - VERSION: pypy-3 FRAMEWORK: aioredis-newest - - VERSION: python-3.6 - FRAMEWORK: aioredis-newest # aiomysql - VERSION: pypy-3 FRAMEWORK: aiomysql-newest - - VERSION: python-3.6 - FRAMEWORK: aiomysql-newest # aiobotocore - VERSION: pypy-3 FRAMEWORK: aiobotocore-newest - - VERSION: python-3.6 - FRAMEWORK: aiobotocore-newest # mysql-connector-python - - VERSION: python-3.6 - FRAMEWORK: mysql_connector-newest # twisted - VERSION: python-3.11 FRAMEWORK: twisted-18 @@ -318,8 +266,6 @@ exclude: - VERSION: python-3.13 FRAMEWORK: pylibmc-1.4 # grpc - - VERSION: python-3.6 - FRAMEWORK: grpc-newest - VERSION: python-3.7 FRAMEWORK: grpc-1.24 - VERSION: python-3.8 diff --git a/.ci/.matrix_python.yml b/.ci/.matrix_python.yml index 86c87ad88..1649823b1 100644 --- a/.ci/.matrix_python.yml +++ b/.ci/.matrix_python.yml @@ -1,3 +1,3 @@ VERSION: - - python-3.6 + - python-3.7 - python-3.13 diff --git a/.ci/.matrix_python_full.yml b/.ci/.matrix_python_full.yml index bb763b7ca..98e228991 100644 --- a/.ci/.matrix_python_full.yml +++ b/.ci/.matrix_python_full.yml @@ -1,5 +1,4 @@ VERSION: - - python-3.6 - python-3.7 - python-3.8 - python-3.9 diff --git a/.ci/.matrix_windows.yml b/.ci/.matrix_windows.yml deleted file mode 100644 index 0f12b9422..000000000 --- a/.ci/.matrix_windows.yml +++ /dev/null @@ -1,21 +0,0 @@ -# This is the limited list of matrix builds in Windows, to be triggered on a PR basis -# The format is: -# VERSION: Major.Minor python version. -# FRAMEWORK: What framework to be tested. String format. -# ASYNCIO: Whether it's enabled or disabled. Boolean format. -# -# TODO: Remove this file when fully migrated to GH Actions - -windows: -# - VERSION: "3.6" -# FRAMEWORK: "none" -# ASYNCIO: "true" -# - VERSION: "3.7" -# FRAMEWORK: "none" -# ASYNCIO: "true" - - VERSION: "3.8" - FRAMEWORK: "none" - ASYNCIO: "true" - - VERSION: "3.9" # waiting for greenlet to have binary wheels for 3.9 - FRAMEWORK: "none" - ASYNCIO: "true" diff --git a/.ci/publish-aws.sh b/.ci/publish-aws.sh index 3bb7a554c..137b82ef6 100755 --- a/.ci/publish-aws.sh +++ b/.ci/publish-aws.sh @@ -46,7 +46,7 @@ for region in $ALL_AWS_REGIONS; do --layer-name="${FULL_LAYER_NAME}" \ --description="AWS Lambda Extension Layer for the Elastic APM Python Agent" \ --license-info="BSD-3-Clause" \ - --compatible-runtimes python3.6 python3.7 python3.8 python3.9 python3.10 python3.11 python3.12 python3.13\ + --compatible-runtimes python3.7 python3.8 python3.9 python3.10 python3.11 python3.12 python3.13\ --zip-file="fileb://${zip_file}") echo "${publish_output}" > "${AWS_FOLDER}/${region}" layer_version=$(echo "${publish_output}" | jq '.Version') diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4fc7a275e..bd3f79c76 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -114,9 +114,6 @@ jobs: fail-fast: false matrix: include: - # - version: "3.6" - # framework: "none" - # asyncio: "true" # - version: "3.7" # framework: none # asyncio: true diff --git a/Makefile b/Makefile index b2d00f400..82e4d2fb4 100644 --- a/Makefile +++ b/Makefile @@ -10,14 +10,8 @@ flake8: test: # delete any __pycache__ folders to avoid hard-to-debug caching issues find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete - # pypy3 should be added to the first `if` once it supports py3.7 - if [[ "$$PYTHON_VERSION" =~ ^(3.7|3.8|3.9|3.10|3.11|3.12|3.13|nightly)$$ ]] ; then \ - echo "Python 3.7+, with asyncio"; \ - pytest -v $(PYTEST_ARGS) --showlocals $(PYTEST_MARKER) $(PYTEST_JUNIT); \ - else \ - echo "Python < 3.7, without asyncio"; \ - pytest -v $(PYTEST_ARGS) --showlocals $(PYTEST_MARKER) $(PYTEST_JUNIT) --ignore-glob='*/asyncio*/*'; \ - fi + echo "Python 3.7+, with asyncio"; \ + pytest -v $(PYTEST_ARGS) --showlocals $(PYTEST_MARKER) $(PYTEST_JUNIT); \ coverage: PYTEST_ARGS=--cov --cov-context=test --cov-config=setup.cfg --cov-branch coverage: export COVERAGE_FILE=.coverage.docker.$(PYTHON_FULL_VERSION).$(FRAMEWORK) diff --git a/docs/reference/run-tests-locally.md b/docs/reference/run-tests-locally.md index f72432d7e..689b08524 100644 --- a/docs/reference/run-tests-locally.md +++ b/docs/reference/run-tests-locally.md @@ -53,7 +53,7 @@ $ ./tests/scripts/docker/run_tests.sh python-version framework-version bool: def check_python_version(self) -> None: v = tuple(map(int, platform.python_version_tuple()[:2])) - if v < (3, 6): - warnings.warn("The Elastic APM agent only supports Python 3.6+", DeprecationWarning) + if v < (3, 7): + warnings.warn("The Elastic APM agent only supports Python 3.7+", DeprecationWarning) def check_server_version( self, gte: Optional[Tuple[int, ...]] = None, lte: Optional[Tuple[int, ...]] = None diff --git a/elasticapm/instrumentation/register.py b/elasticapm/instrumentation/register.py index b37aff1e9..3e5d82230 100644 --- a/elasticapm/instrumentation/register.py +++ b/elasticapm/instrumentation/register.py @@ -28,8 +28,6 @@ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -import sys - from elasticapm.utils.module_import import import_string _cls_register = { @@ -70,35 +68,29 @@ "elasticapm.instrumentation.packages.kafka.KafkaInstrumentation", "elasticapm.instrumentation.packages.grpc.GRPCClientInstrumentation", "elasticapm.instrumentation.packages.grpc.GRPCServerInstrumentation", + "elasticapm.instrumentation.packages.asyncio.sleep.AsyncIOSleepInstrumentation", + "elasticapm.instrumentation.packages.asyncio.aiohttp_client.AioHttpClientInstrumentation", + "elasticapm.instrumentation.packages.httpx.async.httpx.HttpxAsyncClientInstrumentation", + "elasticapm.instrumentation.packages.asyncio.elasticsearch.ElasticSearchAsyncConnection", + "elasticapm.instrumentation.packages.asyncio.elasticsearch.ElasticsearchAsyncTransportInstrumentation", + "elasticapm.instrumentation.packages.asyncio.aiopg.AioPGInstrumentation", + "elasticapm.instrumentation.packages.asyncio.asyncpg.AsyncPGInstrumentation", + "elasticapm.instrumentation.packages.tornado.TornadoRequestExecuteInstrumentation", + "elasticapm.instrumentation.packages.tornado.TornadoHandleRequestExceptionInstrumentation", + "elasticapm.instrumentation.packages.tornado.TornadoRenderInstrumentation", + "elasticapm.instrumentation.packages.httpx.async.httpcore.HTTPCoreAsyncInstrumentation", + "elasticapm.instrumentation.packages.asyncio.aioredis.RedisConnectionPoolInstrumentation", + "elasticapm.instrumentation.packages.asyncio.aioredis.RedisPipelineInstrumentation", + "elasticapm.instrumentation.packages.asyncio.aioredis.RedisConnectionInstrumentation", + "elasticapm.instrumentation.packages.asyncio.aiomysql.AioMySQLInstrumentation", + "elasticapm.instrumentation.packages.asyncio.aiobotocore.AioBotocoreInstrumentation", + "elasticapm.instrumentation.packages.asyncio.starlette.StarletteServerErrorMiddlewareInstrumentation", + "elasticapm.instrumentation.packages.asyncio.redis_asyncio.RedisAsyncioInstrumentation", + "elasticapm.instrumentation.packages.asyncio.redis_asyncio.RedisPipelineInstrumentation", + "elasticapm.instrumentation.packages.asyncio.psycopg_async.AsyncPsycopgInstrumentation", + "elasticapm.instrumentation.packages.grpc.GRPCAsyncServerInstrumentation", } -if sys.version_info >= (3, 7): - _cls_register.update( - [ - "elasticapm.instrumentation.packages.asyncio.sleep.AsyncIOSleepInstrumentation", - "elasticapm.instrumentation.packages.asyncio.aiohttp_client.AioHttpClientInstrumentation", - "elasticapm.instrumentation.packages.httpx.async.httpx.HttpxAsyncClientInstrumentation", - "elasticapm.instrumentation.packages.asyncio.elasticsearch.ElasticSearchAsyncConnection", - "elasticapm.instrumentation.packages.asyncio.elasticsearch.ElasticsearchAsyncTransportInstrumentation", - "elasticapm.instrumentation.packages.asyncio.aiopg.AioPGInstrumentation", - "elasticapm.instrumentation.packages.asyncio.asyncpg.AsyncPGInstrumentation", - "elasticapm.instrumentation.packages.tornado.TornadoRequestExecuteInstrumentation", - "elasticapm.instrumentation.packages.tornado.TornadoHandleRequestExceptionInstrumentation", - "elasticapm.instrumentation.packages.tornado.TornadoRenderInstrumentation", - "elasticapm.instrumentation.packages.httpx.async.httpcore.HTTPCoreAsyncInstrumentation", - "elasticapm.instrumentation.packages.asyncio.aioredis.RedisConnectionPoolInstrumentation", - "elasticapm.instrumentation.packages.asyncio.aioredis.RedisPipelineInstrumentation", - "elasticapm.instrumentation.packages.asyncio.aioredis.RedisConnectionInstrumentation", - "elasticapm.instrumentation.packages.asyncio.aiomysql.AioMySQLInstrumentation", - "elasticapm.instrumentation.packages.asyncio.aiobotocore.AioBotocoreInstrumentation", - "elasticapm.instrumentation.packages.asyncio.starlette.StarletteServerErrorMiddlewareInstrumentation", - "elasticapm.instrumentation.packages.asyncio.redis_asyncio.RedisAsyncioInstrumentation", - "elasticapm.instrumentation.packages.asyncio.redis_asyncio.RedisPipelineInstrumentation", - "elasticapm.instrumentation.packages.asyncio.psycopg_async.AsyncPsycopgInstrumentation", - "elasticapm.instrumentation.packages.grpc.GRPCAsyncServerInstrumentation", - ] - ) - # These instrumentations should only be enabled if we're instrumenting via the # wrapper script, which calls register_wrapper_instrumentations() below. _wrapper_register = { diff --git a/setup.cfg b/setup.cfg index e9f766645..5a29c245f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,7 +15,6 @@ classifiers = Operating System :: OS Independent Topic :: Software Development Programming Language :: Python - Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 @@ -33,7 +32,7 @@ project_urls = Tracker = https://github.com/elastic/apm-agent-python/issues [options] -python_requires = >=3.6, <4 +python_requires = >=3.7, <4 packages = find: include_package_data = true zip_safe = false diff --git a/tests/requirements/reqs-base.txt b/tests/requirements/reqs-base.txt index d1105586a..9fb503dd3 100644 --- a/tests/requirements/reqs-base.txt +++ b/tests/requirements/reqs-base.txt @@ -1,8 +1,6 @@ -pytest==7.0.1 ; python_version == '3.6' -pytest==7.4.0 ; python_version > '3.6' +pytest==7.4.0 pytest-random-order==1.1.0 pytest-django==4.4.0 -coverage==6.2 ; python_version == '3.6' coverage==6.3 ; python_version == '3.7' coverage[toml]==6.3 ; python_version == '3.7' coverage==7.3.1 ; python_version > '3.7' @@ -10,16 +8,11 @@ pytest-cov==4.0.0 ; python_version < '3.8' pytest-cov==4.1.0 ; python_version > '3.7' jinja2==3.1.5 ; python_version == '3.7' pytest-localserver==0.9.0 -pytest-mock==3.6.1 ; python_version == '3.6' -pytest-mock==3.10.0 ; python_version > '3.6' -pytest-benchmark==3.4.1 ; python_version == '3.6' -pytest-benchmark==4.0.0 ; python_version > '3.6' -pytest-bdd==5.0.0 ; python_version == '3.6' -pytest-bdd==6.1.1 ; python_version > '3.6' -pytest-rerunfailures==10.2 ; python_version == '3.6' -pytest-rerunfailures==11.1.2 ; python_version > '3.6' -jsonschema==3.2.0 ; python_version == '3.6' -jsonschema==4.17.3 ; python_version > '3.6' +pytest-mock==3.10.0 +pytest-benchmark==4.0.0 +pytest-bdd==6.1.1 +pytest-rerunfailures==11.1.2 +jsonschema==4.17.3 urllib3!=2.0.0,<3.0.0 @@ -32,6 +25,6 @@ structlog wrapt>=1.14.1,!=1.15.0 simplejson -pytest-asyncio==0.21.0 ; python_version >= '3.7' -asynctest==0.13.0 ; python_version >= '3.7' +pytest-asyncio==0.21.0 +asynctest==0.13.0 typing_extensions!=3.10.0.1 ; python_version >= '3.10' # see https://github.com/python/typing/issues/865 diff --git a/tests/scripts/run_tests.sh b/tests/scripts/run_tests.sh index 7fcc85010..414a09885 100755 --- a/tests/scripts/run_tests.sh +++ b/tests/scripts/run_tests.sh @@ -6,7 +6,7 @@ export PATH=${HOME}/.local/bin:${PATH} python -m pip install --user -U pip setuptools --cache-dir "${PIP_CACHE}" python -m pip install --user -r "tests/requirements/reqs-${FRAMEWORK}.txt" --cache-dir "${PIP_CACHE}" -export PYTHON_VERSION=$(python -c "import platform; pv=platform.python_version_tuple(); print('pypy' + ('' if pv[0] == 2 else str(pv[0])) if platform.python_implementation() == 'PyPy' else '.'.join(map(str, platform.python_version_tuple()[:2])))") +export PYTHON_VERSION=$(python -c "import platform; pv=platform.python_version_tuple(); print('pypy' + (str(pv[0])) if platform.python_implementation() == 'PyPy' else '.'.join(map(str, platform.python_version_tuple()[:2])))") # check if the full FRAMEWORK name is in scripts/envs if [[ -e "./tests/scripts/envs/${FRAMEWORK}.sh" ]]