ctypes in Jython

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

ctypes in Jython

Marius-11
Hi!

I checked out the website:
"We do plan to support bz2, ctypes, sqlite3, flesh out unicodedata,
and support cjk codecs in 2.5.1." <-
(http://www.jython.org/faq3.html)

->Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)
[OpenJDK Server VM (Sun Microsystems Inc.)] on java1.6.0_18
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named ctypes
>>>

Is there support for ctypes with Jython? Or can I get ctypes working
with Jython somehow?

Thanks :),
Marius

------------------------------------------------------------------------------
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/msIE9-sfdev2dev
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users
Reply | Threaded
Open this post in threaded view
|

Re: ctypes in Jython

Jim Baker
Sorry for being too optimistic. We ended up not supporting any of those modules in 2.5.1, because we wanted to get some critical bug fixes out first. 2.5.2 is more bug fixes, plus Java integration. There's some experimental support for ctypes in 2.5.2, but it's really more of a placeholder at this point. And none of the other modules mentioned (bz2, CJK codecs, sqlite3, or completion of unicodedata) have been completed either. They might be released on PyPI first as a separate download, or in 2.6. Nothing really too difficult to do, but we don't have the resources since we are an all-volunteer project. Contributions welcome!

We do need to update the FAQ of course.

I do recommend JNA if you can modify your ctypes code. JNA is pretty close to ctypes - JNA's API apparently was significantly influenced by ctypes! JNA also seems to work well with Jython.

The other option is to use something like execnet. For execnet specifically: it allows you to pair Jython with CPython, and it does seem to work well. But its GPL license makes it a non starter for many people. There are other choices out there too.

- Jim

On Wed, Nov 17, 2010 at 5:24 AM, Marius <[hidden email]> wrote:
Hi!

I checked out the website:
"We do plan to support bz2, ctypes, sqlite3, flesh out unicodedata,
and support cjk codecs in 2.5.1." <-
(http://www.jython.org/faq3.html)

->Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)
[OpenJDK Server VM (Sun Microsystems Inc.)] on java1.6.0_18
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
ImportError: No module named ctypes
>>>

Is there support for ctypes with Jython? Or can I get ctypes working
with Jython somehow?

Thanks :),
Marius

------------------------------------------------------------------------------
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/msIE9-sfdev2dev
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users


------------------------------------------------------------------------------
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/msIE9-sfdev2dev
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users
Reply | Threaded
Open this post in threaded view
|

Re: ctypes in Jython

josu jugo-3
HI

About JNA, I can say that we have use it under jython 2.5.x  on different projects successfully, although I must add that the projects are not large.

regards

josu


On 2010 aza 17, at 22:37, Jim Baker wrote:

Sorry for being too optimistic. We ended up not supporting any of those modules in 2.5.1, because we wanted to get some critical bug fixes out first. 2.5.2 is more bug fixes, plus Java integration. There's some experimental support for ctypes in 2.5.2, but it's really more of a placeholder at this point. And none of the other modules mentioned (bz2, CJK codecs, sqlite3, or completion of unicodedata) have been completed either. They might be released on PyPI first as a separate download, or in 2.6. Nothing really too difficult to do, but we don't have the resources since we are an all-volunteer project. Contributions welcome!

We do need to update the FAQ of course.

I do recommend JNA if you can modify your ctypes code. JNA is pretty close to ctypes - JNA's API apparently was significantly influenced by ctypes! JNA also seems to work well with Jython.

The other option is to use something like execnet. For execnet specifically: it allows you to pair Jython with CPython, and it does seem to work well. But its GPL license makes it a non starter for many people. There are other choices out there too.

- Jim

On Wed, Nov 17, 2010 at 5:24 AM, Marius <[hidden email]> wrote:
Hi!

I checked out the website:
"We do plan to support bz2, ctypes, sqlite3, flesh out unicodedata,
and support cjk codecs in 2.5.1." <-
(http://www.jython.org/faq3.html)

->Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)
[OpenJDK Server VM (Sun Microsystems Inc.)] on java1.6.0_18
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
ImportError: No module named ctypes
>>>

Is there support for ctypes with Jython? Or can I get ctypes working
with Jython somehow?

Thanks :),
Marius

