Re: Easiest way to access C module in Python

2017-11-07 Thread Gisle Vanem
bartc wrote:  From inside python 2.7:    Python 2.7.13rc1 (v2.7.13rc1:4d6fd49eeb14, Dec  3 2016, 21:49:42) [MSC v.1500 32 bit (Intel)] on win32    Type "help", "copyright", "credits" or "license" for more information.    >>> import life    >>> dir(life)    ['__builtins__', '__doc__', '__file__'

Re: Easiest way to access C module in Python

2017-11-07 Thread bartc
On 07/11/2017 20:08, Gisle Vanem wrote: Lele Gaifax wrote: On my PC, I get the following, using the "-v" option to verbosely see the imported modules: $ $ python -v # installing zipimport hook import zipimport # builtin # installed zipimport hook ... import life dlopen("./life.so", 2); impor

Re: Easiest way to access C module in Python

2017-11-07 Thread Gisle Vanem
Lele Gaifax wrote: On my PC, I get the following, using the "-v" option to verbosely see the imported modules: $ $ python -v # installing zipimport hook import zipimport # builtin # installed zipimport hook ... import life dlopen("./life.so", 2); import life # dynamically loaded from life.so

Re: Easiest way to access C module in Python

2017-11-07 Thread Lele Gaifax
Gisle Vanem writes: > python.exe -c "import life; print(life.life())" > Traceback (most recent call last): > File "", line 1, in > AttributeError: 'module' object has no attribute 'life' > > Can you give a hint? I tried with Python 2, and the same recipe works for me, on GNU/Linux: $ python

Re: Easiest way to access C module in Python

2017-11-07 Thread Gisle Vanem
Lele Gaifax wrote: $ python setup.py build_ext --inplace Compiling life.pyx because it changed. [1/1] Cythonizing life.pyx running build_ext building 'life' extension creating build creating build/temp.linux-x86_64-3.6 x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototyp

Re: Easiest way to access C module in Python

2017-11-07 Thread Rob Gaddi
On 11/06/2017 05:59 PM, Grant Edwards wrote: On 2017-11-06, John Pote wrote: I have successfully used Python to perform unit and integration tests in the past and I'd like to do the same for some C modules I'm working with at work. There seem to be a number of ways of doing this but being busy

Re: Easiest way to access C module in Python

2017-11-07 Thread bartc
On 07/11/2017 14:33, Tim Golden wrote: On 07/11/2017 14:20, bartc wrote: You've lost me. I had to look up pyPI and it's something to do with a Package Index. But I don't know how that relates to installing Cython. Can I just step in now with my Moderator hat on and ask: please avoid a lengt

Re: Easiest way to access C module in Python

2017-11-07 Thread Tim Golden
On 07/11/2017 14:20, bartc wrote: On 07/11/2017 13:30, Thomas Jollans wrote: On 2017-11-07 12:53, bartc wrote: Having said that, I located pip.exe, trying typing 'pip install cffi' and it seemed to be doing something but then failed with a bunch of errors.) So you're missing out on all of PyP

Re: Easiest way to access C module in Python

2017-11-07 Thread bartc
On 07/11/2017 13:30, Thomas Jollans wrote: On 2017-11-07 12:53, bartc wrote: Having said that, I located pip.exe, trying typing 'pip install cffi' and it seemed to be doing something but then failed with a bunch of errors.) So you're missing out on all of PyPI? That's tragic. You should really

Re: Easiest way to access C module in Python

2017-11-07 Thread Thomas Jollans
On 2017-11-07 12:53, bartc wrote: > Having > said that, I located pip.exe, trying typing 'pip install cffi' and it > seemed to be doing something but then failed with a bunch of errors.) So you're missing out on all of PyPI? That's tragic. You should really try to fix that. I'm sure people on this

Re: Easiest way to access C module in Python

2017-11-07 Thread Lele Gaifax
bartc writes: > OK, compiling fred.c. Is there a dependency on gcc too? This looks more like > makefile hell. That's pretty standard distutils functionality. I'm pretty sure that on M$Windows it would invoke its C compiler, not gcc. I wrote "fred.c" to get closer to the case you mentioned, but

Re: Easiest way to access C module in Python

2017-11-07 Thread bartc
On 07/11/2017 13:11, bartc wrote: $ python setup.py build_ext --inplace OK, thanks. Although when I get to this bit, my system still says: 17.297 Traceback (most recent call last):   File "setup.py", line 1, in     from distutils.core import setup   Update: if I copy the

Re: Easiest way to access C module in Python

2017-11-07 Thread bartc
On 07/11/2017 12:14, Lele Gaifax wrote: bartc writes: But just staying with the "function with no arguments" for the minute (the equivalent of Hello World for this exercise), how would it be done in Cython? Would a working example be simple enough to show in a usenet post? fred.c:: int

