Ticket #10176: sagenb-0.8.9-0.8.9.p1.diff
File sagenb-0.8.9-0.8.9.p1.diff, 10.1 KB (added by , 11 years ago) |
---|
-
sdist
diff --git a/sdist b/sdist
a b 1 #!/bin/bash 2 set -e 1 #!/usr/bin/env bash 3 2 3 # Just curious: *Which* 'sage' is supposed to be called here? 4 # Should we check if SAGE_LOCAL or SAGE_ROOT is defined? 5 # ... and perhaps call $SAGE_ROOT/sage or $SAGE_LOCAL/bin/...? -leif 6 7 # At least check that 'sage' is in the path to specifically catch 8 # one potential error [earlier, with an appropriate error message]: 9 if ! command -v sage >/dev/null; then 10 echo >&2 "Error: $0 requires 'sage' to be in your PATH" 11 echo >&2 "Maybe first call 'SAGE_ROOT/sage -sh'" 12 exit 1 13 fi 14 15 echo "Trying to commit changes (if any)..." 4 16 sage -hg ci 17 status=$? 18 if [ $status -eq 1 ]; then 19 # 'hg ci' returns 1 (!) if there are no changes to commit... 20 echo "No changes to commit (not an error)" 21 elif [ $status -ne 0 ]; then 22 echo >&2 "Error: $0: Couldn't commit changes" \ 23 "('hg ci' failed with exit code $status)" 24 exit 1 25 else 26 # $status == 0 27 echo "Successfully committed the changes" 28 fi 5 29 30 echo "Running 'python setup.py sdist'..." 6 31 sage -python setup.py sdist 32 if [ $? -ne 0 ]; then 33 echo >&2 "Error: $0: 'python setup.py sdist' failed" 34 exit 1 35 fi 36 7 37 8 38 echo "**********************************************************" 9 39 echo "* If this is an official SageNB release, don't forget to *" -
setup.py
diff --git a/setup.py b/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.9 ', # the spkg-dist script assumes single quotes here31 version = '0.8.9.p1', # 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.', -
spkg-dist
diff --git a/spkg-dist b/spkg-dist
a b 1 1 #!/usr/bin/env python 2 2 # Create a new Sage Notebook spkg. 3 3 4 # Since the 'sdist' shell script called below requires (at least) 'sage' 5 # to be in the path, we could equally check *here* if it is; SAGE_ROOT 6 # or SAGE_LOCAL don't have to be set, since 'sdist' calls 'sage -hg ...' 7 # and 'sage -python ...'. 8 # (We also later run 'sage -pkg ...' from *this* script.) 9 # 10 # We *might* get import errors earlier if some system-wide Python executes 11 # this script (which is probably not intended), so we could really check 12 # here first if SAGE_LOCAL is defined, which is a strong indication that 13 # we're actually using Sage's Python. -leif 14 4 15 import os 5 16 import sys 6 17 import stat … … 13 24 from setuptools.package_index import PackageIndex 14 25 15 26 # Get the version from setup.py. 16 version_line = [f for f in open('setup.py').readlines() if 'version' in f][0] 27 try: 28 version_line = [f for f in open('setup.py').readlines() if 'version' in f][0] 29 except IndexError: 30 sys.stderr.write("Error: Found no version string in 'setup.py'\n") 31 sys.exit(1) 17 32 i = version_line.find("'") 18 33 j = version_line.rfind("'") 34 if i==-1 or j==-1 or j-i<3: 35 sys.stderr.write( 36 "Error: Illegal version string in 'setup.py':\n %s\n" % version_line) 37 sys.stderr.write("Perhaps no single quotes used?\n") 38 sys.exit(1) 19 39 version = version_line[i + 1:j] 40 print "New SageNB version: %s" % version 20 41 21 42 # Create the source distribution. 43 print "Creating the new source tarball..." 44 sys.stdout.flush() 22 45 proc = subprocess.Popen([os.path.join(os.path.curdir, 'sdist')], shell=True) 23 46 if proc.wait(): 24 print "Uncommitted changes in repository. Stopping." 47 # The previous error message was most probably inadequate, since 48 # 'sdist' tries to commit any changes, and 'hg ci' returns 1 (!) (which 49 # usually indicates an error) if there are *no changes to commit*. 50 # The other potential error in 'sdist' was that 'python setup.py sdist' 51 # failed, in which case the error message would have also been wrong. 52 #print "Uncommitted changes in repository. Stopping." 53 sys.stderr.write( 54 "Error: './sdist' failed. See message(s) above for the specific error.\n") 25 55 sys.exit(1) 26 56 27 57 # Create the spkg. … … 31 61 shutil.rmtree(path) 32 62 os.makedirs(path) 33 63 34 file = 'sagenb-%s.tar.gz' % version 35 print "Extracting %s" % file 64 file = 'sagenb-%s.tar.gz' % version # created by 'sdist' above 65 print "Extracting %s..." % file 66 sys.stdout.flush() 36 67 t = tarfile.open(os.path.join('dist', file)) 37 68 t.extractall(path) 69 print "Finished extraction." 70 sys.stdout.flush() 38 71 39 os.chdir(path) 72 os.chdir(path) # cd dist/sagenb-x.y.z 40 73 os.mkdir('src') 41 shutil.move(base, os.path.join('src', 'sagenb')) 74 print "Moving new source tree..." 75 sys.stdout.flush() 76 shutil.move(base, os.path.join('src', 'sagenb')) # mv sagenb-x.y.z src/sagenb 42 77 78 print "Copying 'SPKG.txt'..." 79 sys.stdout.flush() 80 shutil.copy(os.path.join(os.path.pardir, os.path.pardir, 'SPKG.txt'), 81 os.path.curdir) # cp ../../SPKG.txt . (which is dist/sagenb-x.y.z) 82 83 print "Creating 'spkg-install'..." 84 sys.stdout.flush() 43 85 spkg_install = os.path.abspath(os.path.join(os.path.curdir, 'spkg-install')) 44 86 spkg_install_fd = open(spkg_install, 'w') 45 spkg_install_fd.write("cd src\n")46 47 shutil.copy(os.path.join(os.path.pardir, os.path.pardir, 'SPKG.txt'),48 os.path.curdir)49 50 87 51 88 52 89 def fetch_packages(): 53 90 # This block is here in case we ever need it again. 91 # XXX Then also make sure the easy_install commands 92 # XXX get written to the correct part of spkg-install! 93 # XXX (We currently use a single string for the whole file.) 54 94 print "Fetching the required packages" 55 95 pkg_index = PackageIndex() 56 96 57 97 tmp_dir = mkdtemp() 58 98 59 60 99 required_packages = () 61 100 62 101 pkg_locations = [] … … 73 112 74 113 return [os.path.basename(location) for location in pkg_locations] 75 114 76 os.chdir(os.path.pardir)77 115 78 spkg_install_fd.write(""" 116 os.chdir(os.path.pardir) # cd .. (now in dist/) 117 118 # Write the whole file from a single raw Python string: 119 # (The #! has to be on the first line of the script.) 120 spkg_install_fd.write( 121 r"""#!/usr/bin/env bash 122 123 # spkg-install for SageNB, generated by SageNB's spkg-dist 124 125 if [ -z "$SAGE_LOCAL" ]; then 126 echo >&2 "SAGE_LOCAL undefined - exiting..." 127 exit 1 128 fi 129 130 cd src 131 79 132 cd sagenb 80 133 python setup.py install 81 82 mkdir -p "$SAGE_ROOT/devel" 83 84 echo "Copying SageNB package to '$SAGE_ROOT/devel/sagenb-main'." 85 if [ -d "$SAGE_ROOT/devel/sagenb-main" ]; then 86 echo "Copying old SageNB package to '$SAGE_ROOT/devel/sagenb-main-old'." 87 rm -rf "$SAGE_ROOT/devel/sagenb-main-old" 88 cp -pr "$SAGE_ROOT/devel/sagenb-main" "$SAGE_ROOT/devel/sagenb-main-old" 134 if [ $? -ne 0 ]; then 135 echo >&2 "Error running 'setup.py install'." 136 exit 1 89 137 fi 90 138 91 rm -f "$SAGE_ROOT/devel/sagenb" 139 mkdir -p "$SAGE_ROOT/devel" # Create if it doesn't already exist 140 if [ $? -ne 0 ]; then 141 echo >&2 "Error creating '$SAGE_ROOT/devel'." 142 exit 1 143 fi 92 144 93 cd .. 94 cp -pr sagenb "$SAGE_ROOT/devel/sagenb-main" 145 echo "Copying SageNB package to '$SAGE_ROOT/devel/sagenb-main'..." 146 147 if [ -d "$SAGE_ROOT/devel/sagenb-main" ]; then 148 echo "Moving old SageNB package to '$SAGE_ROOT/devel/sagenb-main-old'..." 149 rm -rf "$SAGE_ROOT/devel/sagenb-main-old" 150 mv "$SAGE_ROOT/devel/sagenb-main" "$SAGE_ROOT/devel/sagenb-main-old" 151 if [ $? -ne 0 ]; then 152 echo >&2 "Error moving the old 'sagenb-main' branch." 153 exit 1 154 fi 155 fi 156 157 rm -f "$SAGE_ROOT/devel/sagenb" # Delete just the link itself (if it exists) 158 159 cd .. # Back to sagenb-x.y.z/src/ 160 cp -pr sagenb "$SAGE_ROOT/devel/sagenb-main" # Creates new sagenb-main dir 161 if [ $? -ne 0 ]; then 162 echo >&2 "Error copying the new SageNB package." 163 exit 1 164 fi 95 165 96 166 cd "$SAGE_ROOT/devel" 97 ln -snf sagenb-main sagenb 167 ln -s sagenb-main sagenb # Create new symbolic link (deleted above) 168 if [ $? -ne 0 ]; then 169 echo >&2 "Error creating symbolic link to '$SAGE_ROOT/devel/sagenb-main'." 170 exit 1 171 fi 98 172 99 173 # We use relative paths for relocatability. 100 174 cd "$SAGE_ROOT/devel/sagenb" 101 175 python setup.py develop --egg-path ../../../../devel/sagenb 176 if [ $? -ne 0 ]; then 177 echo >&2 "Error running 'setup.py develop'." 178 exit 1 179 fi 102 180 103 181 cd "$SAGE_ROOT/local/lib/python/site-packages" 104 sed 's/^.*sagenb.*$/..\/..\/..\/..\/devel\/sagenb/' easy-install.pth > easy-install.pth.new 105 mv -f easy-install.pth.new easy-install.pth 182 # Dave says Solaris' non-POSIX grep in the default path 183 # doesn't understand "-q" (which *is* POSIX): 184 if ! grep sagenb easy-install.pth >/dev/null; then 185 # Ugly work-around, we haven't found the real cause yet (see #10176): 186 echo "No sagenb path found in 'easy-install.pth'"'!' 187 echo "Adding relative sagenb path to 'easy-install.pth'..." 188 sed -e '$ i \../../../../devel/sagenb' easy-install.pth > easy-install.pth.$$ 189 if [ $? -ne 0 ]; then 190 echo >&2 "Error adding relative sagenb path to 'easy-install.pth'." 191 exit 1 192 fi 193 else 194 echo "Making sagenb path in 'easy-install.pth' relative..." 195 sed 's/^.*sagenb.*$/..\/..\/..\/..\/devel\/sagenb/' easy-install.pth > easy-install.pth.$$ 196 if [ $? -ne 0 ]; then 197 echo >&2 "Error patching 'easy-install.pth' to have relative path to SageNB." 198 exit 1 199 fi 200 fi 201 if true; then # Aids debugging (cf. #10176) 202 echo "Old path: \"`grep sagenb easy-install.pth`\"" 203 echo "New path: \"`grep sagenb easy-install.pth.$$`\"" 204 fi 205 # The following fails only on wrong file permissions etc.: 206 mv -f easy-install.pth.$$ easy-install.pth 207 if [ $? -ne 0 ]; then 208 echo >&2 "Error overwriting original 'easy-install.pth'." 209 exit 1 210 fi 106 211 """) 107 212 spkg_install_fd.close() 108 213 os.chmod(spkg_install, stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP | 109 stat.S_IROTH | stat.S_IXOTH) 214 stat.S_IROTH | stat.S_IXOTH) # -rwxr-xr-x 110 215 216 # We are still in dist/, now package sagenb-x.y.z/ : 217 print "Running 'sage -pkg %s'..."%base 218 sys.stdout.flush() 111 219 subprocess.call(['sage -pkg ' + base], shell=True) 220 # XXX Perhaps also check exit code here... (but 'sage -pkg' is verbose) 221