From 79f1694b05a66cc0fbbbf4e72d63d0a340cf6d84 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 3 Jan 2020 06:30:03 -0500 Subject: [PATCH] Add obnoxious warning about Python 2 being unsupported on this release with guidance on how to avoid the warning and what to do if that guidance was ineffective. --- pkg_resources/__init__.py | 1 + pkg_resources/py2_warn.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 pkg_resources/py2_warn.py diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 2f5aa64a6e..3fa883ceb4 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -83,6 +83,7 @@ __import__('pkg_resources.extern.packaging.specifiers') __import__('pkg_resources.extern.packaging.requirements') __import__('pkg_resources.extern.packaging.markers') +__import__('pkg_resources.py2_warn') __metaclass__ = type diff --git a/pkg_resources/py2_warn.py b/pkg_resources/py2_warn.py new file mode 100644 index 0000000000..1f29851c35 --- /dev/null +++ b/pkg_resources/py2_warn.py @@ -0,0 +1,19 @@ +import sys +import warnings +import textwrap + + +msg = textwrap.dedent(""" + You are running Setuptools on Python 2, which is no longer + supported and + >>> SETUPTOOLS WILL STOP WORKING <<< + in a subsequent release. Please ensure you are installing + Setuptools using pip 9.x or later or pin to `setuptools<45` + in your environment. + If you have done those things and are still encountering + this message, please comment in + https://github.com/pypa/setuptools/issues/1458 + about the steps that led to this unsupported combination. + """) + +sys.version_info < (3,) and warnings.warn("*" * 60 + msg + "*" * 60)