#12868: Attaching a pyx file in the presence of __init__.py results in wrong 
module
names
-----------------------------+----------------------------------------------
       Reporter:  SimonKing  |         Owner:  jason   
           Type:  defect     |        Status:  new     
       Priority:  major      |     Milestone:  sage-5.1
      Component:  misc       |    Resolution:          
       Keywords:             |   Work issues:          
Report Upstream:  N/A        |     Reviewers:          
        Authors:             |     Merged in:          
   Dependencies:             |      Stopgaps:          
-----------------------------+----------------------------------------------

Comment (by SimonKing):

 Replying to [comment:9 leif]:
 > > That wouldn't be a solution. Perhaps the user ''wants'' (for some
 reason) to have it in the folder (in particular, it is no user error).
 >
 > In the temporary build folder?  Not sure whether there are situations
 where this is needed.

 No, in the original folder.

 > This one works for me:
 > {{{
 > #!patch
 > diff --git a/sage/misc/cython.py b/sage/misc/cython.py
 > --- a/sage/misc/cython.py
 > +++ b/sage/misc/cython.py
 > @@ -382,6 +382,10 @@
 >          os.system(cmd)
 >          if os.path.exists("%s/setup.py" % build_dir):
 >              os.unlink("%s/setup.py" % build_dir)
 > +        if os.path.exists("%s/__init__.py" % build_dir):
 > +            sys.stderr.write("Note: Ignoring %s/__init__.py ...\n" %
 abs_base)
 > +            sys.stderr.flush()
 > +            os.unlink("%s/__init__.py" % build_dir)
 >
 >      if compile_message:
 >          print "Compiling %s..."%filename
 > }}}
 > ...
 > That's correct.  But in addition, symbolic links to any(!) file in the
 directory containing the attached file are created in the temporary
 directory (since e.g. you otherwise wouldn't be able to import or include
 other files in that directory from the attached file).  Above, I've only
 changed that part.

 I see! So, you are not unlinking it from the original directory.

 > That's what I was saying.  (Unless you try to `import __init__` in the
 attached file...)

 Hm. Difficult to tell. If you have files `foo.pyx` and `bar.py` in your
 folder, and in `foo.pyx` you want to do `from bar import Bar`, then I
 guess you need to have `__init__.py` in ''the folder in which the
 compilation happens'', isn't it? So, there are situations in which the
 presence of `__init__.py` in the temporary folder (via a symbolic link)
 makes sense.

 The best solution would be to patch Cython, so that the wrong naming of
 modules does not occur (in some post above, I think it was shown that the
 naming is chosen by Cython, not by distutils).

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12868#comment:10>
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