Skip to content

Commit

Permalink
Merge pull request #1215 from newrelic/develop-remove-python27
Browse files Browse the repository at this point in the history
Remove Python2.7 support
  • Loading branch information
TimPansino authored Sep 25, 2024
2 parents a6830a9 + f006351 commit 286a714
Show file tree
Hide file tree
Showing 502 changed files with 2,649 additions and 6,299 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
6 changes: 1 addition & 5 deletions .github/workflows/get-envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ def main(f):
filtered_envs = environments[GROUP_NUMBER::TOTAL_GROUPS]
joined_envs = ",".join(filtered_envs)

assert joined_envs, "No environments found.\nenvironments = %s\nGROUP_NUMBER = %d\nTOTAL_GROUPS = %d" % (
str(environments),
GROUP_NUMBER + 1,
TOTAL_GROUPS,
)
assert joined_envs, f"No environments found.\nenvironments = {str(environments)}\nGROUP_NUMBER = {GROUP_NUMBER + 1}\nTOTAL_GROUPS = {TOTAL_GROUPS}"
print(joined_envs)


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
7 changes: 0 additions & 7 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,13 @@ ignore:
- "newrelic/hooks/adapter_meinheld.py"
- "newrelic/hooks/adapter_paste.py"
- "newrelic/hooks/component_piston.py"
- "newrelic/hooks/database_oursql.py"
- "newrelic/hooks/database_psycopg2ct.py"
- "newrelic/hooks/datastore_aioredis.py"
- "newrelic/hooks/datastore_aredis.py"
- "newrelic/hooks/datastore_motor.py"
- "newrelic/hooks/datastore_pyelasticsearch.py"
- "newrelic/hooks/datastore_umemcache.py"
- "newrelic/hooks/external_dropbox.py"
- "newrelic/hooks/external_facepy.py"
- "newrelic/hooks/external_pywapi.py"
- "newrelic/hooks/external_xmlrpclib.py"
- "newrelic/hooks/framework_pylons.py"
- "newrelic/hooks/framework_web2py.py"
- "newrelic/hooks/framework_webpy.py"
- "newrelic/hooks/middleware_weberror.py"
- "newrelic/packages/*"
- "newrelic/packages/**/*"
14 changes: 6 additions & 8 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 Expand Up @@ -51,7 +49,7 @@ def usage(name):
details = _commands[name]
if details.deprecated:
print("[WARNING] This command is deprecated and will be removed")
print("Usage: newrelic-admin %s %s" % (name, details.options))
print(f"Usage: newrelic-admin {name} {details.options}")


@command("help", "[command]", hidden=True)
Expand All @@ -74,18 +72,18 @@ def help(args):
name = args[0]

if name not in _commands:
print("Unknown command '%s'." % name, end=" ")
print(f"Unknown command '{name}'.", end=" ")
print("Type 'newrelic-admin help' for usage.")

else:
details = _commands[name]

print("Usage: newrelic-admin %s %s" % (name, details.options))
print(f"Usage: newrelic-admin {name} {details.options}")
if details.description:
print()
description = details.description
if details.deprecated:
description = "[DEPRECATED] " + description
description = f"[DEPRECATED] {description}"
print(description)


Expand Down Expand Up @@ -117,7 +115,7 @@ def emit(self, record):

def load_internal_plugins():
for name in _builtin_plugins:
module_name = "%s.%s" % (__name__, name)
module_name = f"{__name__}.{name}"
__import__(module_name)


Expand Down Expand Up @@ -151,7 +149,7 @@ def main():
callback = _commands[command]

except Exception:
print("Unknown command '%s'." % command, end="")
print(f"Unknown command '{command}'.", end="")
print("Type 'newrelic-admin help' for usage.")
sys.exit(1)

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
4 changes: 1 addition & 3 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 Expand Up @@ -58,4 +56,4 @@ def license_key(args):

_settings = global_settings()

print("license_key = %r" % obfuscate_license_key(_settings.license_key))
print(f"license_key = {obfuscate_license_key(_settings.license_key)!r}")
4 changes: 1 addition & 3 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 Expand Up @@ -54,4 +52,4 @@ def local_config(args):
log_file=log_file, log_level=log_level)

for key, value in sorted(global_settings()):
print('%s = %r' % (key, value))
print(f'{key} = {value!r}')
16 changes: 7 additions & 9 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 Expand Up @@ -55,10 +53,10 @@ def network_config(args):

_settings = global_settings()

