From fdffda2cc2a32a1ed623505bdaf54678866e74ee Mon Sep 17 00:00:00 2001 From: jab Date: Wed, 13 Nov 2019 02:39:04 +0000 Subject: [PATCH] Abort if PY2 detected in setup.py. Loosen python_requires to '>=3'. Better warning for PY3 < 3.5. --- bidict/__init__.py | 5 ++--- setup.py | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/bidict/__init__.py b/bidict/__init__.py index 1d54a27..0c890b2 100644 --- a/bidict/__init__.py +++ b/bidict/__init__.py @@ -54,9 +54,8 @@ from .compat import PY2, PYMAJOR, PYMINOR if PY2: raise ImportError('Python 3.5+ is required.') -# Assume Python 3 when not PY2, but explicitly check before showing this warning. -if PYMAJOR == 3 and PYMINOR < 5: # pragma: no cover - warn('Python 3.4 and below are not supported.') +if (PYMAJOR, PYMINOR) < (3, 5): # pragma: no cover + warn('This version of bidict is untested on Python < 3.5 and may not work.') # The rest of this file only collects functionality implemented in the rest of the diff --git a/setup.py b/setup.py index 77ca0cb..41a9d61 100644 --- a/setup.py +++ b/setup.py @@ -10,12 +10,31 @@ Ref: https://github.com/pypa/sampleproject/blob/master/setup.py """ +import sys from codecs import open as c_open from os.path import abspath, dirname, join +from warnings import warn from setuptools import setup +PY2_ERR = """ +This version of bidict does not support Python 2. +Either use bidict 0.18.3, +the last release with Python 2 support, +or use Python 3. + +Also ensure you are using pip >= 9.0.1 to install bidict. + +See python3statement.org for more info. +""" + +if sys.version_info < (3,): + sys.exit(PY2_ERR) +elif sys.version_info < (3, 5): + warn('This version of bidict is untested on Python < 3.5 and may not work.') + + CWD = abspath(dirname(__file__)) # Get bidict's package metadata from ./bidict/metadata.py. @@ -125,7 +144,7 @@ setup( license=METADATA.__license__, packages=['bidict'], zip_safe=False, # Don't zip. (We're zip-safe but prefer not to.) - python_requires='>=3.5', + python_requires='>=3', classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers',