Mercurial > cpython-lru_cache-weakref
annotate Mac/BuildScript/scripts/postflight.patch-profile @ 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 | 9523dbe0b649 |
| children |
| rev | line source |
|---|---|
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1 #!/bin/sh |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2 |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
3 echo "This script will update your shell profile when the 'bin' directory" |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
4 echo "of python is not early enough of the PATH of your shell." |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
5 echo "These changes will be effective only in shell windows that you open" |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
6 echo "after running this script." |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
7 |
|
51564
acdb32341d87
Merged revisions 69544 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
40450
diff
changeset
|
8 PYVER=@PYVER@ |
|
acdb32341d87
Merged revisions 69544 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
40450
diff
changeset
|
9 PYTHON_ROOT="/Library/Frameworks/Python.framework/Versions/@PYVER@" |
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
10 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
11 if [ `id -ur` = 0 ]; then |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
12 # Run from the installer, do some trickery to fetch the information |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
13 # we need. |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
14 theShell="`finger $USER | grep Shell: | head -1 | awk '{ print $NF }'`" |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
15 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
16 else |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
17 theShell="${SHELL}" |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
18 fi |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
19 |
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
20 # Make sure the directory ${PYTHON_ROOT}/bin is on the users PATH. |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
21 BSH="`basename "${theShell}"`" |
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
22 case "${BSH}" in |
|
64974
9523dbe0b649
Add support for the ZSH shell to the "Update Shell Profile" script
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
57361
diff
changeset
|
23 bash|ksh|sh|*csh|zsh) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
24 if [ `id -ur` = 0 ]; then |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
25 P=`su - ${USER} -c 'echo A-X-4-X@@$PATH@@X-4-X-A' | grep 'A-X-4-X@@.*@@X-4-X-A' | sed -e 's/^A-X-4-X@@//g' -e 's/@@X-4-X-A$//g'` |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
26 else |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
27 P="`(exec -l ${theShell} -c 'echo $PATH')`" |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
28 fi |
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
29 ;; |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
30 *) |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
31 echo "Sorry, I don't know how to patch $BSH shells" |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
32 exit 0 |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
33 ;; |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
34 esac |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
35 |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
36 # Now ensure that our bin directory is on $P and before /usr/bin at that |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
37 for elem in `echo $P | tr ':' ' '` |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
38 do |
|
57361
24d1e06c629c
Merged revisions 76409 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54212
diff
changeset
|
39 if [ "${elem}" = "${PYTHON_ROOT}/bin" ]; then |
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
40 echo "All right, you're a python lover already" |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
41 exit 0 |
|
57361
24d1e06c629c
Merged revisions 76409 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54212
diff
changeset
|
42 elif [ "${elem}" = "/usr/bin" ]; then |
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
43 break |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
44 fi |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
45 done |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
46 |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
47 echo "${PYTHON_ROOT}/bin is not on your PATH or at least not early enough" |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
48 case "${BSH}" in |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
49 *csh) |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
50 if [ -f "${HOME}/.tcshrc" ]; then |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
51 RC="${HOME}/.tcshrc" |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
52 else |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
53 RC="${HOME}/.cshrc" |
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
54 fi |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
55 # Create backup copy before patching |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
56 if [ -f "${RC}" ]; then |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
57 cp -fp "${RC}" "${RC}.pysave" |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
58 fi |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
59 echo "" >> "${RC}" |
|
54212
c7fd741c72eb
Merged revisions 72789 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
51564
diff
changeset
|
60 echo "# Setting PATH for Python ${PYVER}" >> "${RC}" |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
61 echo "# The orginal version is saved in .cshrc.pysave" >> "${RC}" |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
62 echo "set path=(${PYTHON_ROOT}/bin "'$path'")" >> "${RC}" |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
63 if [ `id -ur` = 0 ]; then |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
64 chown "${USER}" "${RC}" |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
65 fi |
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
66 exit 0 |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
67 ;; |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
68 bash) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
69 if [ -e "${HOME}/.bash_profile" ]; then |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
70 PR="${HOME}/.bash_profile" |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
71 elif [ -e "${HOME}/.bash_login" ]; then |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
72 PR="${HOME}/.bash_login" |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
73 elif [ -e "${HOME}/.profile" ]; then |
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
74 PR="${HOME}/.profile" |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
75 else |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
76 PR="${HOME}/.bash_profile" |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
77 fi |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
78 ;; |
|
64974
9523dbe0b649
Add support for the ZSH shell to the "Update Shell Profile" script
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
57361
diff
changeset
|
79 zsh) |
|
9523dbe0b649
Add support for the ZSH shell to the "Update Shell Profile" script
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
57361
diff
changeset
|
80 PR="${HOME}/.zprofile" |
|
9523dbe0b649
Add support for the ZSH shell to the "Update Shell Profile" script
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
57361
diff
changeset
|
81 ;; |
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
82 *sh) |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
83 PR="${HOME}/.profile" |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
84 ;; |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
85 esac |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
86 |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
87 # Create backup copy before patching |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
88 if [ -f "${PR}" ]; then |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
89 cp -fp "${PR}" "${PR}.pysave" |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
90 fi |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
91 echo "" >> "${PR}" |
|
54212
c7fd741c72eb
Merged revisions 72789 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
51564
diff
changeset
|
92 echo "# Setting PATH for Python ${PYVER}" >> "${PR}" |
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
93 echo "# The orginal version is saved in `basename ${PR}`.pysave" >> "${PR}" |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
94 echo 'PATH="'"${PYTHON_ROOT}/bin"':${PATH}"' >> "${PR}" |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
95 echo 'export PATH' >> "${PR}" |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
96 if [ `id -ur` = 0 ]; then |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
97 chown "${USER}" "${PR}" |
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
98 fi |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
99 exit 0 |
