bz2 module

View: New views
3 Messages — Rating Filter:   Alert me  

bz2 module

by Steve Lewis-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hey all,

I'm new to Jython, and I've started working on the bz2 module implementation. I've looked at the PortingPythonModulesToJython wiki, and I was following that, but I can't seem to get my bz2 module to be recognized:

Traceback (most recent call last):
  File "test_bz2.py", line 11, in <module>
    import bz2
ImportError: No module named bz2

It appears that there is more than one way to register a module, if the "JythonModulesInJava" is still valid:

"My new approach is borrowed slightly from CPython where it's very common to write a C library, a straight wrapper and then a Pythonic wrapper."

So, is there a way I can use the new approach? It looks like (reading the CPythonLib/csv.py) that if I create a "bz2.py" file in the CPythonLib directory, then jython might see it? Or is there a piece of ant that copies the ... oh there it is.

CPythonLib.includes. There it is. Thanks for the help!
Steve


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Jython-dev mailing list
Jython-dev@...
https://lists.sourceforge.net/lists/listinfo/jython-dev

Re: bz2 module

by Philip Jenvey-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Sep 16, 2009, at 6:50 PM, Steve Lewis wrote:

> Hey all,
>
> I'm new to Jython, and I've started working on the bz2 module  
> implementation. I've looked at the PortingPythonModulesToJython  
> wiki, and I was following that, but I can't seem to get my bz2  
> module to be recognized:
>
> Traceback (most recent call last):
>  File "test_bz2.py", line 11, in <module>
>    import bz2
> ImportError: No module named bz2
>
> It appears that there is more than one way to register a module, if  
> the "JythonModulesInJava" is still valid:
>
> "My new approach is borrowed slightly from CPython where it's very  
> common to write a C library, a straight wrapper and then a Pythonic  
> wrapper."
>
> So, is there a way I can use the new approach? It looks like  
> (reading the CPythonLib/csv.py) that if I create a "bz2.py" file in  
> the CPythonLib directory, then jython might see it? Or is there a  
> piece of ant that copies the ... oh there it is.
>
> CPythonLib.includes. There it is. Thanks for the help!
It just needs an entry in org.python.modules.Setup.

I tried making the bz2 module a couple years ago using the Apache bz2  
lib. The big problem I ran into was the Apache decompressor doesn't  
support streaming (allow passing in pieces of an archive piecemeal)  
like Python's bz2.BZ2Decompressor does. Without a bunch of work on  
this decompressor code we either can't support BZ2Decompressor at all  
or can't support it efficiently (unless you can think of another way)

I actually revistied this code again recently and updated a little.  
Here's what I currently have except for my older failed  
BZ2Decompressor experiment --  it's now using the Apache Commons  
Compress bz2 lib, which is the same Apache's under a different name.

BZ2Compressor seems to work, BZ2File needs cleanup and to support  
writing and universal newlines during read. For that it can probably  
use either java.io.LineNumberReader or  
org.python.core.io.TextIOInputStream combined with  
io.UniversalIOWrapper like core.ParserFacade does.





--
Philip Jenvey
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Jython-dev mailing list
Jython-dev@...
https://lists.sourceforge.net/lists/listinfo/jython-dev

bz2.tar.bz2 (36K) Download Attachment

Re: bz2 module

by Philip Jenvey-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Sep 17, 2009, at 11:23 AM, Philip Jenvey wrote:
>
> I tried making the bz2 module a couple years ago using the Apache  
> bz2 lib. The big problem I ran into was the Apache decompressor  
> doesn't support streaming (allow passing in pieces of an archive  
> piecemeal) like Python's bz2.BZ2Decompressor does. Without a bunch  
> of work on this decompressor code we either can't support  
> BZ2Decompressor at all or can't support it efficiently (unless you  
> can think of another way)

Almost forgot -- another potential option is the older jythonx  
project's bzip2 library. It was written from scratch to match the C  
libbz2 API. However I don't know in what state it's in, I'm not sure  
it's totally finished. Code is available from here:

http://underboss.org/~pjenvey/jython/jythonx-bits.tar.bz2

--
Philip Jenvey


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Jython-dev mailing list
Jython-dev@...
https://lists.sourceforge.net/lists/listinfo/jython-dev