#17044: fix pexpect interfaces with a system-wide sage install
-------------------------+-------------------------------------------------
Reporter: was | Owner:
Type: | Status: needs_review
defect | Milestone: sage-6.4
Priority: major | Resolution:
Component: | Merged in:
interfaces | Reviewers:
Keywords: | Work issues:
Authors: | Commit:
Frédéric Chapoton | 33e6ec3d8d907d3cc04cd90a60db29d414c64a6b
Report Upstream: N/A | Stopgaps:
Branch: |
u/chapoton/17044 |
Dependencies: |
-------------------------+-------------------------------------------------
Description changed by jdemeyer:
Old description:
> If you install Sage system-wide (e.g., in /usr/local) for all users on
> your system, most of the pexpect interfaces will be completely massively
> broken. The bug is big, but the fix is pretty trivial:
>
> {{{
> diff --git a/src/sage/interfaces/expect.py
> b/src/sage/interfaces/expect.py
> index 4e47d54..ef8a4e1 100644
> --- a/src/sage/interfaces/expect.py
> +++ b/src/sage/interfaces/expect.py
> @@ -127,7 +127,7 @@ class Expect(Interface):
> """
> def __init__(self, name, prompt, command=None, server=None,
> server_tmpdir=None,
> ulimit = None, maxread=100000,
> - script_subdirectory="", restart_on_ctrlc=False,
> + script_subdirectory=None, restart_on_ctrlc=False,
> verbose_start=False, init_code=[],
> max_startup_time=None,
> logfile = None, eval_using_file_cutoff=0,
> do_cleaner=True, remote_cleaner=False, path=None,
> }}}
>
> The problem is that elsewhere in the code there is an
> {{{
> if script_subdirectory is None
> }}}
> rather than a
> {{{
> if script_subdirectory
> }}}
New description:
If you install Sage system-wide (e.g., in /usr/local) for all users on
your system, most of the pexpect interfaces for optional packages will be
completely massively broken. For example, on a system which doesn't have
scilab installed:
{{{
sage: scilab('2+3')
---------------------------------------------------------------------------
OSError Traceback (most recent call
last)
<ipython-input-1-c7d52e4ba13e> in <module>()
----> 1 scilab('2+3')
/usr/local/src/sage-git/local/lib/python2.7/site-
packages/sage/interfaces/interface.pyc in __call__(self, x, name)
197
198 if isinstance(x, basestring):
--> 199 return cls(self, x, name=name)
200 try:
201 return self._coerce_from_special_method(x)
/usr/local/src/sage-git/local/lib/python2.7/site-
packages/sage/interfaces/expect.pyc in __init__(self, parent, value,
is_name, name)
1310 else:
1311 try:
-> 1312 self._name = parent._create(value, name=name)
1313 # Convert ValueError and RuntimeError to TypeError for
1314 # coercion to work properly.
/usr/local/src/sage-git/local/lib/python2.7/site-
packages/sage/interfaces/interface.pyc in _create(self, value, name)
387 def _create(self, value, name=None):
388 name = self._next_var_name() if name is None else name
--> 389 self.set(name, value)
390 return name
391
/usr/local/src/sage-git/local/lib/python2.7/site-
packages/sage/interfaces/scilab.pyc in set(self, var, value)
307 """
308 cmd = '%s=%s;'%(var,value)
--> 309 out = self.eval(cmd)
310 if out.find("error") != -1:
311 raise TypeError("Error executing code in
Scilab\nCODE:\n\t%s\nScilab ERROR:\n\t%s"%(cmd, out))
/usr/local/src/sage-git/local/lib/python2.7/site-
packages/sage/interfaces/scilab.pyc in eval(self, command, *args, **kwds)
274 'd =\n \n 44.'
275 """
--> 276 s = Expect.eval(self, command,
**kwds).replace("\x1b[?1l\x1b>","").strip()
277 return s
278
/usr/local/src/sage-git/local/lib/python2.7/site-
packages/sage/interfaces/expect.pyc in eval(self, code, strip,
synchronize, locals, allow_use_file, split_lines, **kwds)
1227 elif split_lines:
1228 return '\n'.join([self._eval_line(L,
allow_use_file=allow_use_file, **kwds)
-> 1229 for L in code.split('\n')
if L != ''])
1230 else:
1231 return self._eval_line(code,
allow_use_file=allow_use_file, **kwds)
/usr/local/src/sage-git/local/lib/python2.7/site-
packages/sage/interfaces/expect.pyc in _eval_line(self, line,
allow_use_file, wait_for_prompt, restart_if_needed)
821 try:
822 if self._expect is None:
--> 823 self._start()
824 E = self._expect
825 try:
/usr/local/src/sage-git/local/lib/python2.7/site-
packages/sage/interfaces/scilab.pyc in _start(self)
261 sage: scilab._start() # optional
- scilab
262 """
--> 263 Expect._start(self)
264 self.eval("mode(0)")
265
/usr/local/src/sage-git/local/lib/python2.7/site-
packages/sage/interfaces/expect.pyc in _start(self, alt_message,
block_during_init)
389 current_path = os.path.abspath('.')
390 dir = self.__path
--> 391 sage_makedirs(dir)
392 os.chdir(dir)
393
/usr/local/src/sage-git/local/lib/python2.7/site-
packages/sage/misc/misc.pyc in sage_makedirs(dir)
79 """
80 try:
---> 81 os.makedirs(dir)
82 except OSError:
83 if not os.path.isdir(dir):
/usr/local/src/sage-git/local/lib/python/os.pyc in makedirs(name, mode)
148 if head and tail and not path.exists(head):
149 try:
--> 150 makedirs(head, mode)
151 except OSError, e:
152 # be happy if someone already created the path
/usr/local/src/sage-git/local/lib/python/os.pyc in makedirs(name, mode)
155 if tail == curdir: # xxx/newdir/. exists if
xxx/newdir exists
156 return
--> 157 mkdir(name, mode)
158
159 def removedirs(name):
OSError: [Errno 13] Permission denied: '/usr/local/src/sage-
git/local/share/sage/ext/scilab'
}}}
--
--
Ticket URL: <http://trac.sagemath.org/ticket/17044#comment:6>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.