msys2-contrib/cpython-mingw

fail build if a module fails to build?

jeremyd2019 opened this issue · 3 comments

After msys2/MINGW-packages#9645, maybe it would make sense to make the build fail if a module fails to build? I did some nasty hacks with tee and sed in the MSYS2-packages/python PKGBUILD to detect a failed module and fail the build, but I know that Gentoo patches python to make it fail there instead.

Gentoo's patch:

From da4a87387b4589313003a7bc73832ee6d19f74c4 Mon Sep 17 00:00:00 2001
From: Mike Gilbert <floppym@gentoo.org>
Date: Fri, 5 Jan 2018 13:32:45 -0500
Subject: [PATCH 04/14] setup.py: exit with non-zero status on failure

https://bugs.gentoo.org/show_bug.cgi?id=281968
https://bugs.python.org/issue6731
---
 setup.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/setup.py b/setup.py
index e5a3f1aff8..15dd1c4ad4 100644
--- a/setup.py
+++ b/setup.py
@@ -105,6 +105,7 @@ Programming Language :: Python
 Topic :: Software Development
 """

+exit_status = 0

 def run_command(cmd):
     status = os.system(cmd)
@@ -524,8 +525,10 @@ class PyBuildExt(build_ext):
             print("been built, they are *disabled* by configure:")
             print_three_column(self.disabled_configure)
             print()
+        global exit_status

         if self.failed:
+            exit_status = 1
             failed = self.failed[:]
             print()
             print("Failed to build these modules:")
@@ -533,6 +536,7 @@ class PyBuildExt(build_ext):
             print()

         if self.failed_on_import:
+            exit_status = 1
             failed = self.failed_on_import[:]
             print()
             print("Following modules built successfully"
@@ -2603,6 +2607,7 @@ def main():
           scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3",
                      "Tools/scripts/2to3"]
         )
+    sys.exit(exit_status)

 # --install-platlib
 if __name__ == '__main__':
--
2.33.0

For reference, the sed script from MSYS2-packages run over the output of makeing python:

sed -ne '/^\s*Failed to build these modules/,$ {p; /^\s*$/q42}' make-python.log

If the log contains "Failed to build these modules", it will re-print from that to the first blank line, and then exit with code 42 (which is non-zero, which will fail the PKGBUILD)

lazka commented

I'm afraid that patching this will result in it failing for users that are (on purpose) missing some deps since there is no way to skip it trying to build things.

e.g. our cross build in CI currently fails some modules. Though we should look into fixing it I guess, and try use the vendored libs there.

I went with adding an import test for the module for now, see b7d2e9e