Skip to content

Commit 66cbe7e

Browse files
author
Rob Speer
committed
Cope with different Python versions better in setup.py
This provides a more helpful message when you attempt to install ftfy on Python 2 (there used to be a message, but in recent versions it was erroring before it got to print the message). Because some instances of running Python 2 are now people who are trying to run Python 3 and messed up their environment, the message now shows details about what version of Python is running and where it came from. This change also sets the Trove classifier that says that we support Python 3.7.
1 parent 3cf2c86 commit 66cbe7e

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

setup.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
from setuptools import setup
21
import sys
32

3+
# Before we get to the rest of setup, with dependencies on setuptools and the
4+
# Python 3 standard library, let's make sure we're not on Python 2 and provide
5+
# a helpful message if we are.
46

57
PY2_MESSAGE = """
68
Sorry, this version of ftfy is no longer written for Python 2.
79
8-
It is much easier to provide consistent handling of Unicode when developing
9-
only for Python 3. ftfy is exactly the kind of library that Python 3 is
10-
designed for, and now there is enough Python 3 usage that we can take advantage
11-
of it and write better, simpler code.
12-
1310
The older version of ftfy, version 4.4, is still available and can run on
1411
Python 2. Try this:
1512
1613
pip install ftfy==4.4.3
1714
"""
1815

19-
DESCRIPTION = open('README.md', encoding='utf-8').read()
20-
21-
2216
if sys.version_info[0] < 3:
2317
print(PY2_MESSAGE)
18+
readable_version = sys.version.split(' ')[0]
19+
print("The version of Python you're running is: %s" % readable_version)
20+
print("Python is running from: %r" % sys.executable)
2421
sys.exit(1)
2522

2623

24+
from setuptools import setup
25+
26+
DESCRIPTION = open('README.md', encoding='utf-8').read()
27+
2728
setup(
2829
name="ftfy",
2930
version='5.5.0',
@@ -46,6 +47,7 @@
4647
"Programming Language :: Python :: 3.4",
4748
"Programming Language :: Python :: 3.5",
4849
"Programming Language :: Python :: 3.6",
50+
"Programming Language :: Python :: 3.7",
4951
"License :: OSI Approved :: MIT License",
5052
"Operating System :: OS Independent",
5153
"Topic :: Software Development :: Libraries :: Python Modules",

0 commit comments

Comments
 (0)