# HG changeset patch
# User Leif Leonhardy <not.really@online.de>
# Date 1288319594 -7200
# Node ID 60d3b34db22e26844317d85da6a83e30b6f42472
# Parent cfcdef9e7a8220f09f3c5268b7f1b27e60f88261
#10176: Version 0.8.7.p2 removes non-POSIX "ln -snf"; more error checking, comments, cosmetic changes; support for debugging.
spkg-install (generated in/by spkg-dist):
* The "-n" option to "ln" is non-portable, so we avoid it now.
* Some more checks of command exit codes added.
* Clarifying commments added, also to prevent later changes breaking things.
* Messages "normalized".
setup.py:
* If SAGE_SETUPTOOLS_DEBUG="yes", we now enable output of distutils.log.debug()
messages. Setuptools seem to ignore the DISTUTILS_DEBUG environment variable,
though distutils' logging is used.
Perhaps I'm missing something here, but this way it works.
diff -r cfcdef9e7a82 -r 60d3b34db22e setup.py
a
|
b
|
|
5 | 5 | import os, sys, time |
6 | 6 | from setuptools import setup |
7 | 7 | |
| 8 | |
| 9 | import distutils.log |
| 10 | |
| 11 | if os.environ.get("SAGE_SETUPTOOLS_DEBUG","no")=="yes": |
| 12 | distutils.log.set_threshold(distutils.log.DEBUG) |
| 13 | |
| 14 | |
8 | 15 | def all_files(dir, lstrip): |
9 | 16 | """ |
10 | 17 | Return list of all filenames in the given directory, with lstrip |
… |
… |
|
21 | 28 | |
22 | 29 | |
23 | 30 | code = setup(name = 'sagenb', |
24 | | version = '0.8.7.p1', # the spkg-dist script assumes single quotes here |
| 31 | version = '0.8.7.p2', # the spkg-dist script assumes single quotes here |
25 | 32 | description = 'The Sage Notebook', |
26 | 33 | license = 'GNU Public License (GPL) v2+', |
27 | 34 | author = 'William Stein et al.', |
diff -r cfcdef9e7a82 -r 60d3b34db22e spkg-dist
a
|
b
|
|
77 | 77 | |
78 | 78 | os.chdir(os.path.pardir) |
79 | 79 | |
| 80 | # Write the whole file from a single raw Python string: |
| 81 | # (The #! has to be on the first line of the script.) |
80 | 82 | spkg_install_fd.write( |
81 | 83 | r"""#!/usr/bin/env bash |
82 | 84 | |
… |
… |
|
92 | 94 | cd sagenb |
93 | 95 | python setup.py install |
94 | 96 | if [ $? -ne 0 ]; then |
95 | | echo "Error running setup.py install" |
| 97 | echo "Error running 'setup.py install'." |
96 | 98 | exit 1 |
97 | 99 | fi |
98 | 100 | |
99 | | mkdir -p "$SAGE_ROOT/devel" |
| 101 | mkdir -p "$SAGE_ROOT/devel" # Create if it doesn't already exist |
100 | 102 | |
101 | | echo "Copying SageNB package to '$SAGE_ROOT/devel/sagenb-main'." |
| 103 | echo "Copying SageNB package to '$SAGE_ROOT/devel/sagenb-main'..." |
| 104 | |
102 | 105 | if [ -d "$SAGE_ROOT/devel/sagenb-main" ]; then |
103 | | echo "Moving old SageNB package to '$SAGE_ROOT/devel/sagenb-main-old'." |
| 106 | echo "Moving old SageNB package to '$SAGE_ROOT/devel/sagenb-main-old'..." |
104 | 107 | rm -rf "$SAGE_ROOT/devel/sagenb-main-old" |
105 | 108 | mv "$SAGE_ROOT/devel/sagenb-main" "$SAGE_ROOT/devel/sagenb-main-old" |
| 109 | if [ $? -ne 0 ]; then |
| 110 | echo "Error moving the old 'sagenb-main' branch." |
| 111 | exit 1 |
| 112 | fi |
106 | 113 | fi |
107 | 114 | |
108 | | # Rather than copying, we now use 'mv' above, so nothing to delete here: |
109 | | # rm -rf "$SAGE_ROOT/devel/sagenb" # Should point to sagenb-main if it exists |
| 115 | rm -f "$SAGE_ROOT/devel/sagenb" # Delete just the link itself (if it exists) |
110 | 116 | |
111 | | cd .. |
112 | | cp -pr sagenb "$SAGE_ROOT/devel/sagenb-main" |
| 117 | cd .. # Back to sagenb-x.y.z/src/ |
| 118 | cp -pr sagenb "$SAGE_ROOT/devel/sagenb-main" # Creates new sagenb-main dir |
| 119 | if [ $? -ne 0 ]; then |
| 120 | echo "Error copying the new SageNB package." |
| 121 | exit 1 |
| 122 | fi |
113 | 123 | |
114 | 124 | cd "$SAGE_ROOT/devel" |
115 | | ln -snf sagenb-main sagenb |
| 125 | ln -s sagenb-main sagenb # Create new symbolic link (deleted above) |
| 126 | if [ $? -ne 0 ]; then |
| 127 | echo "Error creating symbolic link to '$SAGE_ROOT/devel/sagenb-main'." |
| 128 | exit 1 |
| 129 | fi |
116 | 130 | |
117 | 131 | # We use relative paths for relocatability. |
118 | 132 | cd "$SAGE_ROOT/devel/sagenb" |
119 | 133 | python setup.py develop --egg-path ../../../../devel/sagenb |
120 | 134 | if [ $? -ne 0 ]; then |
121 | | echo "Error running setup.py develop" |
| 135 | echo "Error running 'setup.py develop'." |
122 | 136 | exit 1 |
123 | 137 | fi |
124 | 138 | |
… |
… |
|
127 | 141 | # doesn't understand "-q" (which *is* POSIX): |
128 | 142 | if ! grep sagenb easy-install.pth >/dev/null; then |
129 | 143 | # Ugly work-around, we haven't found the real cause yet (see #10176): |
130 | | echo 'No sagenb path found in easy-install.pth!' |
131 | | echo "Adding relative sagenb path to easy-install.pth" |
| 144 | echo "No sagenb path found in 'easy-install.pth'"'!' |
| 145 | echo "Adding relative sagenb path to 'easy-install.pth'..." |
132 | 146 | sed -e '$ i \../../../../devel/sagenb' easy-install.pth > easy-install.pth.$$ |
133 | 147 | if [ $? -ne 0 ]; then |
134 | | echo "Error adding relative sagenb path to easy-install.pth" |
| 148 | echo "Error adding relative sagenb path to 'easy-install.pth'." |
135 | 149 | exit 1 |
136 | 150 | fi |
137 | 151 | else |
138 | | echo "Making sagenb path in easy-install.pth relative" |
| 152 | echo "Making sagenb path in 'easy-install.pth' relative..." |
139 | 153 | sed 's/^.*sagenb.*$/..\/..\/..\/..\/devel\/sagenb/' easy-install.pth > easy-install.pth.$$ |
140 | 154 | if [ $? -ne 0 ]; then |
141 | | echo "Error patching easy-install.pth to have relative path to SageNB" |
| 155 | echo "Error patching 'easy-install.pth' to have relative path to SageNB." |
142 | 156 | exit 1 |
143 | 157 | fi |
144 | 158 | fi |
145 | | if true; then # DEBUG (cf. #10176) |
| 159 | if true; then # Aids debugging (cf. #10176) |
146 | 160 | echo "Old path: \"`grep sagenb easy-install.pth`\"" |
147 | 161 | echo "New path: \"`grep sagenb easy-install.pth.$$`\"" |
148 | 162 | fi |
149 | 163 | # The following fails only on wrong file permissions etc.: |
150 | 164 | mv -f easy-install.pth.$$ easy-install.pth |
151 | 165 | if [ $? -ne 0 ]; then |
152 | | echo "Error overwriting original easy-install.pth" |
| 166 | echo "Error overwriting original 'easy-install.pth'." |
153 | 167 | exit 1 |
154 | 168 | fi |
155 | 169 | """) |