Skip to content

Commit 8446aa1

Browse files
authored
Revert old python support removal (#2385)
* Revert "Drop Python 3.7 support (#2340)" This reverts commit 8ac1781. * Revert "Drop support for Python 3.6 (#2338)" This reverts commit 76cf5c8. * Revert "Use unittest.mock instead of the mock backport package (#2370)" This reverts commit 7241b27. [xrmx: keep the azurestorage marker addition]
1 parent abbb037 commit 8446aa1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+198
-80
lines changed

.ci/.matrix_exclude.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,53 @@ exclude:
55
# Django 4.0 requires Python 3.8+
66
- VERSION: pypy-3 # current pypy-3 is compatible with Python 3.7
77
FRAMEWORK: django-4.0
8+
- VERSION: python-3.6
9+
FRAMEWORK: django-4.0
10+
- VERSION: python-3.7
11+
FRAMEWORK: django-4.0
12+
# Django 4.2 requires Python 3.8+
13+
- VERSION: python-3.6
14+
FRAMEWORK: django-4.2
15+
- VERSION: python-3.7
16+
FRAMEWORK: django-4.2
817
# Django 5.0 requires Python 3.10+
18+
- VERSION: python-3.6
19+
FRAMEWORK: django-5.0
20+
- VERSION: python-3.7
21+
FRAMEWORK: django-5.0
922
- VERSION: python-3.8
1023
FRAMEWORK: django-5.0
1124
- VERSION: python-3.9
1225
FRAMEWORK: django-5.0
1326
- VERSION: pypy-3 # current pypy-3 is compatible with Python 3.7
1427
FRAMEWORK: celery-5-django-4
28+
- VERSION: python-3.6
29+
FRAMEWORK: celery-5-django-4
30+
- VERSION: python-3.7
31+
FRAMEWORK: celery-5-django-4
32+
- VERSION: python-3.6
33+
FRAMEWORK: celery-5-django-5
34+
- VERSION: python-3.7
35+
FRAMEWORK: celery-5-django-5
1536
- VERSION: python-3.8
1637
FRAMEWORK: celery-5-django-5
1738
- VERSION: python-3.9
1839
FRAMEWORK: celery-5-django-5
1940
# Flask
2041
- VERSION: pypy-3
2142
FRAMEWORK: flask-0.11 # see https://github.com/pallets/flask/commit/6e46d0cd, 0.11.2 was never released
43+
- VERSION: python-3.6
44+
FRAMEWORK: flask-2.1
45+
- VERSION: python-3.6
46+
FRAMEWORK: flask-2.2
47+
- VERSION: python-3.6
48+
FRAMEWORK: flask-2.3
49+
- VERSION: python-3.6
50+
FRAMEWORK: flask-3.0
51+
- VERSION: python-3.7
52+
FRAMEWORK: flask-2.3
53+
- VERSION: python-3.7
54+
FRAMEWORK: flask-3.0
2255
# Python 3.10 removed a bunch of classes from collections, now in collections.abc
2356
- VERSION: python-3.10
2457
FRAMEWORK: django-1.11
@@ -152,6 +185,8 @@ exclude:
152185
# pymssql
153186
- VERSION: pypy-3 # currently fails with error on pypy3
154187
FRAMEWORK: pymssql-newest
188+
- VERSION: python-3.6 # dropped support for py3.6
189+
FRAMEWORK: pymssql-newest
155190
# pyodbc
156191
- VERSION: pypy-3
157192
FRAMEWORK: pyodbc-newest
@@ -175,49 +210,81 @@ exclude:
175210
# aiohttp client, only supported in Python 3.7+
176211
- VERSION: pypy-3
177212
FRAMEWORK: aiohttp-3.0
213+
- VERSION: python-3.6
214+
FRAMEWORK: aiohttp-3.0
178215
- VERSION: pypy-3
179216
FRAMEWORK: aiohttp-4.0
217+
- VERSION: python-3.6
218+
FRAMEWORK: aiohttp-4.0
180219
- VERSION: pypy-3
181220
FRAMEWORK: aiohttp-newest
221+
- VERSION: python-3.6
222+
FRAMEWORK: aiohttp-newest
182223
# tornado, only supported in Python 3.7+
183224
- VERSION: pypy-3
184225
FRAMEWORK: tornado-newest
226+
- VERSION: python-3.6
227+
FRAMEWORK: tornado-newest
185228
# Starlette, only supported in python 3.7+
186229
- VERSION: pypy-3
187230
FRAMEWORK: starlette-0.13
231+
- VERSION: python-3.6
232+
FRAMEWORK: starlette-0.13
188233
- VERSION: pypy-3
189234
FRAMEWORK: starlette-0.14
235+
- VERSION: python-3.6
236+
FRAMEWORK: starlette-0.14
190237
- VERSION: pypy-3
191238
FRAMEWORK: starlette-newest
239+
- VERSION: python-3.6
240+
FRAMEWORK: starlette-newest
192241
# aiopg
193242
- VERSION: pypy-3
194243
FRAMEWORK: aiopg-newest
244+
- VERSION: python-3.6
245+
FRAMEWORK: aiopg-newest
195246
# asyncpg
196247
- VERSION: pypy-3
197248
FRAMEWORK: asyncpg-newest
198249
- VERSION: pypy-3
199250
FRAMEWORK: asyncpg-0.28
251+
- VERSION: python-3.6
252+
FRAMEWORK: asyncpg-newest
253+
- VERSION: python-3.6
254+
FRAMEWORK: asyncpg-0.28
200255
- VERSION: python-3.13
201256
FRAMEWORK: asyncpg-0.28
202257
# sanic
203258
- VERSION: pypy-3
204259
FRAMEWORK: sanic-newest
205260
- VERSION: pypy-3
206261
FRAMEWORK: sanic-20.12
262+
- VERSION: python-3.6
263+
FRAMEWORK: sanic-20.12
264+
- VERSION: python-3.6
265+
FRAMEWORK: sanic-newest
207266
- VERSION: python-3.8
208267
FRAMEWORK: sanic-newest
209268
- VERSION: python-3.13
210269
FRAMEWORK: sanic-20.12
211270
# aioredis
212271
- VERSION: pypy-3
213272
FRAMEWORK: aioredis-newest
273+
- VERSION: python-3.6
274+
FRAMEWORK: aioredis-newest
214275
# aiomysql
215276
- VERSION: pypy-3
216277
FRAMEWORK: aiomysql-newest
278+
- VERSION: python-3.6
279+
FRAMEWORK: aiomysql-newest
217280
# aiobotocore
218281
- VERSION: pypy-3
219282
FRAMEWORK: aiobotocore-newest
283+
- VERSION: python-3.6
284+
FRAMEWORK: aiobotocore-newest
220285
# mysql-connector-python
286+
- VERSION: python-3.6
287+
FRAMEWORK: mysql_connector-newest
221288
# twisted
222289
- VERSION: python-3.11
223290
FRAMEWORK: twisted-18
@@ -251,6 +318,10 @@ exclude:
251318
- VERSION: python-3.13
252319
FRAMEWORK: pylibmc-1.4
253320
# grpc
321+
- VERSION: python-3.6
322+
FRAMEWORK: grpc-newest
323+
- VERSION: python-3.7
324+
FRAMEWORK: grpc-1.24
254325
- VERSION: python-3.8
255326
FRAMEWORK: grpc-1.24
256327
- VERSION: python-3.9
@@ -263,6 +334,12 @@ exclude:
263334
FRAMEWORK: grpc-1.24
264335
- VERSION: python-3.13
265336
FRAMEWORK: grpc-1.24
337+
- VERSION: python-3.7
338+
FRAMEWORK: flask-1.0
339+
- VERSION: python-3.7
340+
FRAMEWORK: flask-1.1
341+
- VERSION: python-3.7
342+
FRAMEWORK: jinja2-2
266343
# TODO py3.12
267344
- VERSION: python-3.12
268345
FRAMEWORK: sanic-20.12 # no wheels available yet

.ci/.matrix_python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
VERSION:
2-
- python-3.8
2+
- python-3.6
33
- python-3.13

.ci/.matrix_python_full.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
VERSION:
2+
- python-3.6
3+
- python-3.7
24
- python-3.8
35
- python-3.9
46
- python-3.10

.ci/publish-aws.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ for region in $ALL_AWS_REGIONS; do
4646
--layer-name="${FULL_LAYER_NAME}" \
4747
--description="AWS Lambda Extension Layer for the Elastic APM Python Agent" \
4848
--license-info="BSD-3-Clause" \
49-
--compatible-runtimes python3.8 python3.9 python3.10 python3.11 python3.12 python3.13\
49+
--compatible-runtimes python3.6 python3.7 python3.8 python3.9 python3.10 python3.11 python3.12 python3.13\
5050
--zip-file="fileb://${zip_file}")
5151
echo "${publish_output}" > "${AWS_FOLDER}/${region}"
5252
layer_version=$(echo "${publish_output}" | jq '.Version')

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ jobs:
114114
fail-fast: false
115115
matrix:
116116
include:
117+
# - version: "3.6"
118+
# framework: "none"
119+
# asyncio: "true"
120+
# - version: "3.7"
121+
# framework: none
122+
# asyncio: true
117123
- version: "3.8"
118124
framework: none
119125
asyncio: true

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@ flake8:
1010
test:
1111
# delete any __pycache__ folders to avoid hard-to-debug caching issues
1212
find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete
13-
echo "Python 3.7+, with asyncio"; \
14-
pytest -v $(PYTEST_ARGS) --showlocals $(PYTEST_MARKER) $(PYTEST_JUNIT); \
13+
# pypy3 should be added to the first `if` once it supports py3.7
14+
if [[ "$$PYTHON_VERSION" =~ ^(3.7|3.8|3.9|3.10|3.11|3.12|3.13|nightly)$$ ]] ; then \
15+
echo "Python 3.7+, with asyncio"; \
16+
pytest -v $(PYTEST_ARGS) --showlocals $(PYTEST_MARKER) $(PYTEST_JUNIT); \
17+
else \
18+
echo "Python < 3.7, without asyncio"; \
19+
pytest -v $(PYTEST_ARGS) --showlocals $(PYTEST_MARKER) $(PYTEST_JUNIT) --ignore-glob='*/asyncio*/*'; \
20+
fi
1521

