@@ -179,9 +179,6 @@ def get_option_from_sys_argv(option_str):
179
179
# extension. Note that those libraries have to be compiled with
180
180
# -fPIC for this to work.
181
181
compile_static_ext = get_option_from_sys_argv ('--compile_static_extension' )
182
- extra_compile_args = ['-Wno-write-strings' ,
183
- '-Wno-invalid-offsetof' ,
184
- '-Wno-sign-compare' ]
185
182
libraries = ['protobuf' ]
186
183
extra_objects = None
187
184
if compile_static_ext :
@@ -190,6 +187,27 @@ def get_option_from_sys_argv(option_str):
190
187
'../src/.libs/libprotobuf-lite.a' ]
191
188
test_conformance .target = 'test_python_cpp'
192
189
190
+ extra_compile_args = []
191
+
192
+ if sys .platform != 'win32' :
193
+ extra_compile_args .append ('-Wno-write-strings' )
194
+ extra_compile_args .append ('-Wno-invalid-offsetof' )
195
+ extra_compile_args .append ('-Wno-sign-compare' )
196
+
197
+ # https://github.com/Theano/Theano/issues/4926
198
+ if sys .platform == 'win32' :
199
+ extra_compile_args .append ('-D_hypot=hypot' )
200
+
201
+ # https://github.com/tpaviot/pythonocc-core/issues/48
202
+ if sys .platform == 'win32' and '64 bit' in sys .version :
203
+ extra_compile_args .append ('-DMS_WIN64' )
204
+
205
+ # MSVS default is dymanic
206
+ if (sys .platform == 'win32' and
207
+ ((sys .version_info [0 ] == 3 and sys .version_info [1 ] == 5 ) or
208
+ (sys .version_info [0 ] == 3 and sys .version_info [1 ] == 6 ))):
209
+ extra_compile_args .append ('/MT' )
210
+
193
211
if "clang" in os .popen ('$CC --version 2> /dev/null' ).read ():
194
212
extra_compile_args .append ('-Wno-shorten-64-to-32' )
195
213
@@ -217,7 +235,7 @@ def get_option_from_sys_argv(option_str):
217
235
Extension (
218
236
"google.protobuf.internal._api_implementation" ,
219
237
glob .glob ('google/protobuf/internal/api_implementation.cc' ),
220
- extra_compile_args = ['-DPYTHON_PROTO2_CPP_IMPL_V2' ],
238
+ extra_compile_args = extra_compile_args + ['-DPYTHON_PROTO2_CPP_IMPL_V2' ],
221
239
),
222
240
])
223
241
os .environ ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION' ] = 'cpp'
0 commit comments