annotate Tools/scripts/checkpip.py @ 87690:66c1c9f32567 default tip

Add use_weakref option to functools.lru_cache The use_weakref option makes lru_cache create weak references to the function arguments when creating the cache key, which prevents them from staying in the memory forever even after all other references to them are gone. This is a proof of concept for http://bugs.python.org/issue19859
author Radomir Dopieralski <devel@sheep.art.pl>
date Tue, 03 Dec 2013 16:02:48 +0100
parents 6a6b1ee306e3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
87051
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
1 #/usr/bin/env python3
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
2 """
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
3 Checks that the version of the projects bundled in ensurepip are the latest
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
4 versions available.
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
5 """
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
6 import ensurepip
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
7 import json
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
8 import urllib.request
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
9 import sys
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
10
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
11
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
12 def main():
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
13 outofdate = False
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
14
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
15 for project, version in ensurepip._PROJECTS:
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
16 data = json.loads(urllib.request.urlopen(
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
17 "https://pypi.python.org/pypi/{}/json".format(project),
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
18 cadefault=True,
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
19 ).read().decode("utf8"))
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
20 upstream_version = data["info"]["version"]
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
21
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
22 if version != upstream_version:
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
23 outofdate = True
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
24 print("The latest version of {} on PyPI is {}, but ensurepip "
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
25 "has {}".format(project, upstream_version, version))
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
26
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
27 if outofdate:
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
28 sys.exit(1)
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
29
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
30
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
31 if __name__ == "__main__":
6a6b1ee306e3 Close #19406: Initial implementation of ensurepip
Nick Coghlan <ncoghlan@gmail.com>
parents:
diff changeset
32 main()