Skip to content
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

fail build if a module fails to build? #46

Open
jeremyd2019 opened this issue Sep 23, 2021 · 3 comments
Open

fail build if a module fails to build? #46

jeremyd2019 opened this issue Sep 23, 2021 · 3 comments

Comments

@jeremyd2019
Copy link

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.

@jeremyd2019
Copy link
Author

Gentoo's patch:

From da4a87387b4589313003a7bc73832ee6d19f74c4 Mon Sep 17 00:00:00 2001
From: Mike Gilbert <[email protected]>
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

@jeremyd2019
Copy link
Author

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
Copy link
Member

lazka commented Sep 25, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants