Skip to content

Commit 0704620

Browse files
authored
Remove Python 2 Support (#1195)
* Remove Python 2 iteration techniques * Remove six.b * Replace six types * Clean up async_wrapper module * Clean up object_names module * Clean up exception messages tests * Delete RedisBlaster tests (Python 2 only) * Delete gRPC tests Python 2 garbage collection test * Clean up pika tests * Remove py2_namespace from CLM validator * Clean up testing fixtures * Update feed parser tests to Python 3 * Remove all Python 2 tests from tox * Fix imports on BaseHTTPServer * Remove Python 2.7 from docker image * Remove python 2.7 from setup.py * Remove Python 2 reimplementations * Remove Python 2 build logic * Clean up import hook module * Trim comments related to Python 2 * Remove Python 2 vs 3 conditionals * Delete six import statments * Remove six package * Removing python 2 specific closure logic * Trim comments related to python 2 * Remove try catch on importing importlib reload * Rename configparser module imports * Rename __builtin__ module * Remove __future__ imports * Remove Python 2 specific argument binding code * Use os.sep not "/" * Remove longs from attribute tests * Fix Python 2 imports * Fix functools lru_cache * Fix bug in django tastypie tests * Fix imports for test_http_client * Update import hook tests to use find_spec * Fix mistakes in pika tests * Remove references to urllib2 * Remove iscoroutinefunction reimplementation * Remove falcon master tests for py37 (unsupported) * Add banner to gearman tests * Drop virtualenv pin from tox
1 parent 70e98a5 commit 0704620

File tree

176 files changed

+572
-3361
lines changed

Some content is hidden

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

176 files changed

+572
-3361
lines changed

.github/containers/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ RUN echo 'eval "$(pyenv init -)"' >>${HOME}/.bashrc && \
9696
pyenv update
9797

9898
# Install Python
99-
ARG PYTHON_VERSIONS="3.11 3.10 3.9 3.8 3.7 3.12 2.7 pypy2.7-7.3.12 pypy3.10-7.3.15"
99+
ARG PYTHON_VERSIONS="3.11 3.10 3.9 3.8 3.7 3.12 pypy3.10-7.3.15"
100100
COPY --chown=1000:1000 --chmod=+x ./install-python.sh /tmp/install-python.sh
101101
RUN /tmp/install-python.sh && \
102102
rm /tmp/install-python.sh

.github/containers/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ REPO_ROOT:=$(realpath ${MAKEFILE_DIR}../../)
2323
UNAME_P:=$(shell uname -p)
2424
PLATFORM_AUTOMATIC:=$(if $(findstring arm,${UNAME_P}),linux/arm64,linux/amd64)
2525
PLATFORM:=$(if ${PLATFORM_OVERRIDE},${PLATFORM_OVERRIDE},${PLATFORM_AUTOMATIC})
26-
PYTHON_VERSIONS_AUTOMATIC:=3.10 2.7
26+
PYTHON_VERSIONS_AUTOMATIC:=3.10
2727
PYTHON_VERSIONS:=$(if ${PYTHON_VERSIONS_OVERRIDE},${PYTHON_VERSIONS_OVERRIDE},${PYTHON_VERSIONS_AUTOMATIC})
2828

2929
.PHONY: default
@@ -70,6 +70,5 @@ test: build
7070
ghcr.io/newrelic/python-agent-ci:local \
7171
/bin/bash -c '\
7272
python3.10 --version && \
73-
python2.7 --version && \
7473
touch tox.ini && tox --version && \
7574
echo "Success! Python versions installed."'

.github/containers/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ isort
55
pip
66
setuptools
77
tox
8-
virtualenv<20.22.0
8+
virtualenv
99
wheel

.github/workflows/deploy-python.yml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -64,35 +64,6 @@ jobs:
6464
path: ./wheelhouse/*.whl
6565
retention-days: 1
6666

67-
build-linux-py2:
68-
runs-on: ubuntu-latest
69-
70-
steps:
71-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1
72-
with:
73-
persist-credentials: false
74-
fetch-depth: 0
75-
76-
- name: Setup QEMU
77-
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # 3.0.0
78-
79-
- name: Build Wheels
80-
uses: pypa/cibuildwheel@bf3a5590c9aeb9a7e4ff4025ef7400e0c6ad1248 # 1.12.0 (Last release to support Python 2)
81-
env:
82-
CIBW_PLATFORM: linux
83-
CIBW_BUILD: cp27-manylinux_x86_64
84-
CIBW_ARCHS_LINUX: x86_64
85-
CIBW_ENVIRONMENT: "LD_LIBRARY_PATH=/opt/rh/devtoolset-8/root/usr/lib64:/opt/rh/devtoolset-8/root/usr/lib:/opt/rh/devtoolset-8/root/usr/lib64/dyninst:/opt/rh/devtoolset-8/root/usr/lib/dyninst:/usr/local/lib64:/usr/local/lib"
86-
CIBW_TEST_REQUIRES: pytest==4.6.11
87-
CIBW_TEST_COMMAND: "PYTHONPATH={project}/tests pytest {project}/tests/agent_unittests -vx"
88-
89-
- name: Upload Artifacts
90-
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # 4.3.1
91-
with:
92-
name: ${{ github.job }}
93-
path: ./wheelhouse/*.whl
94-
retention-days: 1
95-
9667
build-sdist:
9768
runs-on: ubuntu-latest
9869
steps:
@@ -130,7 +101,6 @@ jobs:
130101

131102
needs:
132103
- build-linux-py3
133-
- build-linux-py2
134104
- build-sdist
135105

136106
steps:

THIRD_PARTY_NOTICES.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,6 @@ Distributed under the following license(s):
3535
* [The Apache License, Version 2.0 License](https://opensource.org/license/apache-2-0/)
3636

3737

38-
## [six](https://pypi.org/project/six)
39-
40-
Copyright (c) 2010-2013 Benjamin Peterson
41-
42-
Distributed under the following license(s):
43-
44-
* [The MIT License](http://opensource.org/licenses/MIT)
45-
46-
4738
## [time.monotonic](newrelic/common/_monotonic.c)
4839

4940
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Python Software Foundation; All Rights Reserved

newrelic/admin/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from __future__ import print_function
16-
1715
import logging
1816
import sys
1917

newrelic/admin/debug_console.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from __future__ import print_function
16-
1715
from newrelic.admin import command, usage
1816

1917
@command('debug-console', 'config_file [session_log]',

newrelic/admin/generate_config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from __future__ import print_function
16-
1715
from newrelic.admin import command, usage
1816

1917
@command('generate-config', 'license_key [output_file]',

newrelic/admin/license_key.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from __future__ import print_function
16-
1715
from newrelic.admin import command, usage
1816
from newrelic.common.encoding_utils import obfuscate_license_key
1917

newrelic/admin/local_config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from __future__ import print_function
16-
1715
from newrelic.admin import command, usage
1816

1917

newrelic/admin/network_config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from __future__ import print_function
16-
1715
from newrelic.admin import command, usage
1816

1917

newrelic/admin/record_deploy.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from __future__ import print_function
16-
1715
import os
1816
import pwd
1917

newrelic/admin/run_program.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from __future__ import print_function
16-
1715
from newrelic.admin import command, usage
1816

1917

newrelic/admin/run_python.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from __future__ import print_function
16-
1715
from newrelic.admin import command, usage
1816

1917
@command('run-python', '...',

newrelic/admin/server_config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from __future__ import print_function
16-
1715
from newrelic.admin import command, usage
1816

1917

newrelic/admin/validate_config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from __future__ import print_function
16-
1715
from newrelic.admin import command, usage
1816

1917

newrelic/api/application.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import newrelic.api.import_hook
1919
import newrelic.core.agent
2020
import newrelic.core.config
21-
import newrelic.packages.six as six
2221

2322

2423
class Application(object):
@@ -106,7 +105,7 @@ def shutdown(self):
106105

107106
@property
108107
def linked_applications(self):
109-
return list(six.iterkeys(self._linked))
108+
return list(self._linked.keys())
110109

111110
def link_to_application(self, name):
112111
self._linked[name] = True

newrelic/api/asgi_application.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
function_wrapper,
2727
wrap_object,
2828
)
29-
from newrelic.packages import asgiref_compatibility, six
29+
from newrelic.packages import asgiref_compatibility
3030

3131

3232
def _bind_scope(scope, *args, **kwargs):
@@ -158,7 +158,7 @@ async def send_inject_browser_agent(self, message):
158158
# if there's a valid body string, attempt to insert the HTML
159159
if verify_body_exists(self.body):
160160
body = insert_html_snippet(
161-
self.body, lambda: six.b(self.transaction.browser_timing_header()), self.search_maximum
161+
self.body, lambda: self.transaction.browser_timing_header().encode("latin-1"), self.search_maximum
162162
)
163163

164164
# If we have inserted the browser agent

0 commit comments

Comments
 (0)