On Tuesday, February 26, 2013 5:27:46 PM UTC-8, Nils Bruin wrote: > > On Feb 26, 4:15 pm, JMH <jacek.m.holec...@gmail.com> wrote: > > Hi, > > in general, the package that I want to use comes with a shell script > which > > modifies environment variables that are needed. So I need a mechanism to > > "source" that shell script (and that script needs to modify at least > > "PATH", "LD_LIBRARY_PATH" and "PYTHONPATH" plus it sets some > > package-specific environment variables). > > You can still do that from python via something like > > from subprocess import PIPE, Popen > P = Popen("sh",stdin=PIPE,stdout=PIPE) > P.stdin.write(". <your configuration script>\n") > P.stdin.write("echo $PATH\n") > newval = P.stdout.readline() > os.environ["PATH"] = newval > P.stdin.write("exit\n") > > You could do this in your .sagerc, right before you do "import module- > version-XY" > > It's a bit hacky, but what you're trying to do is a bit hacky too, so > the means seem appropriate. I don't think the sage configuration > system by default should go out of its way to support hacky things > that can be accomplished anyway. You're of course free to patch it as > you please. > > The non-hacky way would consist of amending the package itself to > support multiple versions. >
> A further alternative would be to use a wrapper script to start sage: > > #!.../sage -sh > . <your configuration script> > exec sage > > You can put an initialization script like this in ~/.sage/sagerc. This file gets sourced at the end of sage-env. -- John -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel?hl=en. For more options, visit https://groups.google.com/groups/opt_out.