Skip to content

Commit

Permalink
Remove Python 2 Support (#1195)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
TimPansino authored Aug 22, 2024
1 parent 70e98a5 commit 0704620
Show file tree
Hide file tree
Showing 176 changed files with 572 additions and 3,361 deletions.
2 changes: 1 addition & 1 deletion .github/containers/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ RUN echo 'eval "$(pyenv init -)"' >>${HOME}/.bashrc && \
pyenv update

# Install Python
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"
ARG PYTHON_VERSIONS="3.11 3.10 3.9 3.8 3.7 3.12 pypy3.10-7.3.15"
COPY --chown=1000:1000 --chmod=+x ./install-python.sh /tmp/install-python.sh
RUN /tmp/install-python.sh && \
rm /tmp/install-python.sh
Expand Down
3 changes: 1 addition & 2 deletions .github/containers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ REPO_ROOT:=$(realpath ${MAKEFILE_DIR}../../)
UNAME_P:=$(shell uname -p)
PLATFORM_AUTOMATIC:=$(if $(findstring arm,${UNAME_P}),linux/arm64,linux/amd64)
PLATFORM:=$(if ${PLATFORM_OVERRIDE},${PLATFORM_OVERRIDE},${PLATFORM_AUTOMATIC})
PYTHON_VERSIONS_AUTOMATIC:=3.10 2.7
PYTHON_VERSIONS_AUTOMATIC:=3.10
PYTHON_VERSIONS:=$(if ${PYTHON_VERSIONS_OVERRIDE},${PYTHON_VERSIONS_OVERRIDE},${PYTHON_VERSIONS_AUTOMATIC})

.PHONY: default
Expand Down Expand Up @@ -70,6 +70,5 @@ test: build
ghcr.io/newrelic/python-agent-ci:local \
/bin/bash -c '\
python3.10 --version && \
python2.7 --version && \
touch tox.ini && tox --version && \
echo "Success! Python versions installed."'
2 changes: 1 addition & 1 deletion .github/containers/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ isort
pip
setuptools
tox
virtualenv<20.22.0
virtualenv
wheel
30 changes: 0 additions & 30 deletions .github/workflows/deploy-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,35 +64,6 @@ jobs:
path: ./wheelhouse/*.whl
retention-days: 1

build-linux-py2:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1
with:
persist-credentials: false
fetch-depth: 0

- name: Setup QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # 3.0.0

- name: Build Wheels
uses: pypa/cibuildwheel@bf3a5590c9aeb9a7e4ff4025ef7400e0c6ad1248 # 1.12.0 (Last release to support Python 2)
env:
CIBW_PLATFORM: linux
CIBW_BUILD: cp27-manylinux_x86_64
CIBW_ARCHS_LINUX: x86_64
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"
CIBW_TEST_REQUIRES: pytest==4.6.11
CIBW_TEST_COMMAND: "PYTHONPATH={project}/tests pytest {project}/tests/agent_unittests -vx"

- name: Upload Artifacts
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # 4.3.1
with:
name: ${{ github.job }}
path: ./wheelhouse/*.whl
retention-days: 1

build-sdist:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -130,7 +101,6 @@ jobs:

needs:
- build-linux-py3
- build-linux-py2
- build-sdist

steps:
Expand Down
9 changes: 0 additions & 9 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ Distributed under the following license(s):
* [The Apache License, Version 2.0 License](https://opensource.org/license/apache-2-0/)


## [six](https://pypi.org/project/six)

Copyright (c) 2010-2013 Benjamin Peterson

Distributed under the following license(s):

* [The MIT License](http://opensource.org/licenses/MIT)


## [time.monotonic](newrelic/common/_monotonic.c)

Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Python Software Foundation; All Rights Reserved
Expand Down
2 changes: 0 additions & 2 deletions newrelic/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function

import logging
import sys

Expand Down
2 changes: 0 additions & 2 deletions newrelic/admin/debug_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function

from newrelic.admin import command, usage

@command('debug-console', 'config_file [session_log]',
Expand Down
2 changes: 0 additions & 2 deletions newrelic/admin/generate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function

from newrelic.admin import command, usage

@command('generate-config', 'license_key [output_file]',
Expand Down
2 changes: 0 additions & 2 deletions newrelic/admin/license_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function

from newrelic.admin import command, usage
from newrelic.common.encoding_utils import obfuscate_license_key

Expand Down
2 changes: 0 additions & 2 deletions newrelic/admin/local_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function

from newrelic.admin import command, usage


Expand Down
2 changes: 0 additions & 2 deletions newrelic/admin/network_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function

from newrelic.admin import command, usage


Expand Down
2 changes: 0 additions & 2 deletions newrelic/admin/record_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function

import os
import pwd

Expand Down
2 changes: 0 additions & 2 deletions newrelic/admin/run_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function

from newrelic.admin import command, usage


Expand Down
2 changes: 0 additions & 2 deletions newrelic/admin/run_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function

from newrelic.admin import command, usage

@command('run-python', '...',
Expand Down
2 changes: 0 additions & 2 deletions newrelic/admin/server_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function

from newrelic.admin import command, usage


Expand Down
2 changes: 0 additions & 2 deletions newrelic/admin/validate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function

from newrelic.admin import command, usage


Expand Down
3 changes: 1 addition & 2 deletions newrelic/api/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import newrelic.api.import_hook
import newrelic.core.agent
import newrelic.core.config
import newrelic.packages.six as six


class Application(object):
Expand Down Expand Up @@ -106,7 +105,7 @@ def shutdown(self):

@property
def linked_applications(self):
return list(six.iterkeys(self._linked))
return list(self._linked.keys())

def link_to_application(self, name):
self._linked[name] = True
Expand Down
4 changes: 2 additions & 2 deletions newrelic/api/asgi_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
function_wrapper,
wrap_object,
)
from newrelic.packages import asgiref_compatibility, six
from newrelic.packages import asgiref_compatibility


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

# If we have inserted the browser agent
Expand Down
Loading

0 comments on commit 0704620

Please sign in to comment.