[PR #133] [MERGED] fix compilation on Windows Python 2.7 + support for MINGW32 and Cygwin #746

Open
opened 2026-01-29 20:50:40 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/google/brotli/pull/133
Author: @anthrotype
Created: 8/10/2015
Status: Merged
Merged: 8/11/2015
Merged by: @szabadka

Base: masterHead: py27win


📝 Commits (6)

  • f141729 [brotlimodule.cc] fix RuntimeError on OS X: keyword list must be NULL terminated
  • c3540e2 [setup.py] use MSVC 10.0 when compiling for Windows Python 2.7
  • 54baf43 [setup.py] support MINGW32 compiler: fix clashing 'hypot' definition; statically link libgcc and libstdc++
  • ac33d35 [brotlimodule.cc] add version string attribute to brotli module
  • 8c7edd3 [bro.py] print --version as brotli.version
  • d2c8b27 [setup.py] retrieve version string from brotlimodule.cc so we don't need to modify it more than once

📊 Changes

3 files changed (+48 additions, -9 deletions)

View changed files

📝 python/bro.py (+1 -4)
📝 python/brotlimodule.cc (+5 -1)
📝 setup.py (+42 -4)

📄 Description

This includes:

  • a patch to setup.py to force distutils use MS Visual C++ 10.0, from Visual Studio 2010, instead of the default 9.0, Visual Studio 2008, when compiling for Windows Python 2.7. The latter does not support many of the modern C++ features required to compile the Brotli encoder. Windows Python version 3 and above are compiled with 2010 so they are ok.
  • two patches to setup.py to allow building Brotli with GCC for Windows, instead of the default Microsoft compiler. This can be done by passing the --compiler=mingw32 option to setup.py.
  • a patch to streams.cc to fix compilation under the Cygwin environment. Here GCC complains that 'malloc' and 'free' weren't declared in the current scope:
enc/streams.cc: In constructor ‘brotli::BrotliFileIn::BrotliFileIn(FILE*, size_t)’:
enc/streams.cc:92:32: error: ‘malloc’ was not declared in this scope
       buf_(malloc(max_read_size)),
                                ^
enc/streams.cc: In destructor ‘virtual brotli::BrotliFileIn::~BrotliFileIn()’:
enc/streams.cc:96:22: error: ‘free’ was not declared in this scope
   if (buf_) free(buf_);
                      ^
error: command 'gcc' failed with exit status 1

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/google/brotli/pull/133 **Author:** [@anthrotype](https://github.com/anthrotype) **Created:** 8/10/2015 **Status:** ✅ Merged **Merged:** 8/11/2015 **Merged by:** [@szabadka](https://github.com/szabadka) **Base:** `master` ← **Head:** `py27win` --- ### 📝 Commits (6) - [`f141729`](https://github.com/google/brotli/commit/f14172902b9c21f4ed47a35ce467727f02867280) [brotlimodule.cc] fix RuntimeError on OS X: keyword list must be NULL terminated - [`c3540e2`](https://github.com/google/brotli/commit/c3540e2b7aff0f4632e1ea82cd2cfd55b1b11ff4) [setup.py] use MSVC 10.0 when compiling for Windows Python 2.7 - [`54baf43`](https://github.com/google/brotli/commit/54baf43c700138518c678cee87c439d3a9335aa8) [setup.py] support MINGW32 compiler: fix clashing 'hypot' definition; statically link libgcc and libstdc++ - [`ac33d35`](https://github.com/google/brotli/commit/ac33d35632ad127e7a27d10c7e7bee2e8a70496f) [brotlimodule.cc] add __version__ string attribute to brotli module - [`8c7edd3`](https://github.com/google/brotli/commit/8c7edd3e07b46634361f47fce220ed8c5a9be8aa) [bro.py] print --version as brotli.__version__ - [`d2c8b27`](https://github.com/google/brotli/commit/d2c8b2777d41adb0a8c52becca70b8dc8c40e2dd) [setup.py] retrieve version string from brotlimodule.cc so we don't need to modify it more than once ### 📊 Changes **3 files changed** (+48 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `python/bro.py` (+1 -4) 📝 `python/brotlimodule.cc` (+5 -1) 📝 `setup.py` (+42 -4) </details> ### 📄 Description This includes: - a patch to `setup.py` to force `distutils` use MS Visual C++ 10.0, from Visual Studio 2010, instead of the default 9.0, Visual Studio 2008, when compiling for **Windows Python 2.7**. The latter does not support many of the modern C++ features required to compile the Brotli encoder. Windows Python version 3 and above are compiled with 2010 so they are ok. - two patches to `setup.py` to allow building Brotli with GCC for Windows, instead of the default Microsoft compiler. This can be done by passing the `--compiler=mingw32` option to setup.py. - a patch to `streams.cc` to fix compilation under the Cygwin environment. Here GCC complains that 'malloc' and 'free' weren't declared in the current scope: ``` enc/streams.cc: In constructor ‘brotli::BrotliFileIn::BrotliFileIn(FILE*, size_t)’: enc/streams.cc:92:32: error: ‘malloc’ was not declared in this scope buf_(malloc(max_read_size)), ^ enc/streams.cc: In destructor ‘virtual brotli::BrotliFileIn::~BrotliFileIn()’: enc/streams.cc:96:22: error: ‘free’ was not declared in this scope if (buf_) free(buf_); ^ error: command 'gcc' failed with exit status 1 ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 20:50:40 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#746