------------------------------------------------------------------------------
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/msIE9-sfdev2dev
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users

------------------------------------------------------------------------------
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/msIE9-sfdev2dev_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users


------------------------------------------------------------------------------
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/msIE9-sfdev2dev
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users
Reply | Threaded
Open this post in threaded view
|

Re: ctypes in Jython

Dan Stromberg-2
In reply to this post by Jim Baker


On Wed, Nov 17, 2010 at 1:37 PM, Jim Baker <[hidden email]> wrote:
There's some experimental support for ctypes in 2.5.2, but it's really more of a placeholder at this point.

I tried the ctypes module in 2.5.2rc2 recently, and found that:
1) There's no ctypes.util.find_library yet
2) ctypes.Structure doesn't support non-scalar types yet

So I agree with the "more of a placeholder" assessment.  Still, it's exciting to see it getting started.



------------------------------------------------------------------------------
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/msIE9-sfdev2dev
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users
Reply | Threaded
Open this post in threaded view
|

Re: ctypes in Jython

Safoura
In reply to this post by Jim Baker
Jim Baker <jbaker <at> zyasoft.com> writes:

>
>
> Sorry for being too optimistic. We ended up not supporting any of those
modules in 2.5.1, because we wanted to get some critical bug fixes out first.
2.5.2 is more bug fixes, plus Java integration. There's some experimental
support for ctypes in 2.5.2, but it's really more of a placeholder at this
point. And none of the other modules mentioned (bz2, CJK codecs, sqlite3, or
completion of unicodedata) have been completed either. They might be released on
PyPI first as a separate download, or in 2.6. Nothing really too difficult to
do, but we don't have the resources since we are an all-volunteer project.
Contributions welcome!
>
>
>
>
> We do need to update the FAQ of course.
> I do recommend JNA if you can modify your ctypes code. JNA is pretty close to
ctypes - JNA's API apparently was significantly influenced by ctypes! JNA also
seems to work well with Jython.
>
>
> The other option is to use something like execnet. For execnet specifically:
it allows you to pair Jython with CPython, and it does seem to work well. But
its GPL license makes it a non starter for many people. There are other choices
out there too.
>
>
> - JimOn Wed, Nov 17, 2010 at 5:24 AM, Marius <wishinet <at> googlemail.com>
wrote:

>
> Hi!
> I checked out the website:
> "We do plan to support bz2, ctypes, sqlite3, flesh out unicodedata,
> and support cjk codecs in 2.5.1." <-
> (http://www.jython.org/faq3.html)
> ->Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)
> [OpenJDK Server VM (Sun Microsystems Inc.)] on java1.6.0_18
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import ctypes
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> ImportError: No module named ctypes
> >>>
> Is there support for ctypes with Jython? Or can I get ctypes working
> with Jython somehow?
> Thanks :),
> Marius
> ------------------------------------------------------------------------------
> 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 todayhttp://p.sf.net/sfu/msIE9-
sfdev2dev
> _______________________________________________
> Jython-users mailing listJython-users <at>
lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/jython-users

>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> 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/msIE9-sfdev2dev
>
> _______________________________________________
> Jython-users mailing list
> Jython-users <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jython-users
>

Hi Jim,
As I was doing some research for my problem, I found this post and joined this
mailing list.
I need to communicate with some device which I have a perfectly working Python
module for. I also have an extensive Java program which needs to talk to the
device and I thought I just call the perfect python module functions from the
already existing Java code.
Therefore I have been looking for a way to call the Python module lib's
functions from Java and found out that Jython is designed to do that.
However, the Python module uses "PyUSB" library which apparently uses ctypes to
communicate with native libraries in Python.
Now is it true that I won't simply be able to continue this project any more
because ctypes is not supported in Jython? I was so excited about this but now
don't know how to go further.
If that is the case, is there any thing other than Jython that you could suggest
as a solution, by any chance?
Any comment/suggestion would be greatly appreciated.

Thanks so much
Safi



------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users
Reply | Threaded
Open this post in threaded view
|

Re: ctypes in Jython

Alex Grönholm-3
22.06.2011 18:42, Safoura kirjoitti:

> Jim Baker<jbaker<at>  zyasoft.com>  writes:
>
>>
>> Sorry for being too optimistic. We ended up not supporting any of those
> modules in 2.5.1, because we wanted to get some critical bug fixes out first.
> 2.5.2 is more bug fixes, plus Java integration. There's some experimental
> support for ctypes in 2.5.2, but it's really more of a placeholder at this
> point. And none of the other modules mentioned (bz2, CJK codecs, sqlite3, or
> completion of unicodedata) have been completed either. They might be released on
> PyPI first as a separate download, or in 2.6. Nothing really too difficult to
> do, but we don't have the resources since we are an all-volunteer project.
> Contributions welcome!
>>
>>
>>
>> We do need to update the FAQ of course.
>> I do recommend JNA if you can modify your ctypes code. JNA is pretty close to
> ctypes - JNA's API apparently was significantly influenced by ctypes! JNA also
> seems to work well with Jython.
>>
>> The other option is to use something like execnet. For execnet specifically:
> it allows you to pair Jython with CPython, and it does seem to work well. But
> its GPL license makes it a non starter for many people. There are other choices
> out there too.
>>
>> - JimOn Wed, Nov 17, 2010 at 5:24 AM, Marius<wishinet<at>  googlemail.com>
> wrote:
>> Hi!
>> I checked out the website:
>> "We do plan to support bz2, ctypes, sqlite3, flesh out unicodedata,
>> and support cjk codecs in 2.5.1."<-
>> (http://www.jython.org/faq3.html)
>> ->Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)
>> [OpenJDK Server VM (Sun Microsystems Inc.)] on java1.6.0_18
>> Type "help", "copyright", "credits" or "license" for more information.
>>>>> import ctypes
>> Traceback (most recent call last):
>>    File "<stdin>", line 1, in<module>
>> ImportError: No module named ctypes
>> Is there support for ctypes with Jython? Or can I get ctypes working
>> with Jython somehow?
>> Thanks :),
>> Marius
>> ------------------------------------------------------------------------------
>> 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 todayhttp://p.sf.net/sfu/msIE9-
> sfdev2dev
>> _______________________________________________
>> Jython-users mailing listJython-users<at>
> lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/jython-users
>>
>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> 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/msIE9-sfdev2dev
>>
>> _______________________________________________
>> Jython-users mailing list
>> Jython-users<at>  lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jython-users
>>
> Hi Jim,
> As I was doing some research for my problem, I found this post and joined this
> mailing list.
> I need to communicate with some device which I have a perfectly working Python
> module for. I also have an extensive Java program which needs to talk to the
> device and I thought I just call the perfect python module functions from the
> already existing Java code.
> Therefore I have been looking for a way to call the Python module lib's
> functions from Java and found out that Jython is designed to do that.
> However, the Python module uses "PyUSB" library which apparently uses ctypes to
> communicate with native libraries in Python.
> Now is it true that I won't simply be able to continue this project any more
> because ctypes is not supported in Jython? I was so excited about this but now
> don't know how to go further.
> If that is the case, is there any thing other than Jython that you could suggest
> as a solution, by any chance?
> Any comment/suggestion would be greatly appreciated.
Try Py4J. It will bridge CPython and Jython so you can use stuff from both.

> Thanks so much
> Safi
>
>
>
> ------------------------------------------------------------------------------
> Simplify data backup and recovery for your virtual environment with vRanger.
> Installation's a snap, and flexible recovery options mean your data is safe,
> secure and there when you need it. Data protection magic?
> Nope - It's vRanger. Get your free trial download today.
> http://p.sf.net/sfu/quest-sfdev2dev
> _______________________________________________
> Jython-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jython-users


------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users
Reply | Threaded
Open this post in threaded view
|

Re: ctypes in Jython

Safoura
> > Hi Jim,
> > As I was doing some research for my problem, I found this post and joined
this
> > mailing list.
> > I need to communicate with some device which I have a perfectly working
Python
> > module for. I also have an extensive Java program which needs to talk to the
> > device and I thought I just call the perfect python module functions from
the
> > already existing Java code.
> > Therefore I have been looking for a way to call the Python module lib's
> > functions from Java and found out that Jython is designed to do that.
> > However, the Python module uses "PyUSB" library which apparently uses ctypes
to
> > communicate with native libraries in Python.
> > Now is it true that I won't simply be able to continue this project any more
> > because ctypes is not supported in Jython? I was so excited about this but
now
> > don't know how to go further.
> > If that is the case, is there any thing other than Jython that you could
suggest
> > as a solution, by any chance?
> > Any comment/suggestion would be greatly appreciated.
> Try Py4J. It will bridge CPython and Jython so you can use stuff from both.
> > Thanks so much
> > Safi
> >
> >
> >


Hi

Thanks for introducing Py4J; I went through the docs. But isn't that for
accessing the Java objects from a python program and the other way around. As I
mentioned, I need to find a way to call the Python lib functions from my running
Java code. Would it be still an option? How about Jepp? Could that be a solution
too?

Thanks so much in advance.

Safi



------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users
Reply | Threaded
Open this post in threaded view
|

Re: ctypes in Jython

Chris Clark-2
Safoura wrote:
> Thanks for introducing Py4J; I went through the docs. But isn't that for
> accessing the Java objects from a python program and the other way around. As I
> mentioned, I need to find a way to call the Python lib functions from my running
> Java code. Would it be still an option? How about Jepp? Could that be a solution
> too?
>  

I've used http://pypi.python.org/pypi/RPyC/ a few times and I've had
pretty  good success with it (in both directions, my pure Jython JDBC
driver works great being accessed from Cpython [the reverse of what you
want]).

There are a bunch of others (execnet, SPyRO, and SPIRO).

A ctypes module based on top if JNA would be neat :-) That would be a a
great project as others could use it later on (I've not looked in the
the Jython initial ctypes implementation so if you want to hack on
something also consider hacking on the current ctypes code in Jython).

Chris


------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users
Reply | Threaded
Open this post in threaded view
|

Re: ctypes in Jython

Chris Clark-2
Chris Clark wrote:

> Safoura wrote:
>> Thanks for introducing Py4J; I went through the docs. But isn't that
>> for accessing the Java objects from a python program and the other
>> way around. As I mentioned, I need to find a way to call the Python
>> lib functions from my running Java code. Would it be still an option?
>> How about Jepp? Could that be a solution too?
>>  
>
> I've used http://pypi.python.org/pypi/RPyC/ a few times and I've had
> pretty  good success with it (in both directions, my pure Jython JDBC
> driver works great being accessed from Cpython [the reverse of what
> you want]).
>
> There are a bunch of others (execnet, SPyRO, and SPIRO).

RE RPyC calling Cpython from Jython, I forgot to add that the version I
had raised errors on method calls (it was fine in the other direction),
but using .__call__() always worked fine. I never got around to going
any further (e.g. logging a bug report) as I was playing around and got
what I needed to do work.

Chris


------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users
Reply | Threaded
Open this post in threaded view
|

Re: ctypes in Jython

Alan Kennedy-2
In reply to this post by Safoura
[Safoura]
> I need to communicate with some device which I have a perfectly working Python
> module for. I also have an extensive Java program which needs to talk to the
> device and I thought I just call the perfect python module functions from the
> already existing Java code.
> Therefore I have been looking for a way to call the Python module lib's
> functions from Java and found out that Jython is designed to do that.
> However, the Python module uses "PyUSB" library which apparently uses ctypes to
> communicate with native libraries in Python.

Have you considered porting that python USB code to a java USB
library? They would probably have similar APIs, and might even use the
same underlying native library, if the java lib uses JNA.

http://stackoverflow.com/questions/862880/java-usb-library

Alan.

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users
Reply | Threaded
Open this post in threaded view
|

Re: ctypes in Jython

Dan Stromberg-2
In reply to this post by Safoura

On Wed, Jun 22, 2011 at 8:42 AM, Safoura <[hidden email]> wrote:


However, the Python module uses "PyUSB" library which apparently uses ctypes to
communicate with native libraries in Python.
Now is it true that I won't simply be able to continue this project any more
because ctypes is not supported in Jython?

Jython has a ctypes module - it's just kind of young:

 $ /usr/local/jython-2.5.2/bin/jython -c 'import ctypes; print ctypes'
<module 'ctypes' from '/usr/local/jython-2.5.2/Lib/ctypes/__init__.py'>


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense..
http://p.sf.net/sfu/splunk-d2d-c1
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users