Ticket #10176: trac_10176-further_improve_spkg_install-spkg.patch

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

SageNB spkg patch (0.8.7.p1 -> 0.8.7.p2). Removes ln -snf etc.; apply on top of the previous spkg patch (i.e., the p1).

  • setup.py

    # 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  
    55import os, sys, time
    66from setuptools import setup
    77
     8
     9import distutils.log
     10
     11if os.environ.get("SAGE_SETUPTOOLS_DEBUG","no")=="yes":
     12    distutils.log.set_threshold(distutils.log.DEBUG)
     13
     14
    815def all_files(dir, lstrip):
    916    """
    1017    Return list of all filenames in the given directory, with lstrip
     
    2128   
    2229
    2330code = 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
    2532      description = 'The Sage Notebook',
    2633      license     = 'GNU Public License (GPL) v2+',
    2734      author      = 'William Stein et al.',
  • spkg-dist

    diff -r cfcdef9e7a82 -r 60d3b34db22e spkg-dist
    a b  
    7777
    7878os.chdir(os.path.pardir)
    7979
     80# Write the whole file from a single raw Python string:
     81# (The #! has to be on the first line of the script.)
    8082spkg_install_fd.write(
    8183r"""#!/usr/bin/env bash
    8284
     
    9294cd sagenb
    9395python setup.py install
    9496if [ $? -ne 0 ]; then
    95     echo "Error running setup.py install"
     97    echo "Error running 'setup.py install'."
    9698    exit 1
    9799fi
    98100
    99 mkdir -p "$SAGE_ROOT/devel"
     101mkdir -p "$SAGE_ROOT/devel" # Create if it doesn't already exist
    100102
    101 echo "Copying SageNB package to '$SAGE_ROOT/devel/sagenb-main'."
     103echo "Copying SageNB package to '$SAGE_ROOT/devel/sagenb-main'..."
     104
    102105if [ -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'..."
    104107    rm -rf "$SAGE_ROOT/devel/sagenb-main-old"
    105108    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
    106113fi
    107114
    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
     115rm -f "$SAGE_ROOT/devel/sagenb" # Delete just the link itself (if it exists)
    110116
    111 cd ..
    112 cp -pr sagenb "$SAGE_ROOT/devel/sagenb-main"
     117cd .. # Back to sagenb-x.y.z/src/
     118cp -pr sagenb "$SAGE_ROOT/devel/sagenb-main" # Creates new sagenb-main dir
     119if [ $? -ne 0 ]; then
     120    echo "Error copying the new SageNB package."
     121    exit 1
     122fi
    113123
    114124cd "$SAGE_ROOT/devel"
    115 ln -snf sagenb-main sagenb
     125ln -s sagenb-main sagenb # Create new symbolic link (deleted above)
     126if [ $? -ne 0 ]; then
     127    echo "Error creating symbolic link to '$SAGE_ROOT/devel/sagenb-main'."
     128    exit 1
     129fi
    116130
    117131# We use relative paths for relocatability.
    118132cd "$SAGE_ROOT/devel/sagenb"
    119133python setup.py develop --egg-path ../../../../devel/sagenb
    120134if [ $? -ne 0 ]; then
    121     echo "Error running setup.py develop"
     135    echo "Error running 'setup.py develop'."
    122136    exit 1
    123137fi
    124138
     
    127141# doesn't understand "-q" (which *is* POSIX):
    128142if ! grep sagenb easy-install.pth >/dev/null; then
    129143    # 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'..."
    132146    sed -e '$ i \../../../../devel/sagenb' easy-install.pth > easy-install.pth.$$
    133147    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'."
    135149        exit 1
    136150    fi
    137151else
    138     echo "Making sagenb path in easy-install.pth relative"
     152    echo "Making sagenb path in 'easy-install.pth' relative..."
    139153    sed 's/^.*sagenb.*$/..\/..\/..\/..\/devel\/sagenb/' easy-install.pth > easy-install.pth.$$
    140154    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."
    142156        exit 1
    143157    fi
    144158fi
    145 if true; then # DEBUG (cf. #10176)
     159if true; then # Aids debugging (cf. #10176)
    146160    echo "Old path: \"`grep sagenb easy-install.pth`\""
    147161    echo "New path: \"`grep sagenb easy-install.pth.$$`\""
    148162fi
    149163# The following fails only on wrong file permissions etc.:
    150164mv -f easy-install.pth.$$ easy-install.pth
    151165if [ $? -ne 0 ]; then
    152     echo "Error overwriting original easy-install.pth"
     166    echo "Error overwriting original 'easy-install.pth'."
    153167    exit 1
    154168fi
    155169""")