summaryrefslogtreecommitdiffstats
path: root/Tools/scripts/checkpip.py
diff options
context:
space:
mode:
authorDonald Stufft <donald@stufft.io>2014-11-11 15:24:11 (GMT)
committerDonald Stufft <donald@stufft.io>2014-11-11 15:24:11 (GMT)
commit8aaff54db30b902702feb99344e60d77ddd6a551 (patch)
tree7654ff5d04bcc726cac393f72f62cedff2f0a05c /Tools/scripts/checkpip.py
parent04eee639499f3d643e14099b7374bc8a259af015 (diff)
downloadcpython-8aaff54db30b902702feb99344e60d77ddd6a551.zip
cpython-8aaff54db30b902702feb99344e60d77ddd6a551.tar.gz
cpython-8aaff54db30b902702feb99344e60d77ddd6a551.tar.bz2
Implement PEP 477 - Backport ensurepip (PEP 453) to 2.7
* Backports ensurepip to the 2.7 branch * Backports some of the improved documentation to the 2.7 branch. * Adds a private backport of the 3.x mock library as test._mock_backport to enable saner testing of ensurepip. Key Differences from 3.x: * Ensurepip does not have any Makefile integration, specifically it is not ran by default in the Makefile. * There is no venv module in 2.7, so downstream distributors can completely disable ensurepip, ideally with a message redirecting to the correct way to install pip. * To match the ``python`` command in 2.7, ensurepip will install the unversioned ``pip`` command as well. * No-op and hide --default-pip and add --no-default-pip to restore the 3.x behavor on 2.7.
Diffstat (limited to 'Tools/scripts/checkpip.py')
-rw-r--r--Tools/scripts/checkpip.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/Tools/scripts/checkpip.py b/Tools/scripts/checkpip.py
new file mode 100644
index 0000000..1b6049d
--- /dev/null
+++ b/Tools/scripts/checkpip.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python2
+"""
+Checks that the version of the projects bundled in ensurepip are the latest
+versions available.
+"""
+import ensurepip
+import json
+import urllib2
+import sys
+
+
+def main():
+ outofdate = False
+
+ for project, version in ensurepip._PROJECTS:
+ data = json.loads(urllib2.urlopen(
+ "https://pypi.python.org/pypi/{}/json".format(project),
+ ).read().decode("utf8"))
+ upstream_version = data["info"]["version"]
+
+ if version != upstream_version:
+ outofdate = True
+ print("The latest version of {} on PyPI is {}, but ensurepip "
+ "has {}".format(project, upstream_version, version))
+
+ if outofdate:
+ sys.exit(1)
+
+
+if __name__ == "__main__":
+ main()