11#!/usr/bin/env python
22# Create a new Sage Notebook spkg.
3-
3+ #
44# Since the 'sdist' shell script called below requires (at least) 'sage'
55# to be in the path, we could equally check *here* if it is; SAGE_ROOT
66# or SAGE_LOCAL don't have to be set, since 'sdist' calls 'sage -hg ...'
77# and 'sage -python ...'.
88# (We also later run 'sage -pkg ...' from *this* script.)
99#
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
10+ # This spkg-dist doesn't need any Sage components, it is fine to run
11+ # it from a system-wide Python. -- Jeroen Demeyer
1412
1513import os
1614import sys
2927except IndexError :
3028 sys .stderr .write ("Error: Found no version string in 'setup.py'\n " )
3129 sys .exit (1 )
30+
3231i = version_line .find ("'" )
3332j = version_line .rfind ("'" )
3433if i == - 1 or j == - 1 or j - i < 3 :
3534 sys .stderr .write (
36- "Error: Illegal version string in 'setup.py':\n %s\n " % version_line )
35+ "Error: Illegal version string in 'setup.py':\n %s\n " % version_line )
3736 sys .stderr .write ("Perhaps no single quotes used?\n " )
3837 sys .exit (1 )
3938version = version_line [i + 1 :j ]
@@ -44,14 +43,8 @@ print "Creating the new source tarball..."
4443sys .stdout .flush ()
4544proc = subprocess .Popen ([os .path .join (os .path .curdir , 'sdist' )], shell = True )
4645if proc .wait ():
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."
5346 sys .stderr .write (
54- "Error: './sdist' failed. See message(s) above for the specific error.\n " )
47+ "Error: './sdist' failed. See message(s) above for the specific error.\n " )
5548 sys .exit (1 )
5649
5750# Create the spkg.
@@ -179,8 +172,7 @@ if [ $? -ne 0 ]; then
179172fi
180173
181174cd "$SAGE_ROOT/local/lib/python/site-packages"
182- # Dave says Solaris' non-POSIX grep in the default path
183- # doesn't understand "-q" (which *is* POSIX):
175+ # Use >/dev/null instead of grep -q (which doesn't work on Solaris)
184176if ! grep sagenb easy-install.pth >/dev/null; then
185177 # Ugly work-around, we haven't found the real cause yet (see #10176):
186178 echo "No sagenb path found in 'easy-install.pth'"'!'
@@ -198,10 +190,11 @@ else
198190 exit 1
199191 fi
200192fi
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
193+
194+ # Print paths for debugging
195+ echo "Old path: '`grep sagenb easy-install.pth`'"
196+ echo "New path: '`grep sagenb easy-install.pth.$$`'"
197+
205198# The following fails only on wrong file permissions etc.:
206199mv -f easy-install.pth.$$ easy-install.pth
207200if [ $? -ne 0 ]; then
@@ -216,6 +209,6 @@ os.chmod(spkg_install, stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP |
216209# We are still in dist/, now package sagenb-x.y.z/ :
217210print "Running 'sage -pkg %s'..." % base
218211sys .stdout .flush ()
219- subprocess .call (['sage -pkg ' + base ], shell = True )
220- # XXX Perhaps also check exit code here... (but 'sage -pkg' is verbose)
221-
212+ if subprocess .call (['sage' , ' -pkg' , base ]):
213+ print "sage -pkg %s failed. See message(s) above for the specific error. \n " % base
214+ sys . exit ( 1 )
0 commit comments