#13459: spkg/bin/sage: do not change directory
----------------------------------+-----------------------------------------
       Reporter:  jdemeyer        |         Owner:  leif        
           Type:  enhancement     |        Status:  needs_review
       Priority:  major           |     Milestone:  sage-5.4    
      Component:  scripts         |    Resolution:              
       Keywords:                  |   Work issues:              
Report Upstream:  N/A             |     Reviewers:              
        Authors:  Jeroen Demeyer  |     Merged in:              
   Dependencies:                  |      Stopgaps:              
----------------------------------+-----------------------------------------

Comment (by jdemeyer):

 Replying to [comment:7 jhpalmieri]:
 > Can you explain the change in sage-ipython? I don't see any lines
 corresponding to `import sage` in the old version. I guess I don't know
 the mechanics of how sage gets imported when you run `sage` from the
 command line.

 When running Sage through IPython (but not through plain Python when
 running a script for example), the current working directory is always
 added to `sys.path` (the empty string is added as zeroth entry, which
 means the current working directory).  So when doing
 {{{
 import sage    # or sage.foo.bar....
 }}}
 the ''current working directory'' will be checked first for the existence
 of a "sage" module.  If the current working directory happens to be
 `$SAGE_ROOT/devel/sage`, that contains a "sage" subdirectory which Python
 will happily import.  But this is the wrong directory, it should be
 imported from `site-packages` instead.  This creates problems for Cython
 modules, as these exist ''only'' in `site-packages`.

 So we avoid this problem by first fixing `sys.path`, then importing Sage
 so any future imports of Sage submodules will work fine.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13459#comment:8>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to