#11680: support extra_compile_args (e.g., C99) when loading/attaching .pyx 
(cython)
files, and when using %cython in the notebook
---------------------------------------------+------------------------------
   Reporter:  was                            |          Owner:  jason          
       Type:  enhancement                    |         Status:  positive_review
   Priority:  minor                          |      Milestone:  sage-4.7.2     
  Component:  misc                           |       Keywords:  sd32           
Work_issues:                                 |       Upstream:  N/A            
   Reviewer:  William Stein, Leif Leonhardy  |         Author:  Martin Albrecht
     Merged:                                 |   Dependencies:                 
---------------------------------------------+------------------------------
Description changed by leif:

Old description:

> Right now, the following file foo.pyx cannot be just loaded into Sage:
> {{{
>
> from sage.rings.rational cimport Rational
> from sage.rings.polynomial.polynomial_rational_flint cimport
> Polynomial_rational_flint
> from sage.libs.flint.fmpq_poly cimport (fmpq_poly_get_coeff_mpq,
> fmpq_poly_set_coeff_mpq,
>                                         fmpq_poly_length)
>
> def evaluate_at_power_of_gen(Polynomial_rational_flint f, unsigned long
> n):
>     assert n >= 1
>     cdef Polynomial_rational_flint res = f._new()
>     cdef unsigned long k
>     cdef Rational z = Rational(0)
>     for k in range(fmpq_poly_length(f.__poly)):
>         fmpq_poly_get_coeff_mpq(z.value, f.__poly, k)
>         fmpq_poly_set_coeff_mpq(res.__poly, n*k, z.value)
>     return res
> }}}
>
> The main reason is that there is no way to tell Sage (i.e., the file
> cython.py) that the code needs to have the extra compile flag:
> {{{
>               extra_compile_args = ['-std=c99'],
> }}}
>
> Currently devel/sage/sage/misc/cython.py defines "clang", "clib", and
> "cinclude".  But none of these let us add an extra_compile_arg or use
> c99.

New description:

 Right now, the following file `foo.pyx` cannot be just loaded into Sage:
 {{{
 from sage.rings.rational cimport Rational
 from sage.rings.polynomial.polynomial_rational_flint cimport
 Polynomial_rational_flint
 from sage.libs.flint.fmpq_poly cimport (fmpq_poly_get_coeff_mpq,
 fmpq_poly_set_coeff_mpq,
                                         fmpq_poly_length)

 def evaluate_at_power_of_gen(Polynomial_rational_flint f, unsigned long
 n):
     assert n >= 1
     cdef Polynomial_rational_flint res = f._new()
     cdef unsigned long k
     cdef Rational z = Rational(0)
     for k in range(fmpq_poly_length(f.__poly)):
         fmpq_poly_get_coeff_mpq(z.value, f.__poly, k)
         fmpq_poly_set_coeff_mpq(res.__poly, n*k, z.value)
     return res
 }}}

 The main reason is that there is no way to tell Sage (i.e., the file
 `cython.py`) that the code needs to have the extra compile flag:
 {{{
               extra_compile_args = ['-std=c99'],
 }}}

 Currently `devel/sage/sage/misc/cython.py` supports "clang", "clib", and
 "cinclude" pragmas.  But none of these let us add an `extra_compile_arg`
 or use C99.

 ----

 Apply [attachment:trac_11680.patch] to the Sage library.

--

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