Blob Blame History Raw
--- ./ipbori/ipythonrc-polybori.orig	2011-09-05 17:11:22.000000000 -0600
+++ ./ipbori/ipythonrc-polybori	2011-09-07 15:40:52.223977416 -0600
@@ -21,20 +21,6 @@
 # PolyBoRi path (either set by wrapper or assumed to be the parent directory)
 # Note: change "execute pbdir = '..'", if you manually install this profile
 execute from os import environ as env
-execute from os import path as os_path
-execute pbdir = '..'
-execute if 'PBDIR' in env.keys(): pbdir = env['PBDIR']
-
-execute ipbdir = os_path.join(pbdir, 'ipbori')
-execute if 'IPBDIR' in env.keys(): pbdir = env['IPBDIR']
-
-                              
-# Get program name and prompt something
-execute ipbname = 'ipbori'
-execute if 'IPBNAME' in env.keys(): ipbname = env['IPBNAME']
-execute print ipbname, "-- PolyBoRi's interactive command line tool"
-execute print 'Type "polybori_copyright()" or "polybori_license()"',
-execute print 'for more information.\n'
 
 # Uncomment, if we want to skip the banner 
 # banner 0
@@ -42,26 +28,17 @@
 # Include base config from current IPYTHONDIR and only add some extras
 include ipythonrc
 
-# Append the PolyBoRi application directory to current search path
-execute from sys import path
-
-# The following string may be changed by install. If not installed, use default.
-execute relpyroot = '$RELATIVEPYPREFIX'
-execute if relpyroot[0] == '$': relpyroot = '../pyroot'
-execute pyroot = os_path.join(ipbdir, relpyroot)
-execute path.insert(0, pyroot)
+# execute PolyBoRi settings
+execut from os import environ as env
+execute exec(env["IPBORI_INIT_CMDS"])
+execute print ''
 
 # Get all basic stuff from PyPolyBoRi
 execute from polybori.PyPolyBoRi import *
-execute r = Ring(10000)
-execute x = Variable
 
 # Get all-inclusive groebner routine
 execute from polybori.gbcore import groebner_basis
 
-# Import some high-level modelling functionality
-execute from polybori import *
-
 execute pb_copy =  "Copyright (c) 2007-2010 by The PolyBoRi Team.\n"
 execute pb_copy +=  "  Michael Brickenstein (MFO)  brickenstein@mfo.de\n"
 execute pb_copy +=  "  Alexander Dreyer (ITWM)     "
@@ -90,9 +67,3 @@
 
 execute def polybori_copyright(): print pb_copy 
 execute def polybori_license(): print pb_lic
-
-# Get special stuff for this user interface
-execute from polybori.frontend import *
-
-# Simplify ring declaration
-execute def declare_ring(arg1, arg2 = None): return ternary_declare_ring(arg1, arg2, globals())
--- ./ipbori/ipbori.orig	2011-09-05 17:11:22.000000000 -0600
+++ ./ipbori/ipbori	2011-09-07 15:27:58.534959479 -0600
@@ -65,5 +65,23 @@
 # installing the profile, but custom settings like IPYTHONDIR/ipythonrc are
 # still available. 
 # (For the latter, ipythonrc-polybori needs to import ipythonrc.)
-${IPYTHONPREFIX}ipython -rcfile ${IPBDIR}/ipythonrc-polybori  $@
+#${IPYTHONPREFIX}ipython -rcfile ${IPBDIR}/ipythonrc-polybori  $@
+
+export PBORI_SITE="pyroot/"
+
+# Note: $PBORI_SITE is replaced on installation with relative path
+# to the PolyBoRi python site
+export IPBORI_INIT_CMDS="import sys; sys.path.insert(0, '$PBDIR/$PBORI_SITE');\
+from polybori.frontend import *; polybori_start(globals())"
+
+IPYTHON=${IPYTHONPREFIX}ipython
 
+# RCfiles are supported up to ipython 0.11
+if [[ `$IPYTHON --c="import IPython; \
+    ([eval(elt) for elt in IPython.__version__.split('.')[:2] ]< [0, 11]) "\
+    -quick` =~ "True" ]]
+then
+    ${IPYTHON} -rcfile ${IPBDIR}/ipythonrc-polybori $@
+else
+    ${IPYTHON} --c="print'';$IPBORI_INIT_CMDS" --i
+fi
--- ./pyroot/polybori/frontend.py.orig	2011-09-05 17:11:22.000000000 -0600
+++ ./pyroot/polybori/frontend.py	2011-09-07 15:44:38.499331854 -0600
@@ -1,15 +1,7 @@
+# Import basic functionality
+from polybori import *
 from polybori.blocks import declare_ring as orig_declare_ring
-
-def ternary_declare_ring(blocks, context, global_context):
-    """This is just a wrapper fpr declare_ring, which selects context, if it is
-    not None and global_context otherwise."""
-    if context is None:
-        context = global_context
-        
-    return orig_declare_ring(blocks, context)
-
-
-
+from os import environ as env, path as os_path
 
 def block_scheme_names(blocks):
     """Helper for Singular interface."""
@@ -19,3 +11,21 @@
     declare_block_scheme(blocks, context)
 
     return context.keys()
+
+ipbname = 'ipbori'
+
+def polybori_start(global_context):
+    def declare_ring(blocks, context=None):
+        if context is None:
+            context = global_context
+
+        return orig_declare_ring(blocks, context)
+    declare_ring.__doc__ = orig_declare_ring.__doc__
+    global_context["declare_ring"] = declare_ring
+
+    print ipbname + """ -- PolyBoRi's interactive command line tool
+Type "polybori_copyright()" or "polybori_license()" for more information."""
+
+# Here come the defaults
+r = Ring(10000)
+x = Variable