Re: Easiest way to access C module in Python

2017-11-07 Thread Lele Gaifax
bartc writes: > But just staying with the "function with no arguments" for the minute (the > equivalent of Hello World for this exercise), how would it be done in > Cython? Would a working example be simple enough to show in a usenet post? fred.c:: int fred(void) { return 42; } life

Re: Easiest way to access C module in Python

2017-11-07 Thread bartc
On 07/11/2017 11:35, Paul Moore wrote: On 7 November 2017 at 11:16, Chris Angelico wrote: Thanks for the FUD. I love it when someone, on the basis of one failed experiment, trash-talks an excellent piece of software that would solve the OP's problem. It *is* true that the learning curve for C

Re: Easiest way to access C module in Python

2017-11-07 Thread Paul Moore
On 7 November 2017 at 11:16, Chris Angelico wrote: > Thanks for the FUD. I love it when someone, on the basis of one failed > experiment, trash-talks an excellent piece of software that would > solve the OP's problem. It *is* true that the learning curve for Cython is steeper than that of ctypes.

Re: Easiest way to access C module in Python

2017-11-07 Thread bartc
On 07/11/2017 11:16, Chris Angelico wrote: On Tue, Nov 7, 2017 at 10:06 PM, bartc wrote: My experience is different. Thanks for the FUD. I love it when someone, on the basis of one failed experiment, trash-talks an excellent piece of software that would solve the OP's problem. OK, I gave

Re: Easiest way to access C module in Python

2017-11-07 Thread Chris Angelico
On Tue, Nov 7, 2017 at 10:06 PM, bartc wrote: > On 07/11/2017 02:23, Chris Angelico wrote: >> >> On Tue, Nov 7, 2017 at 12:52 PM, bartc wrote: > > >>> Cython seems very confusing to me. >> >> > >> >>> Otherwise what /I/ would look for is ways to call C functions inside >>> shared >>> libraries (.

Re: Easiest way to access C module in Python

2017-11-07 Thread bartc
On 07/11/2017 02:23, Chris Angelico wrote: On Tue, Nov 7, 2017 at 12:52 PM, bartc wrote: Cython seems very confusing to me. Otherwise what /I/ would look for is ways to call C functions inside shared libraries (.dll and .so). That requires that the modules under test be wrapped as a sh

Re: Easiest way to access C module in Python

2017-11-06 Thread Christian Gollwitzer
Am 07.11.17 um 02:59 schrieb Grant Edwards: On 2017-11-06, John Pote wrote: I have successfully used Python to perform unit and integration tests in the past and I'd like to do the same for some C modules I'm working with at work. There seem to be a number of ways of doing this but being busy

Re: Easiest way to access C module in Python

2017-11-06 Thread Chris Angelico
On Tue, Nov 7, 2017 at 12:52 PM, bartc wrote: > On 07/11/2017 00:58, Chris Angelico wrote: >> >> On Tue, Nov 7, 2017 at 10:43 AM, John Pote >> wrote: >>> >>> Hi all, >>> I have successfully used Python to perform unit and integration tests in >>> the >>> past and I'd like to do the same for some

Re: Easiest way to access C module in Python

2017-11-06 Thread Grant Edwards
On 2017-11-06, John Pote wrote: > I have successfully used Python to perform unit and integration tests in > the past and I'd like to do the same for some C modules I'm working with > at work. There seem to be a number of ways of doing this but being busy > at work and home I looking for the a

Re: Easiest way to access C module in Python

2017-11-06 Thread bartc
On 07/11/2017 00:58, Chris Angelico wrote: On Tue, Nov 7, 2017 at 10:43 AM, John Pote wrote: Hi all, I have successfully used Python to perform unit and integration tests in the past and I'd like to do the same for some C modules I'm working with at work. There seem to be a number of ways of do

Re: Easiest way to access C module in Python

2017-11-06 Thread Bill
John Pote wrote: Hi all, I have successfully used Python to perform unit and integration tests in the past and I'd like to do the same for some C modules I'm working with at work. There seem to be a number of ways of doing this but being busy at work and home I looking for the approach with th

Re: Easiest way to access C module in Python

2017-11-06 Thread Chris Angelico
On Tue, Nov 7, 2017 at 10:43 AM, John Pote wrote: > Hi all, > I have successfully used Python to perform unit and integration tests in the > past and I'd like to do the same for some C modules I'm working with at > work. There seem to be a number of ways of doing this but being busy at work > and

Easiest way to access C module in Python

2017-11-06 Thread John Pote
Hi all, I have successfully used Python to perform unit and integration tests in the past and I'd like to do the same for some C modules I'm working with at work. There seem to be a number of ways of doing this but being busy at work and home I looking for the approach with the least learning c