print('host = %r' % _settings.host)
print('port = %r' % _settings.port)
print('proxy_scheme = %r' % _settings.proxy_scheme)
print('proxy_host = %r' % _settings.proxy_host)
print('proxy_port = %r' % _settings.proxy_port)
print('proxy_user = %r' % _settings.proxy_user)
print('proxy_pass = %r' % _settings.proxy_pass)
print(f'host = {_settings.host!r}')
print(f'port = {_settings.port!r}')
print(f'proxy_scheme = {_settings.proxy_scheme!r}')
print(f'proxy_host = {_settings.proxy_host!r}')
print(f'proxy_port = {_settings.proxy_port!r}')
print(f'proxy_user = {_settings.proxy_user!r}')
print(f'proxy_pass = {_settings.proxy_pass!r}')
15 changes: 3 additions & 12 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 Expand Up @@ -78,12 +76,10 @@ def record_deploy(
app_id = fetch_app_id(app_name, client, headers)
if app_id is None:
raise RuntimeError(
"The application named %r was not found in your account. Please "
"try running the newrelic-admin server-config command to force "
"the application to register with New Relic." % app_name
f"The application named {app_name!r} was not found in your account. Please try running the newrelic-admin server-config command to force the application to register with New Relic."
)

path = "/v2/applications/{}/deployments.json".format(app_id)
path = f"/v2/applications/{app_id}/deployments.json"

if user is None:
user = pwd.getpwuid(os.getuid()).pw_gecos
Expand All @@ -107,12 +103,7 @@ def record_deploy(

if status_code != 201:
raise RuntimeError(
"An unexpected HTTP response of %r was received "
"for request made to https://%s:%d%s. The payload for the "
"request was %r. The response payload for the request was %r. "
"If this issue persists then please report this problem to New "
"Relic support for further investigation."
% (status_code, host, port, path, data, response)
f"An unexpected HTTP response of {status_code!r} was received for request made to https://{host}:{int(port)}{path}. The payload for the request was {data!r}. The response payload for the request was {response!r}. If this issue persists then please report this problem to New Relic support for further investigation."
)


Expand Down
7 changes: 2 additions & 5 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 Expand Up @@ -42,7 +40,7 @@ def log_message(text, *args):
if startup_debug:
text = text % args
timestamp = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
print('NEWRELIC: %s (%d) - %s' % (timestamp, os.getpid(), text))
print(f'NEWRELIC: {timestamp} ({os.getpid()}) - {text}')

log_message('New Relic Admin Script (%s)', __file__)

Expand Down Expand Up @@ -80,8 +78,7 @@ def log_message(text, *args):
if 'PYTHONPATH' in os.environ:
path = os.environ['PYTHONPATH'].split(os.path.pathsep)
if boot_directory not in path:
python_path = "%s%s%s" % (boot_directory, os.path.pathsep,
os.environ['PYTHONPATH'])
python_path = f"{boot_directory}{os.path.pathsep}{os.environ['PYTHONPATH']}"

os.environ['PYTHONPATH'] = python_path

Expand Down
7 changes: 2 additions & 5 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 All @@ -37,7 +35,7 @@ def log_message(text, *args):
if startup_debug:
text = text % args
timestamp = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
print('NEWRELIC: %s (%d) - %s' % (timestamp, os.getpid(), text))
print(f'NEWRELIC: {timestamp} ({os.getpid()}) - {text}')

log_message('New Relic Admin Script (%s)', __file__)

Expand Down Expand Up @@ -73,8 +71,7 @@ def log_message(text, *args):
if 'PYTHONPATH' in os.environ:
path = os.environ['PYTHONPATH'].split(os.path.pathsep)
if not boot_directory in path:
python_path = "%s%s%s" % (boot_directory, os.path.pathsep,
os.environ['PYTHONPATH'])
python_path = f"{boot_directory}{os.path.pathsep}{os.environ['PYTHONPATH']}"

os.environ['PYTHONPATH'] = python_path

Expand Down
4 changes: 1 addition & 3 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 Expand Up @@ -75,4 +73,4 @@ def server_config(args):
_logger.debug('Registration took %s seconds.', _duration)

for key, value in sorted(_application.settings):
print('%s = %r' % (key, value))
print(f'{key} = {value!r}')
4 changes: 1 addition & 3 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 Expand Up @@ -225,7 +223,7 @@ def validate_config(args):
url = parts[1].strip()
print("Registration successful. Reporting to:")
print()
print(" %s" % url)
print(f" {url}")
print()
break

Expand Down
Loading

0 comments on commit 286a714

Please sign in to comment.