At the moment I'm looking at rails, it seems like a great framework.
The only downside it has is its rather limited availability of 3rd
party libraries. At the moment there are at least two libraries I need
that are available to python but not to ruby (search engine, either
xapian or lucene( python has bindings to both, ruby has neither), pydns
and another custom python script)
After looking for a solution I came across ruby-python
(http://raa.ruby-lang.org/project/ruby-python/). Sadly enough it is a
little bit outdated. It seems to need ruby 2.6 and python 1.5 while
I'm using ruby 1.82 and python 2.4. I tried looking into the source
code, changing reference to python 1.5 to python 2.4, changed
PyObject_HEAD_INIT(&PyType_Type) to PyObject_HEAD_INIT(NULL) and set
ob_type to &PyType_Type in the init method (the new gcc compiler
doesn't like non constant elements outside function calls) and even got
it to compile. However, this is about as far as my knowledge of C goes,
and i end up with a segmentation fault. Thus somewhere there's a
pointer or reference not pointing to the right spot. I have absolutely
no clue how to solve this.
Are there any other libraries which allow ruby to execute python code,
or has anybody got ruby-python to work with recent versions of both
ruby and python?
If there is no solution i could of course shell execution to run some
python scripts, using that output, but I'd rather not do this as
it'll create quite some messy interaction. Moreover, I think having
ruby able to run use python libraries would definitely help others to
adapt to using ruby, as I'm sure that the lack of libraries is
holding them back to use ruby, just as it does for me. Being able to
use at least a part of the libraries available to python gives ruby a
lot more libraries, with just having one wrapper library.
At the moment I'm looking at rails, it seems like a great framework.
The only downside it has is its rather limited availability of 3rd
party libraries. At the moment there are at least two libraries I need
that are available to python but not to ruby (search engine, either
xapian or lucene( python has bindings to both, ruby has neither), pydns
and another custom python script)
If there is no solution i could of course shell execution to run some
python scripts, using that output, but I'd rather not do this as
it'll create quite some messy interaction. Moreover, I think having
ruby able to run use python libraries would definitely help others to
adapt to using ruby, as I'm sure that the lack of libraries is
holding them back to use ruby, just as it does for me. Being able to
use at least a part of the libraries available to python gives ruby a
lot more libraries, with just having one wrapper library.
Instead of trying to generate something generic you maybe should
simply write a C extension that includes python.h and ruby.h and wrap
the API calls. If it is not very performance critical (i really think
it is not) you can simply generate the connectivity by passing string
arguments from one side to the other, together with a little parameter
encoding/decoding.
And yes, this requires C and gives you a good way to learn more about
it. Having knowlegde of C is IMHO an absolute "must have" for every
programmer.
···
--
Best regards, emailto: scholz at scriptolutions dot com
Lothar Scholz http://www.ruby-ide.com
CTO Scriptolutions Ruby, PHP, Python IDE 's
At the moment there are at least two libraries I need
that are available to python but not to ruby (search engine, either
xapian or lucene( python has bindings to both, ruby has neither), pydns
and another custom python script)
While someone mentioned Odeum, nobody replied to your second. Ruby stdlib:
require 'resolv'
I'll take a look at odeum. Though that'll only solve a part of the
things i've been trying (though i have to admit, it'd be the most
complicated one). But still i'd really like to have the ability to use
python code inside ruby, just for the simple reason to extend the
availabilty of 3rd party libraries to ruby.
I kind of got the ruby-python module to work! Sadly enough, I'm still
only vaguely aware of how it works. And I haven't thoroughly tested
things.
But for now, it appears to be quite usable for my situation. I can
execute my custom python modules from within Ruby, what more could I
wish to achieve
I already send my changes to the original author. It weren't really ig
changes. Only changing references to python1.5 to python2.4. Initialize
two PyObjects in the init method instead of doing that in their
definition, and finally i removed a check for duplicate modules, as it
marked all objects as duplicates. Especial the removal of this check
is, ofcourse, a bad thing.
To get it to compile in windows i also had to change to sequence in
which the headers were included. But under windows it nly works
Partially. I can exeucte python statements with the methods created for
the Py object (Py.eval for example), trying to work on a real Python
module (Py::Sys for example) crashes the whole thing.
As i said, i'm not really a programmer, and to have a full understandig
of the code one would need to understand both the ruby and python way
of interacting with C. As i know neither, i'm not the person to update
the module.
I already send my changes to the original author. It weren't really big
changes. Only changing references to python1.5 to python2.4. Initialize
two PyObjects in the init method instead of doing that in their
definition, and finally I removed a check for duplicate modules, as it
marked all objects as duplicates. Especial the removal of this check
is, of course, a bad thing.
To get it to compile in windows I also had to change to sequence in
which the headers were included. But under windows it only works
partially. I can execute python statements with the methods created for
the Py object (Py.eval for example), trying to work on a real Python
module (Py::Sys for example) crashes the whole thing.
As I said, I'm not really a programmer, and to have a full
understanding
of the code one would need to understand both the ruby and python way
of interacting with C. As I know neither, I'm not the person to
update
the module.
Thanks! That might come in handy sometime. Though i mostly need my
stuff to run on linux. That it works on windows is a nice pluss, as i
develop on it
But... I got ruby-python to run on win32. I messed up my entire windows
setup by installing all kinds compilers and ruby / python ports, but in
the end i got it working
I still have not recieved a response from the original author, so im
not sure what to do with my modifications. I might publish them
somewhere, though as i'm not able to maintain it that might not be too
usefull (in the past few day's i've really gone crazy reading
documentation that was just plain wrong. I don't want to add to that
mess). On the other hand, there might be more people like me that want
to use ruby, but the relatively little amount of avialable libraries
holds them back. Especial for those wanting to use Rails. (For plain
scripts one would ofcourse use "the right tool for the job", which
would be the language the libraries are written in). In that case this
extention might be a good solution for them too.
Thanks! That might come in handy sometime. Though i mostly need my
stuff to run on linux. That it works on windows is a nice pluss, as i
develop on it
But... I got ruby-python to run on win32. I messed up my entire windows
setup by installing all kinds compilers and ruby / python ports, but in
the end i got it working
I still have not recieved a response from the original author, so im
not sure what to do with my modifications. I might publish them
somewhere, though as i'm not able to maintain it that might not be too
usefull (in the past few day's i've really gone crazy reading
documentation that was just plain wrong. I don't want to add to that
mess). On the other hand, there might be more people like me that want
to use ruby, but the relatively little amount of avialable libraries
holds them back. Especial for those wanting to use Rails. (For plain
scripts one would ofcourse use "the right tool for the job", which
would be the language the libraries are written in). In that case this
extention might be a good solution for them too.