-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix Python binding compilation under Windows #31
Conversation
|
||
try: | ||
if options.decompress: | ||
bufsize = options.bufsize or 10*len(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default here seems a bit fragile. The compression ratio could easily be more that 10x, the easiest example is a huge file with only zeros in it.
If you want to be more robust, the solutions I can think of, in order of increasing complexity:
- Do the decompression in a loop, with exponentially increasing buffer sizes, until a limit is reached. The limit can be a command-line argument with a reasonable default, e.g. 1GB
- Add a python binding for the BrotliDecompressedSize() and try to use that. Drawback is that it does not work if there are many metablocks, so you would have to fall back to solution 1)
- Add a python binding for the decompression function that uses two callbacks, and then you can allocate more output if it is needed.
thanks for your comments and suggestions. I'll look into it and try to fix it. |
I cherry-picked two commits from #32 since they relate to the Python binding build process. Besides, the latter gives a warning if the flag |
1752dd4
to
fad6a92
Compare
@szabadka I added a binding for the BrotliDecompressedSize function (I called it "get_decompressed_size"), as you have suggested. Cosimo. |
I’d rather prefer if the Python module was changed to use |
Yes, I also believe that'd be a better idea. I will wait for your patch then. |
I wonder if @khaledhosny had the chance to finish that patch to C. |
Sorry for the delay, open #36 for the decompress changes. |
thank you @khaledhosny!
I'll have closer look tomorrow, and see if I can better debug what's happening here. C. |
@khaledhosny |
- Don't read the whole input to memory. - Support reading from stdin and writing to stdout.
Use memmove() for copying overlapping buffers.
This also fixes two "comparison between signed and unsigned" warnings.
So that we can use a callback to dynamically allocate the decompression buffer, getting rid of the optional bufsize argument to decompress.decompress().
I apologise for the rebase mess, I'm gonna close this pull request and open a new, cleaner one. |
@anthrotype Thanks, I fixed the missing return statement in my PR. |
Hi,
the setup.py needs to be modified to make sure that the building of the Python extension succeeds on a Windows machine.
I tested the scripts on Windows, Cygwin and OS X. You can use them to test that the Python extension works on non-UNIX systems.
All best,
Cosimo