#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 leif):

 Replying to [comment:4 leif]:
 > So I'm pretty sure -- if at all -- ''distutils'' are to blame for the
 unexpected behaviour, although it seems quite reasonable to me.


 Nope, actually ''Cython'' is causing this, since the following does
 '''not''' solve your problem (if it really is one):
 {{{
 #!diff
 diff --git a/sage/misc/cython.py b/sage/misc/cython.py
 --- a/sage/misc/cython.py
 +++ b/sage/misc/cython.py
 @@ -432,6 +432,11 @@
      SAGE_ROOT  = os.environ['SAGE_ROOT']
      SAGE_LOCAL = SAGE_ROOT + '/local/'

 +# Remove unwanted link to an __init__.py file from the current directory,
 +# i.e., from the temporary build directory only (#12868):
 +if os.path.exists("__init__.py"):
 +    os.unlink("__init__.py")
 +
  extra_link_args =  ['-L' + SAGE_LOCAL + '/lib']
  extra_compile_args = %s

 }}}

 You can verify that Cython changes the module name depending on whether an
 `__init__.py` file is present by

 {{{
 #!sh
 $ sage --sh -c 'cython test.pyx' && grep '^#.*__Pyx_MODULE_NAME' test.c`
 }}}

 Although it is not yet clear to me how Cython finds the `__init__.py` if I
 remove it from the temporary build directory, as there's only the symbolic
 link to the "unrelated" original `.pyx` source file, but probably Cython
 somehow "knows" about the relation.

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