From 6ec62d9bbf5b0dd94fcd7df952c808e3a5430d04 Mon Sep 17 00:00:00 2001 From: Waf Project Date: Mon, 28 Oct 2024 23:35:33 +0800 Subject: [PATCH] Disable GX warnings when buildin Python modules with Microsoft Visual Studio Python distutils add the GX flag by default but that was for very old systems and ./Lib/distutils/msvccompiler.py was removed in Python 3.12 --- ChangeLog | 7 +++++++ demos/python/spammodule.c | 2 +- demos/python/test.c | 2 +- demos/python/wscript | 8 +++++--- waflib/Tools/python.py | 4 ++-- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index f03193cd..029e9820 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +NEW IN WAF 2.1.3 +---------------- +* Work around a race condition in mingw Python +* Install Python artifacts under PREFIX in a similar way as waf-2.0 +* Disable GX warnings when buildin Python modules with Microsoft Visual Studio +* Improve the build_logs (prevent log file collisions), PyQt (v6), Sphinx and Cuda examples + NEW IN WAF 2.1.2 ---------------- * Work around some Python regressions diff --git a/demos/python/spammodule.c b/demos/python/spammodule.c index ebe277dc..bd0b72f5 100644 --- a/demos/python/spammodule.c +++ b/demos/python/spammodule.c @@ -34,7 +34,7 @@ static struct PyModuleDef spammodule = { PyMODINIT_FUNC PyInit_spam(void) { - (void) PyModule_Create(&spammodule); + return PyModule_Create(&spammodule); } #else diff --git a/demos/python/test.c b/demos/python/test.c index bfe85a2b..ab548948 100644 --- a/demos/python/test.c +++ b/demos/python/test.c @@ -32,7 +32,7 @@ static struct PyModuleDef embmodule = { PyMODINIT_FUNC PyInit_emb(void) { - (void) PyModule_Create(&embmodule); + return PyModule_Create(&embmodule); } #endif diff --git a/demos/python/wscript b/demos/python/wscript index 0d662b63..deda9181 100644 --- a/demos/python/wscript +++ b/demos/python/wscript @@ -34,9 +34,11 @@ def build(bld): bld(features='py', source=bld.path.ant_glob('*.py'), install_from='.') # example for generated python files - target = bld.path.find_or_declare('abc.py') - bld(rule='touch ${TGT}', source='wscript', target=target) - bld(features='py', source=[target], install_from=target.parent) + from waflib import Utils + if not Utils.is_win32: + target = bld.path.find_or_declare('abc.py') + bld(rule='touch ${TGT}', source='wscript', target=target) + bld(features='py', source=[target], install_from=target.parent) # then a c extension module bld( diff --git a/waflib/Tools/python.py b/waflib/Tools/python.py index fa23eaf6..5f333305 100644 --- a/waflib/Tools/python.py +++ b/waflib/Tools/python.py @@ -476,8 +476,8 @@ def check_python_headers(conf, features='pyembed pyext'): if env.CC_NAME == "msvc": # From https://github.com/python/cpython/blob/main/Lib/distutils/msvccompiler.py - env.append_value('CFLAGS_PYEXT', [ '/nologo', '/Ox', '/MD', '/W3', '/GX', '/DNDEBUG']) - env.append_value('CXXFLAGS_PYEXT', [ '/nologo', '/Ox', '/MD', '/W3', '/GX', '/DNDEBUG']) + env.append_value('CFLAGS_PYEXT', [ '/nologo', '/Ox', '/MD', '/W3', '/EHsc', '/DNDEBUG']) + env.append_value('CXXFLAGS_PYEXT', [ '/nologo', '/Ox', '/MD', '/W3', '/EHsc', '/DNDEBUG']) env.append_value('LINKFLAGS_PYEXT', ['/DLL', '/nologo', '/INCREMENTAL:NO']) # See if it compiles