From 4ade9a2135c7ced80839ae050ce222db230d0e39 Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Wed, 27 Jan 2021 16:37:46 -0700 Subject: [PATCH 1/5] Error on python <= 3.5 --- CHANGELOG.asciidoc | 6 ++++++ elasticapm/__init__.py | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index f62c16786..3a6eaadae 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -34,6 +34,12 @@ endif::[] // Unreleased changes go here // When the next release happens, nest these changes under the "Python Agent version 5.x" heading +[float] +===== Breaking changes + +* Python 2.7 and 3.5 support has been deprecated. The python agent now requires python 3.6+ + + [float] ===== Features diff --git a/elasticapm/__init__.py b/elasticapm/__init__.py index 6ce782a3c..c71e53ece 100644 --- a/elasticapm/__init__.py +++ b/elasticapm/__init__.py @@ -36,8 +36,8 @@ capture_span, get_span_id, get_trace_id, - get_transaction_id, get_trace_parent_header, + get_transaction_id, label, set_context, set_custom_context, @@ -60,5 +60,7 @@ VERSION = "unknown" -if sys.version_info >= (3, 5): - from elasticapm.contrib.asyncio.traces import async_capture_span # noqa: F401 +if sys.version_info <= (3, 5): + raise Exception("The agent requires python 3.6+") + +from elasticapm.contrib.asyncio.traces import async_capture_span # noqa: F401 From fd7373ea00ba28c2792ce793060ea974583cbbb6 Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Wed, 27 Jan 2021 16:50:06 -0700 Subject: [PATCH 2/5] Remove py2/pypy2 from setup.cfg and from CI --- .ci/.jenkins_exclude.yml | 127 --------------------------------------- .ci/.jenkins_python.yml | 3 - setup.cfg | 6 +- 3 files changed, 1 insertion(+), 135 deletions(-) diff --git a/.ci/.jenkins_exclude.yml b/.ci/.jenkins_exclude.yml index d231158ab..0a9ebf8aa 100644 --- a/.ci/.jenkins_exclude.yml +++ b/.ci/.jenkins_exclude.yml @@ -1,41 +1,11 @@ exclude: # Django - - PYTHON_VERSION: python-2.7 - FRAMEWORK: django-2.0 - - PYTHON_VERSION: python-2.7 - FRAMEWORK: django-2.1 - - PYTHON_VERSION: python-2.7 - FRAMEWORK: django-2.2 - - PYTHON_VERSION: python-2.7 - FRAMEWORK: django-3.0 - - PYTHON_VERSION: python-2.7 - FRAMEWORK: django-master - - PYTHON_VERSION: python-3.5 - FRAMEWORK: django-3.0 - PYTHON_VERSION: python-3.7 FRAMEWORK: django-1.11 # see https://code.djangoproject.com/ticket/28814 - - PYTHON_VERSION: pypy-2 - FRAMEWORK: django-2.0 - - PYTHON_VERSION: pypy-2 - FRAMEWORK: django-2.1 - - PYTHON_VERSION: pypy-2 - FRAMEWORK: django-2.2 - - PYTHON_VERSION: pypy-2 - FRAMEWORK: django-3.0 - - PYTHON_VERSION: pypy-2 - FRAMEWORK: django-master # Flask - PYTHON_VERSION: pypy-3 FRAMEWORK: flask-0.11 # see https://github.com/pallets/flask/commit/6e46d0cd, 0.11.2 was never released # celery - - PYTHON_VERSION: python-2.7 - FRAMEWORK: celery-3-django-2.0 - - PYTHON_VERSION: python-2.7 - FRAMEWORK: celery-4-django-2.0 - - PYTHON_VERSION: pypy-2 - FRAMEWORK: celery-3-django-2.0 - - PYTHON_VERSION: pypy-2 - FRAMEWORK: celery-4-django-2.0 - PYTHON_VERSION: python-3.7 FRAMEWORK: celery-3-django-1.11 # see https://code.djangoproject.com/ticket/28814 # celery 4 doesn't currently work on Python 3.7, see https://github.com/celery/celery/issues/4500 @@ -58,8 +28,6 @@ exclude: - PYTHON_VERSION: python-3.9-rc FRAMEWORK: celery-4-flask-1.0 # requests - - PYTHON_VERSION: python-3.5 - FRAMEWORK: requests-1.2 - PYTHON_VERSION: python-3.6 FRAMEWORK: requests-1.2 - PYTHON_VERSION: python-3.7 @@ -71,8 +39,6 @@ exclude: - PYTHON_VERSION: pypy-3 FRAMEWORK: requests-1.2 # pymongo - - PYTHON_VERSION: python-3.5 - FRAMEWORK: pymongo-3.0 - PYTHON_VERSION: python-3.6 FRAMEWORK: pymongo-3.0 - PYTHON_VERSION: python-3.7 @@ -116,8 +82,6 @@ exclude: - PYTHON_VERSION: pypy-3 FRAMEWORK: pymongo-3.0 # python-memcached - - PYTHON_VERSION: python-3.5 - FRAMEWORK: memcached-1.51 - PYTHON_VERSION: python-3.6 FRAMEWORK: memcached-1.51 - PYTHON_VERSION: python-3.7 @@ -129,8 +93,6 @@ exclude: - PYTHON_VERSION: pypy-3 FRAMEWORK: memcached-1.51 # pymssql - - PYTHON_VERSION: pypy-2 # currently fails with error on pypy2 - FRAMEWORK: pymssql-newest - PYTHON_VERSION: pypy-3 # currently fails with error on pypy3 FRAMEWORK: pymssql-newest - PYTHON_VERSION: python-3.6 # currently fails with error on python 3.6 due to cython issues @@ -147,8 +109,6 @@ exclude: - PYTHON_VERSION: python-3.9-rc # see https://github.com/psycopg/psycopg2/issues/858 FRAMEWORK: psycopg2-2.7 # pyodbc - - PYTHON_VERSION: pypy-2 - FRAMEWORK: pyodbc-newest - PYTHON_VERSION: pypy-3 FRAMEWORK: pyodbc-newest # boto3 @@ -171,17 +131,9 @@ exclude: FRAMEWORK: boto3-1.6 - PYTHON_VERSION: python-3.9-rc FRAMEWORK: boto3-newest - # opentracing - - PYTHON_VERSION: python-3.3 - FRAMEWORK: opentracing-newest - # eventlet - - PYTHON_VERSION: pypy-2 #currently fails on pypy2 - FRAMEWORK: eventlet-newest # zerorpc - only run on py2 - PYTHON_VERSION: pypy-3 FRAMEWORK: zerorpc-0.4 - - PYTHON_VERSION: python-3.5 - FRAMEWORK: zerorpc-0.4 - PYTHON_VERSION: python-3.6 FRAMEWORK: zerorpc-0.4 - PYTHON_VERSION: python-3.7 @@ -190,119 +142,40 @@ exclude: FRAMEWORK: zerorpc-0.4 - PYTHON_VERSION: python-3.9-rc FRAMEWORK: zerorpc-0.4 - # gevent - - PYTHON_VERSION: pypy-2 # see https://github.com/gevent/gevent/issues/1380, fix will be in gevent 1.5 - FRAMEWORK: gevent-newest # aiohttp client, only supported in Python 3.7+ - - PYTHON_VERSION: python-2.7 - FRAMEWORK: aiohttp-3.0 - - PYTHON_VERSION: pypy-2 - FRAMEWORK: aiohttp-3.0 - PYTHON_VERSION: pypy-3 FRAMEWORK: aiohttp-3.0 - - PYTHON_VERSION: python-3.5 - FRAMEWORK: aiohttp-3.0 - PYTHON_VERSION: python-3.6 FRAMEWORK: aiohttp-3.0 - - PYTHON_VERSION: python-2.7 - FRAMEWORK: aiohttp-4.0 - - PYTHON_VERSION: pypy-2 - FRAMEWORK: aiohttp-4.0 - PYTHON_VERSION: pypy-3 FRAMEWORK: aiohttp-4.0 - - PYTHON_VERSION: python-3.5 - FRAMEWORK: aiohttp-4.0 - PYTHON_VERSION: python-3.6 FRAMEWORK: aiohttp-4.0 - - PYTHON_VERSION: python-2.7 - FRAMEWORK: aiohttp-newest - - PYTHON_VERSION: pypy-2 - FRAMEWORK: aiohttp-newest - PYTHON_VERSION: pypy-3 FRAMEWORK: aiohttp-newest - - PYTHON_VERSION: python-3.5 - FRAMEWORK: aiohttp-newest - PYTHON_VERSION: python-3.6 FRAMEWORK: aiohttp-newest # tornado, only supported in Python 3.7+ - - PYTHON_VERSION: python-2.7 - FRAMEWORK: tornado-newest - - PYTHON_VERSION: pypy-2 - FRAMEWORK: tornado-newest - PYTHON_VERSION: pypy-3 FRAMEWORK: tornado-newest - - PYTHON_VERSION: python-3.5 - FRAMEWORK: tornado-newest - PYTHON_VERSION: python-3.6 FRAMEWORK: tornado-newest # Starlette, only supported in python 3.7+ - - PYTHON_VERSION: python-2.7 - FRAMEWORK: starlette-0.13 - - PYTHON_VERSION: pypy-2 - FRAMEWORK: starlette-0.13 - PYTHON_VERSION: pypy-3 FRAMEWORK: starlette-0.13 - - PYTHON_VERSION: python-3.5 - FRAMEWORK: starlette-0.13 - PYTHON_VERSION: python-3.6 FRAMEWORK: starlette-0.13 - - PYTHON_VERSION: python-2.7 - FRAMEWORK: starlette-newest - - PYTHON_VERSION: pypy-2 - FRAMEWORK: starlette-newest - PYTHON_VERSION: pypy-3 FRAMEWORK: starlette-newest - - PYTHON_VERSION: python-3.5 - FRAMEWORK: starlette-newest - PYTHON_VERSION: python-3.6 FRAMEWORK: starlette-newest # aiopg - - PYTHON_VERSION: python-2.7 - FRAMEWORK: aiopg-newest - - PYTHON_VERSION: pypy-2 - FRAMEWORK: aiopg-newest - PYTHON_VERSION: pypy-3 FRAMEWORK: aiopg-newest - - PYTHON_VERSION: python-3.5 - FRAMEWORK: aiopg-newest - PYTHON_VERSION: python-3.6 FRAMEWORK: aiopg-newest # asyncpg - - PYTHON_VERSION: python-2.7 - FRAMEWORK: asyncpg-newest - - PYTHON_VERSION: pypy-2 - FRAMEWORK: asyncpg-newest - PYTHON_VERSION: pypy-3 FRAMEWORK: asyncpg-newest - - PYTHON_VERSION: python-3.5 - FRAMEWORK: asyncpg-newest - PYTHON_VERSION: python-3.6 FRAMEWORK: asyncpg-newest - # psutil - - PYTHON_VERSION: pypy-2 #currently fails on pypy2 (https://github.com/giampaolo/psutil/issues/1659) - FRAMEWORK: psutil-newest - # httpx (python3.6+) - - PYTHON_VERSION: pypy-2 - FRAMEWORK: httpx-0.12 - - PYTHON_VERSION: pypy-2 - FRAMEWORK: httpx-0.13 - - PYTHON_VERSION: pypy-2 - FRAMEWORK: httpx-0.14 - - PYTHON_VERSION: pypy-2 - FRAMEWORK: httpx-newest - - PYTHON_VERSION: python-2.7 - FRAMEWORK: httpx-0.12 - - PYTHON_VERSION: python-2.7 - FRAMEWORK: httpx-0.13 - - PYTHON_VERSION: python-2.7 - FRAMEWORK: httpx-0.14 - - PYTHON_VERSION: python-2.7 - FRAMEWORK: httpx-newest - - PYTHON_VERSION: python-3.5 - FRAMEWORK: httpx-0.12 - - PYTHON_VERSION: python-3.5 - FRAMEWORK: httpx-0.13 - - PYTHON_VERSION: python-3.5 - FRAMEWORK: httpx-0.14 - - PYTHON_VERSION: python-3.5 - FRAMEWORK: httpx-newest diff --git a/.ci/.jenkins_python.yml b/.ci/.jenkins_python.yml index 919810465..07e70083b 100644 --- a/.ci/.jenkins_python.yml +++ b/.ci/.jenkins_python.yml @@ -1,9 +1,6 @@ PYTHON_VERSION: - - python-2.7 - - python-3.5 - python-3.6 - python-3.7 - python-3.8 - python-3.9-rc - - pypy-2 - pypy-3 diff --git a/setup.cfg b/setup.cfg index 3aab7217d..3e26e4418 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,8 +19,6 @@ classifiers = Operating System :: OS Independent Topic :: Software Development Programming Language :: Python - Programming Language :: Python :: 2.7 - Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 @@ -34,14 +32,13 @@ project_urls = Tracker = https://github.com/elastic/apm-agent-python/issues [options] -python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4 +python_requires = >=3.6, <4 packages = find: include_package_data = true zip_safe = false install_requires = urllib3 certifi - cachetools;python_version=='2.7' test_suite=tests tests_require = pytest==4.6.9 @@ -99,7 +96,6 @@ tests_require = pytest-mock ; python_version >= '3.7' httpx ; python_version >= '3.6' - cachetools==2.0.1 ; python_version == '2.7' [options.extras_require] flask = From 41028b563403bc73ecf87cfe14a8d215f5be5d50 Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Wed, 27 Jan 2021 16:59:30 -0700 Subject: [PATCH 3/5] Use DeprecationWarning instead of Exception --- elasticapm/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elasticapm/__init__.py b/elasticapm/__init__.py index c71e53ece..70ab1c994 100644 --- a/elasticapm/__init__.py +++ b/elasticapm/__init__.py @@ -61,6 +61,6 @@ if sys.version_info <= (3, 5): - raise Exception("The agent requires python 3.6+") + raise DeprecationWarning("The agent requires python 3.6+") from elasticapm.contrib.asyncio.traces import async_capture_span # noqa: F401 From f7ea82d8bd7a0f4eac9afad045b95f65d9227dad Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Thu, 28 Jan 2021 08:45:29 -0700 Subject: [PATCH 4/5] Skip packages for cp27 and cp35 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 98c3ada89..43fd51df2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -170,7 +170,7 @@ pipeline { sh script: 'pip3 install --user cibuildwheel', label: "Installing cibuildwheel" sh script: 'mkdir wheelhouse', label: "creating wheelhouse" // skip pypy builds with CIBW_SKIP=pp* - sh script: 'CIBW_SKIP="pp*" cibuildwheel --platform linux --output-dir wheelhouse; ls -l wheelhouse' + sh script: 'CIBW_SKIP="pp* cp27* cp35*" cibuildwheel --platform linux --output-dir wheelhouse; ls -l wheelhouse' } stash allowEmpty: true, name: 'packages', includes: "${BASE_DIR}/wheelhouse/*.whl,${BASE_DIR}/dist/*.tar.gz", useDefaultExcludes: false } From 9bb4f410e60e31cb0bc118c2d4dd5f8f10142f94 Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Thu, 28 Jan 2021 08:48:49 -0700 Subject: [PATCH 5/5] Apply suggestions from code review Co-authored-by: Benjamin Wohlwend --- CHANGELOG.asciidoc | 2 +- elasticapm/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 3a6eaadae..f0debf7dd 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -37,7 +37,7 @@ endif::[] [float] ===== Breaking changes -* Python 2.7 and 3.5 support has been deprecated. The python agent now requires python 3.6+ +* Python 2.7 and 3.5 support has been deprecated. The Python agent now requires Python 3.6+ [float] diff --git a/elasticapm/__init__.py b/elasticapm/__init__.py index 70ab1c994..7038e8c02 100644 --- a/elasticapm/__init__.py +++ b/elasticapm/__init__.py @@ -61,6 +61,6 @@ if sys.version_info <= (3, 5): - raise DeprecationWarning("The agent requires python 3.6+") + raise DeprecationWarning("The Elastic APM agent requires Python 3.6+") from elasticapm.contrib.asyncio.traces import async_capture_span # noqa: F401