1622
coverage: PYTEST_ARGS=--cov --cov-context=test --cov-config=setup.cfg --cov-branch
1723
coverage: export COVERAGE_FILE=.coverage.docker.$(PYTHON_FULL_VERSION).$(FRAMEWORK)

docs/reference/run-tests-locally.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ $ ./tests/scripts/docker/run_tests.sh python-version framework-version <pip-cach
5353
```
5454

5555
::::{note}
56-
The `python-version` must be of format `python-version`, e.g. `python-3.8` or `pypy-3`. The `framework` must be of format `framework-version`, e.g. `django-1.10` or `flask-0.12`.
56+
The `python-version` must be of format `python-version`, e.g. `python-3.6` or `pypy-2`. The `framework` must be of format `framework-version`, e.g. `django-1.10` or `flask-0.12`.
5757
::::
5858

5959

elasticapm/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
VERSION = "unknown"
6363

6464

65-
if sys.version_info < (3, 8):
66-
raise DeprecationWarning("The Elastic APM agent requires Python 3.8+")
65+
if sys.version_info <= (3, 5):
66+
raise DeprecationWarning("The Elastic APM agent requires Python 3.6+")
6767

6868
from elasticapm.contrib.asyncio.traces import async_capture_span # noqa: F401 E402

elasticapm/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,8 @@ def should_ignore_topic(self, topic: str) -> bool:
704704

705705
def check_python_version(self) -> None:
706706
v = tuple(map(int, platform.python_version_tuple()[:2]))
707-
if v < (3, 8):
708-
warnings.warn("The Elastic APM agent only supports Python 3.8+", DeprecationWarning)
707+
if v < (3, 6):
708+
warnings.warn("The Elastic APM agent only supports Python 3.6+", DeprecationWarning)
709709

710710
def check_server_version(
711711
self, gte: Optional[Tuple[int, ...]] = None, lte: Optional[Tuple[int, ...]] = None

elasticapm/instrumentation/register.py

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2929
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030

31+
import sys
32+
3133
from elasticapm.utils.module_import import import_string
3234

3335
_cls_register = {
@@ -68,29 +70,35 @@
6870
"elasticapm.instrumentation.packages.kafka.KafkaInstrumentation",
6971
"elasticapm.instrumentation.packages.grpc.GRPCClientInstrumentation",
7072
"elasticapm.instrumentation.packages.grpc.GRPCServerInstrumentation",
71-
"elasticapm.instrumentation.packages.asyncio.sleep.AsyncIOSleepInstrumentation",
72-
"elasticapm.instrumentation.packages.asyncio.aiohttp_client.AioHttpClientInstrumentation",
73-
"elasticapm.instrumentation.packages.httpx.async.httpx.HttpxAsyncClientInstrumentation",
74-
"elasticapm.instrumentation.packages.asyncio.elasticsearch.ElasticSearchAsyncConnection",
75-
"elasticapm.instrumentation.packages.asyncio.elasticsearch.ElasticsearchAsyncTransportInstrumentation",
76-
"elasticapm.instrumentation.packages.asyncio.aiopg.AioPGInstrumentation",
77-
"elasticapm.instrumentation.packages.asyncio.asyncpg.AsyncPGInstrumentation",
78-
"elasticapm.instrumentation.packages.tornado.TornadoRequestExecuteInstrumentation",
79-
"elasticapm.instrumentation.packages.tornado.TornadoHandleRequestExceptionInstrumentation",
80-
"elasticapm.instrumentation.packages.tornado.TornadoRenderInstrumentation",
81-
"elasticapm.instrumentation.packages.httpx.async.httpcore.HTTPCoreAsyncInstrumentation",
82-
"elasticapm.instrumentation.packages.asyncio.aioredis.RedisConnectionPoolInstrumentation",
83-
"elasticapm.instrumentation.packages.asyncio.aioredis.RedisPipelineInstrumentation",
84-
"elasticapm.instrumentation.packages.asyncio.aioredis.RedisConnectionInstrumentation",
85-
"elasticapm.instrumentation.packages.asyncio.aiomysql.AioMySQLInstrumentation",
86-
"elasticapm.instrumentation.packages.asyncio.aiobotocore.AioBotocoreInstrumentation",
87-
"elasticapm.instrumentation.packages.asyncio.starlette.StarletteServerErrorMiddlewareInstrumentation",
88-
"elasticapm.instrumentation.packages.asyncio.redis_asyncio.RedisAsyncioInstrumentation",
89-
"elasticapm.instrumentation.packages.asyncio.redis_asyncio.RedisPipelineInstrumentation",
90-
"elasticapm.instrumentation.packages.asyncio.psycopg_async.AsyncPsycopgInstrumentation",
91-
"elasticapm.instrumentation.packages.grpc.GRPCAsyncServerInstrumentation",
9273
}
9374

75+
if sys.version_info >= (3, 7):
76+
_cls_register.update(
77+
[
78+
"elasticapm.instrumentation.packages.asyncio.sleep.AsyncIOSleepInstrumentation",
79+
"elasticapm.instrumentation.packages.asyncio.aiohttp_client.AioHttpClientInstrumentation",
80+
"elasticapm.instrumentation.packages.httpx.async.httpx.HttpxAsyncClientInstrumentation",
81+
"elasticapm.instrumentation.packages.asyncio.elasticsearch.ElasticSearchAsyncConnection",
82+
"elasticapm.instrumentation.packages.asyncio.elasticsearch.ElasticsearchAsyncTransportInstrumentation",
83+
"elasticapm.instrumentation.packages.asyncio.aiopg.AioPGInstrumentation",
84+
"elasticapm.instrumentation.packages.asyncio.asyncpg.AsyncPGInstrumentation",
85+
"elasticapm.instrumentation.packages.tornado.TornadoRequestExecuteInstrumentation",
86+
"elasticapm.instrumentation.packages.tornado.TornadoHandleRequestExceptionInstrumentation",
87+
"elasticapm.instrumentation.packages.tornado.TornadoRenderInstrumentation",
88+
"elasticapm.instrumentation.packages.httpx.async.httpcore.HTTPCoreAsyncInstrumentation",
89+
"elasticapm.instrumentation.packages.asyncio.aioredis.RedisConnectionPoolInstrumentation",
90+
"elasticapm.instrumentation.packages.asyncio.aioredis.RedisPipelineInstrumentation",
91+
"elasticapm.instrumentation.packages.asyncio.aioredis.RedisConnectionInstrumentation",
92+
"elasticapm.instrumentation.packages.asyncio.aiomysql.AioMySQLInstrumentation",
93+
"elasticapm.instrumentation.packages.asyncio.aiobotocore.AioBotocoreInstrumentation",
94+
"elasticapm.instrumentation.packages.asyncio.starlette.StarletteServerErrorMiddlewareInstrumentation",
95+
"elasticapm.instrumentation.packages.asyncio.redis_asyncio.RedisAsyncioInstrumentation",
96+
"elasticapm.instrumentation.packages.asyncio.redis_asyncio.RedisPipelineInstrumentation",
97+
"elasticapm.instrumentation.packages.asyncio.psycopg_async.AsyncPsycopgInstrumentation",
98+
"elasticapm.instrumentation.packages.grpc.GRPCAsyncServerInstrumentation",
99+
]
100+
)
101+
94102
# These instrumentations should only be enabled if we're instrumenting via the
95103
# wrapper script, which calls register_wrapper_instrumentations() below.
96104
_wrapper_register = {

0 commit comments

Comments
 (0)