Ticket #10176: trac_10176-improve_spkg_dists_spkg_install_generation-spkg.patch

File trac_10176-improve_spkg_dists_spkg_install_generation-spkg.patch, 8.2 KB (added by leif, 12 years ago)

SageNB spkg patch (0.8.7 -> 0.8.7.p1). Now includes an ugly work-around.

  • setup.py

    # HG changeset patch
    # User Leif Leonhardy <not.really@online.de>
    # Date 1288190015 -7200
    # Node ID 3eafed436bc6b892a0f03b69455fb52e37c6cf1d
    # Parent  b68fd5956e6d9e741cfa4d0a602e80e44e2ecabb
    #10176 Improve generation of spkg-install (in spkg-dist)
    
    diff -r b68fd5956e6d -r 3eafed436bc6 setup.py
    a b  
    2121   
    2222
    2323code = setup(name = 'sagenb',
    24       version     = '0.8.7',  # the spkg-dist script assumes single quotes here
     24      version     = '0.8.7-patched',  # the spkg-dist script assumes single quotes here
    2525      description = 'The Sage Notebook',
    2626      license     = 'GNU Public License (GPL) v2+',
    2727      author      = 'William Stein et al.',
  • spkg-dist

    diff -r b68fd5956e6d -r 3eafed436bc6 spkg-dist
    a b  
    4242
    4343spkg_install = os.path.abspath(os.path.join(os.path.curdir, 'spkg-install'))
    4444spkg_install_fd = open(spkg_install, 'w')
    45 spkg_install_fd.write("cd src\n")
    4645
    4746shutil.copy(os.path.join(os.path.pardir, os.path.pardir, 'SPKG.txt'),
    4847            os.path.curdir)
     
    7574
    7675os.chdir(os.path.pardir)
    7776
    78 spkg_install_fd.write("""
     77spkg_install_fd.write(r"""
     78#!/usr/bin/env bash
     79
     80# spkg-install for SageNB, generated by SageNB's spkg-dist
     81
     82if [ -z "$SAGE_LOCAL" ]; then
     83    echo "SAGE_LOCAL undefined - exiting..."
     84    exit 1
     85fi
     86
     87cd src
     88
    7989cd sagenb
    8090python setup.py install
     91if [ $? -ne 0 ]; then
     92    echo "Error running setup.py install"
     93    exit 1
     94fi
    8195
    8296mkdir -p "$SAGE_ROOT/devel"
    8397
    8498echo "Copying SageNB package to '$SAGE_ROOT/devel/sagenb-main'."
    8599if [ -d "$SAGE_ROOT/devel/sagenb-main" ]; then
    86   echo "Copying old SageNB package to '$SAGE_ROOT/devel/sagenb-main-old'."
     100  echo "Moving old SageNB package to '$SAGE_ROOT/devel/sagenb-main-old'."
    87101  rm -rf "$SAGE_ROOT/devel/sagenb-main-old"
    88   cp -pr "$SAGE_ROOT/devel/sagenb-main" "$SAGE_ROOT/devel/sagenb-main-old"
     102  mv "$SAGE_ROOT/devel/sagenb-main" "$SAGE_ROOT/devel/sagenb-main-old"
    89103fi
    90104
    91 rm -f "$SAGE_ROOT/devel/sagenb"
     105# Rather than copying, we now use 'mv' above, so nothing to delete here:
     106# rm -rf "$SAGE_ROOT/devel/sagenb" # Should point to sagenb-main if it exists
    92107
    93108cd ..
    94109cp -pr sagenb "$SAGE_ROOT/devel/sagenb-main"
     
    99114# We use relative paths for relocatability.
    100115cd "$SAGE_ROOT/devel/sagenb"
    101116python setup.py develop --egg-path ../../../../devel/sagenb
     117if [ $? -ne 0 ]; then
     118    echo "Error running setup.py develop"
     119    exit 1
     120fi
    102121
    103122cd "$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
     123sed 's/^.*sagenb.*$/..\/..\/..\/..\/devel\/sagenb/' easy-install.pth > easy-install.pth.$$
     124if [ $? -ne 0 ]; then
     125    echo "Error patching easy-install.pth to have relative path to SageNB"
     126    exit 1
     127fi
     128if true; then # DEBUG
     129    echo "Old path: \"`grep '^.*sagenb' easy-install.pth`\""
     130    echo "New path: \"`grep '^.*sagenb' easy-install.pth.$$`\""
     131fi
     132# The following fails only on wrong file permissions etc.:
     133mv -f easy-install.pth.$$ easy-install.pth
     134if [ $? -ne 0 ]; then
     135    echo "Error overwriting original easy-install.pth"
     136    exit 1
     137fi
    106138""")
    107139spkg_install_fd.close()
    108140os.chmod(spkg_install, stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP |
  • setup.py

    # HG changeset patch
    # User Leif Leonhardy <not.really@online.de>
    # Date 1288219007 -7200
    # Node ID cfcdef9e7a8220f09f3c5268b7f1b27e60f88261
    # Parent  3eafed436bc6b892a0f03b69455fb52e37c6cf1d
    #10176 Version 0.8.7.p1 adds temporary work-around - not fully tracked down yet!
    
    On *some* OpenSuSE (11.1 and 11.3) installations, the sagenb path doesn't
    get added to $SAGE_ROOT/local/lib/python/site-packages/easy-install.pth,
    so we add (rather than change) it (also a relative one) in that case.
    
    Note that Sage 4.6.rc0 (with SageNB 0.8.7) apparently built ok and passed
    all tests on another OpenSuSE 11.1 system (Skynet's "menas").
    
    (This patch also fixes the previous one not putting #! on the first line.)
    
    The previous patch makes the spkg-install created by spkg-dist more robust:
     * Adds "#!/usr/bin/env bash" which was missing.
     * Adds the usual sanity check (making sure SAGE_LOCAL is defined).
     * Adds a lot more error checking.
     * Uses the shell's PID in the temporary file name.
     * Prints some more messages, including the original (if present) and
       the new path of sagenb recorded in easy-install.pth.
    
    Some clean-up:
     * Move a previous SageNB installation rather than copy and delete it.
     * Use a single, *raw* Python string for the shell script code.
     * Add a warning comment to the currently unused fetch_packages()
       function, which also writes commands to spkg-install. In case
       somebody uses this function again, the current single string
       written to spkg-install has to get split into parts to put these
       commands in the right place (neither the beginning nor the end
       of the script!).
    
    diff -r 3eafed436bc6 -r cfcdef9e7a82 setup.py
    a b  
    2121   
    2222
    2323code = setup(name = 'sagenb',
    24       version     = '0.8.7-patched',  # the spkg-dist script assumes single quotes here
     24      version     = '0.8.7.p1',  # the spkg-dist script assumes single quotes here
    2525      description = 'The Sage Notebook',
    2626      license     = 'GNU Public License (GPL) v2+',
    2727      author      = 'William Stein et al.',
  • spkg-dist

    diff -r 3eafed436bc6 -r cfcdef9e7a82 spkg-dist
    a b  
    5050
    5151def fetch_packages():
    5252    # This block is here in case we ever need it again.
     53    # XXX Then also make sure the easy_install commands
     54    # XXX get written to the correct part of spkg-install!
     55    # XXX (We currently use a single string for the whole file.)
    5356    print "Fetching the required packages"
    5457    pkg_index = PackageIndex()
    5558
     
    7477
    7578os.chdir(os.path.pardir)
    7679
    77 spkg_install_fd.write(r"""
    78 #!/usr/bin/env bash
     80spkg_install_fd.write(
     81r"""#!/usr/bin/env bash
    7982
    8083# spkg-install for SageNB, generated by SageNB's spkg-dist
    8184
     
    97100
    98101echo "Copying SageNB package to '$SAGE_ROOT/devel/sagenb-main'."
    99102if [ -d "$SAGE_ROOT/devel/sagenb-main" ]; then
    100   echo "Moving old SageNB package to '$SAGE_ROOT/devel/sagenb-main-old'."
    101   rm -rf "$SAGE_ROOT/devel/sagenb-main-old"
    102   mv "$SAGE_ROOT/devel/sagenb-main" "$SAGE_ROOT/devel/sagenb-main-old"
     103    echo "Moving old SageNB package to '$SAGE_ROOT/devel/sagenb-main-old'."
     104    rm -rf "$SAGE_ROOT/devel/sagenb-main-old"
     105    mv "$SAGE_ROOT/devel/sagenb-main" "$SAGE_ROOT/devel/sagenb-main-old"
    103106fi
    104107
    105108# Rather than copying, we now use 'mv' above, so nothing to delete here:
     
    120123fi
    121124
    122125cd "$SAGE_ROOT/local/lib/python/site-packages"
    123 sed 's/^.*sagenb.*$/..\/..\/..\/..\/devel\/sagenb/' easy-install.pth > easy-install.pth.$$
    124 if [ $? -ne 0 ]; then
    125     echo "Error patching easy-install.pth to have relative path to SageNB"
    126     exit 1
     126# Dave says Solaris' non-POSIX grep in the default path
     127# doesn't understand "-q" (which *is* POSIX):
     128if ! grep sagenb easy-install.pth >/dev/null; then
     129    # 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"
     132    sed -e '$ i \../../../../devel/sagenb' easy-install.pth > easy-install.pth.$$
     133    if [ $? -ne 0 ]; then
     134        echo "Error adding relative sagenb path to easy-install.pth"
     135        exit 1
     136    fi
     137else
     138    echo "Making sagenb path in easy-install.pth relative"
     139    sed 's/^.*sagenb.*$/..\/..\/..\/..\/devel\/sagenb/' easy-install.pth > easy-install.pth.$$
     140    if [ $? -ne 0 ]; then
     141        echo "Error patching easy-install.pth to have relative path to SageNB"
     142        exit 1
     143    fi
    127144fi
    128 if true; then # DEBUG
    129     echo "Old path: \"`grep '^.*sagenb' easy-install.pth`\""
    130     echo "New path: \"`grep '^.*sagenb' easy-install.pth.$$`\""
     145if true; then # DEBUG (cf. #10176)
     146    echo "Old path: \"`grep sagenb easy-install.pth`\""
     147    echo "New path: \"`grep sagenb easy-install.pth.$$`\""
    131148fi
    132149# The following fails only on wrong file permissions etc.:
    133150mv -f easy-install.pth.$$ easy-install.pth