Skip to contentSkip to conversation

python: improve impermeability to build environment and error handling

PATCH New Thomas Petazzoni 2 participants 3 messages Jul 8, 2014 – Jul 9, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 python: improve impermeability to build environment and error handling

This commit mainly fixes bug #7268 by improving the impermeability to the build environment by making sure some host environment header paths do not leak into the target build. The investigation was done by David <[email protected]>. This is done by not calling the add_multiarch_paths() function of setup.py when we're cross-compiling, a change made in the newly introduced python-013-dont-add-multiarch-path.patch.

In addition to this, another patch is added to make sure the build is aborted when one of the Python module fails to build. This is done in python-014-abort-on-failed-modules.patch. Without this, the Python setup.py script simply logs which module failed to build, but doesn't abort, so it's hard to notice when there is a problem.

---
 .../python-013-dont-add-multiarch-path.patch       | 27 ++++++++++++++++++++++
 .../python-014-abort-on-failed-modules.patch       | 21 +++++++++++++++++
 2 files changed, 48 insertions(+)
 create mode 100644 package/python/python-013-dont-add-multiarch-path.patch
 create mode 100644 package/python/python-014-abort-on-failed-modules.patch
package/python/python-013-dont-add-multiarch-path.patch new file +27 -0
new file mode 100644
index 0000000..0ab38ac
@@ -0,0 +1,27 @@
+Don't add multiarch paths
+
+The add_multiarch_paths() function leads, in certain build
+environments, to the addition of host header paths to the CFLAGS,
+which is not appropriate for cross-compilation. This patch fixes that
+by simply removing the call to add_multiarch_paths() when we're
+cross-compiling.
+
+Investigation done by David <[email protected]>.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+
+Index: b/setup.py
+===================================================================
+--- a/setup.py
++++ b/setup.py
+@@ -454,9 +454,9 @@
+         if not cross_compiling:
+             add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
+             add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
++            self.add_multiarch_paths()
+         if cross_compiling:
+             self.add_gcc_paths()
+-        self.add_multiarch_paths()
+ 
+         # Add paths specified in the environment variables LDFLAGS and
+         # CPPFLAGS for header and library files.
package/python/python-014-abort-on-failed-modules.patch new file +21 -0
new file mode 100644
index 0000000..2031e20
@@ -0,0 +1,21 @@
+Abort on failed module build
+
+When building a Python module fails, the setup.py script currently
+doesn't exit with an error, and simply continues. This is not a really
+nice behavior, so this patch changes setup.py to abort with an error,
+so that the build issue is clearly noticeable.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+
+Index: b/setup.py
+===================================================================
+--- a/setup.py
++++ b/setup.py
+@@ -281,6 +281,7 @@
+             print "Failed to build these modules:"
+             print_three_column(failed)
+             print
++            sys.exit(1)
+ 
+     def build_extension(self, ext):
+ 
Signature · 1 line
2.0.0
#1 lore raw

PATCH 2/2 python3: improve impermeability to build environment and error handling

This commit mainly fixes bug #7268 by improving the impermeability to the build environment by making sure some host environment header paths do not leak into the target build. The investigation was done by David <[email protected]>. This is done by not calling the add_multiarch_paths() function of setup.py when we're cross-compiling, a change made in the newly introduced python3-012-dont-add-multiarch-path.patch.

In addition to this, another patch is added to make sure the build is aborted when one of the Python module fails to build. This is done in python3-013-abort-on-failed-modules.patch. Without this, the Python setup.py script simply logs which module failed to build, but doesn't abort, so it's hard to notice when there is a problem.

---
 .../python3-012-dont-add-multiarch-path.patch      | 28 ++++++++++++++++++++++
 .../python3-013-abort-on-failed-modules.patch      | 21 ++++++++++++++++
 2 files changed, 49 insertions(+)
 create mode 100644 package/python3/python3-012-dont-add-multiarch-path.patch
 create mode 100644 package/python3/python3-013-abort-on-failed-modules.patch
package/python3/python3-012-dont-add-multiarch-path.patch new file +28 -0
new file mode 100644
index 0000000..cfd88b2
@@ -0,0 +1,28 @@
+Don't add multiarch paths
+
+The add_multiarch_paths() function leads, in certain build
+environments, to the addition of host header paths to the CFLAGS,
+which is not appropriate for cross-compilation. This patch fixes that
+by simply removing the call to add_multiarch_paths() when we're
+cross-compiling.
+
+Investigation done by David <[email protected]>.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+
+Index: b/setup.py
+===================================================================
+--- a/setup.py
++++ b/setup.py
+@@ -461,10 +461,10 @@
+         if not cross_compiling:
+             add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
+             add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
++            self.add_multiarch_paths()
+         # only change this for cross builds for 3.3, issues on Mageia
+         if cross_compiling:
+             self.add_gcc_paths()
+-        self.add_multiarch_paths()
+ 
+         # Add paths specified in the environment variables LDFLAGS and
+         # CPPFLAGS for header and library files.
package/python3/python3-013-abort-on-failed-modules.patch new file +21 -0
new file mode 100644
index 0000000..c54c72e
@@ -0,0 +1,21 @@
+Abort on failed module build
+
+When building a Python module fails, the setup.py script currently
+doesn't exit with an error, and simply continues. This is not a really
+nice behavior, so this patch changes setup.py to abort with an error,
+so that the build issue is clearly noticeable.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+
+Index: b/setup.py
+===================================================================
+--- a/setup.py
++++ b/setup.py
+@@ -278,6 +278,7 @@
+             print("Failed to build these modules:")
+             print_three_column(failed)
+             print()
++            sys.exit(1)
+ 
+     def build_extension(self, ext):
+ 
Signature · 1 line
2.0.0
#2 lore raw

PATCH 1/2 python: improve impermeability to build environment and error handling

In reply to Thomas Petazzoni
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

This commit mainly fixes bug #7268 by improving the impermeability to

As discussed on IRC, I think 'isolation of' is more understandable to non-French people ;)

Committed both with this adjusted, thanks.

Signature · 1 line
Bye, Peter Korsgaard