Re: [sage-devel] Re: adding cython/C code in top level of sagelib

2018-07-07 Thread Vincent Delecroix

On 06/07/2018 19:42, Dima Pasechnik wrote:



On Friday, July 6, 2018 at 4:15:55 PM UTC+2, Jeroen Demeyer wrote:


On 2018-07-06 16:08, John H Palmieri wrote:

It’s already documented in the developer’s guide:

http://doc.sagemath.org/html/en/developer/coding_in_cython.html?highlight=module_list


John



But don't use "libraries=", it's better to use "# distutils" directives
at the top of your Cython file.



Really? Any reason for this? It's really much cleaner, IMHO, to have it all
in Python code, easily inspect-able, rather than
in an obscure comments with obscure syntax somewhere you have no means to
inspect from Python...


Nope. Distutils directive as suggested by Jeroen are naturally put
in pxd files. That way, as soon as the pxd gets imported in a pyx the
correct libraries are linked automaticaly. See for example

 sage/libs/gmp/mpz.pxd

If you do cimport the definitions from there, gmp will automatically
be linked. Note also that there is no distutils directive in

 sage/libs/gmp/types.pxd

wich make sense since all the declarations there only depend on the
header files!

I think that this could be added to the developer guide
(since this is not a Cython standard).

However, if the presence of "libraries=" is required in a pyx file, then
I am not sure what I prefer. Any comment?

Best
Vincent

--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] Re: adding cython/C code in top level of sagelib

2018-07-06 Thread Dima Pasechnik


On Friday, July 6, 2018 at 4:15:55 PM UTC+2, Jeroen Demeyer wrote:
>
> On 2018-07-06 16:08, John H Palmieri wrote: 
> > It’s already documented in the developer’s guide: 
> http://doc.sagemath.org/html/en/developer/coding_in_cython.html?highlight=module_list
>  
> > 
> >John 
> > 
>
> But don't use "libraries=", it's better to use "# distutils" directives 
> at the top of your Cython file. 
>

Really? Any reason for this? It's really much cleaner, IMHO, to have it all 
in Python code, easily inspect-able, rather than
in an obscure comments with obscure syntax somewhere you have no means to 
inspect from Python...


  

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: adding cython/C code in top level of sagelib

2018-07-06 Thread Dima Pasechnik


On Friday, July 6, 2018 at 4:08:46 PM UTC+2, John H Palmieri wrote:
>
> It’s already documented in the developer’s guide: 
> http://doc.sagemath.org/html/en/developer/coding_in_cython.html?highlight=module_list
>  
>
>
the bottom line is that it's possible to miss this, especially as
the section heading  
http://doc.sagemath.org/html/en/developer/coding_in_cython.html?highlight=module_list#writing-cython-code-in-sage

rather than something like "Extending Sage's Sagelib". And the latter 
should also say something about pure Python code, not just Cython.

 

>   John 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] Re: adding cython/C code in top level of sagelib

2018-07-06 Thread Jeroen Demeyer

On 2018-07-06 16:08, John H Palmieri wrote:

It’s already documented in the developer’s guide: 
http://doc.sagemath.org/html/en/developer/coding_in_cython.html?highlight=module_list

   John



But don't use "libraries=", it's better to use "# distutils" directives 
at the top of your Cython file.


--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: adding cython/C code in top level of sagelib

2018-07-06 Thread John H Palmieri
It’s already documented in the developer’s guide: 
http://doc.sagemath.org/html/en/developer/coding_in_cython.html?highlight=module_list

  John

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: adding cython/C code in top level of sagelib

2018-07-04 Thread Dima Pasechnik
Thanks. I will open a ticket to document these things.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: adding cython/C code in top level of sagelib

2018-07-04 Thread Volker Braun
See src/module_list.py:

OptionalExtension('sage.libs.homfly',
  sources = ["sage/libs/homfly.pyx"],
  libraries = ["homfly", "gc"],
  package="libhomfly"),


On Wednesday, July 4, 2018 at 2:00:09 PM UTC+2, Dima Pasechnik wrote:
>
> Or, perhaps, someone can walk me through adding a Cython file in 
> src/sage/libs/
>
> E.g. src/sage/libs/homfly.pyx
>
> How does the build process know it has to be cythonised, compiled, and 
> linked ino Sagelib?
> It's complete mystery...
>
> On Wednesday, July 4, 2018 at 1:37:57 PM UTC+2, Dima Pasechnik wrote:
>>
>> Could anyone enlighten us on how to extend sagelib with cython and C code.
>>
>> Namely, suppose I have
>>
>> src/sage/foo/foo.pyx
>> src/sage/foo/bar/foo1.c
>>
>> with foo1.c called from foo.pyx
>>
>> How does one make Sage import things into sagelib, and make the build 
>> process
>> cythonise and compile C code?
>>
>> OK, in src/sage/all.py
>>
>> there should be 
>>
>> from sage.foo.all import *
>>
>>
>> But this is not enough; with this no cythonising happens if I run 
>>
>> make sagelib
>>
>>
>>
>> (Ideally this should be in the manual...)
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: adding cython/C code in top level of sagelib

2018-07-04 Thread Dima Pasechnik
Or, perhaps, someone can walk me through adding a Cython file in 
src/sage/libs/

E.g. src/sage/libs/homfly.pyx

How does the build process know it has to be cythonised, compiled, and 
linked ino Sagelib?
It's complete mystery...

On Wednesday, July 4, 2018 at 1:37:57 PM UTC+2, Dima Pasechnik wrote:
>
> Could anyone enlighten us on how to extend sagelib with cython and C code.
>
> Namely, suppose I have
>
> src/sage/foo/foo.pyx
> src/sage/foo/bar/foo1.c
>
> with foo1.c called from foo.pyx
>
> How does one make Sage import things into sagelib, and make the build 
> process
> cythonise and compile C code?
>
> OK, in src/sage/all.py
>
> there should be 
>
> from sage.foo.all import *
>
>
> But this is not enough; with this no cythonising happens if I run 
>
> make sagelib
>
>
>
> (Ideally this should be in the manual...)
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.