On 06/10/2010, at 5:12 PM, Aleksey Gurtovoy wrote:
>>
>> On a completely unrelated note .. did you know Felix can generate
>> Python modules natively?
>>
>> You can actually make a shared library which you can *run* under
>> Felix but which can also be *import*ed by Python (version 2.x I think).
>
> That's cool; I might actually have a pet project I can try it on. Where do
> I learn more? :)
>From the .. nonexistant .. documentation :)
>From the source code.. :)
Or just by asking here as you did...
It's pretty simple really:
header "#include <Python.h>";
type PyO = "PyObject*";
cfun f(m:PyO,x:PyO)=>x;
export python fun f of (PyO*PyO) as "PyIdent";
This stuff up on the Mac: I have to rename pyx.dylib to pyx.so
and then it fails with
>>> import pyx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(./pyx.so, 2): no suitable image found. Did find:
./pyx.so: mach-o, but wrong architecture
which has something to do with Leopard Python 2.5 on Snow Leopard
I think (snl compiler is 64 bit but python 2.5 is probably 32 bit: as
usual the loader method is crap, it should say what arch is required
(wtf is "mach-o"? Is that 32 bit? Why does Apple have 20K names
for their system? Is at Apple, a Mac, OSX, Darwin, BSD, Mach or
what is it? :)
I used the command line:
$ flx
-I/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/
-L/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/config/
-lpython2.5 pyx
for the compilation of the file above (pyx.flx). At present, it seems the
module initialisation code is
for Python 2.x .. I tried with 3.x but it doesn't work
$ flx -I/Library/Frameworks/Python.framework/Versions/3.1/include/python3.1/ pyx
pyx.cpp: In function ‘PyObject* initpyx()’:
pyx.cpp:52: error: ‘Py_InitModule’ was not declared in this scope
I haven't checked out the differences for CPython 2.x to 3.x ...
--
john skaller
[email protected]
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language