Skip to content

Commit 32ade4d

Browse files
Zac-HDtimgraham
authored andcommitted
Fixed #28878 -- Added python_requires in setup.py and a warning for older pips that don't recognize it.
1 parent 622ead6 commit 32ade4d

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,7 @@ answer newbie questions, and generally made Django that much better:
845845
846846
Yoong Kang Lim <[email protected]>
847847
Yusuke Miyazaki <[email protected]>
848+
Zac Hatfield-Dodds <[email protected]>
848849
Zachary Voase <[email protected]>
849850
Zach Liu <[email protected]>
850851
Zach Thompson <[email protected]>

setup.py

+30
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,35 @@
44

55
from setuptools import find_packages, setup
66

7+
CURRENT_PYTHON = sys.version_info[:2]
8+
REQUIRED_PYTHON = (3, 5)
9+
10+
# This check and everything above must remain compatible with Python 2.7.
11+
if CURRENT_PYTHON < REQUIRED_PYTHON:
12+
sys.stderr.write("""
13+
==========================
14+
Unsupported Python version
15+
==========================
16+
17+
This version of Django requires Python {}.{}, but you're trying to
18+
install it on Python {}.{}.
19+
20+
This may be because you are using a version of pip that doesn't
21+
understand the python_requires classifier. Make sure you
22+
have pip >= 9.0 and setuptools >= 24.2, then try again:
23+
24+
$ python -m pip install --upgrade pip setuptools
25+
$ python -m pip install django
26+
27+
This will install the latest version of Django which works on your
28+
version of Python. If you can't upgrade your pip (or Python), request
29+
an older version of Django:
30+
31+
$ python -m pip install "django<2"
32+
""".format(*(REQUIRED_PYTHON + CURRENT_PYTHON)))
33+
sys.exit(1)
34+
35+
736
# Warn if we are installing over top of an existing installation. This can
837
# cause issues where files that were deleted from a more recent Django are
938
# still present in site-packages. See #18115.
@@ -35,6 +64,7 @@
3564
setup(
3665
name='Django',
3766
version=version,
67+
python_requires='>={}.{}'.format(*REQUIRED_PYTHON),
3868
url='https://www.djangoproject.com/',
3969
author='Django Software Foundation',
4070
author_email='[email protected]',

0 commit comments

Comments
 (0)