From 764086cad244311865adb4af2f3d6eb5c226fadc Mon Sep 17 00:00:00 2001
From: Julien Muchembled <jm@nexedi.com>
Date: Sun, 10 May 2020 22:51:33 +0200
Subject: [PATCH] boost-lib: fix build with python3

---
 component/boost-lib/buildout.cfg               |  9 +++++++--
 component/boost-lib/fix-ftbfs-python-3.3.patch | 18 ++++++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)
 create mode 100644 component/boost-lib/fix-ftbfs-python-3.3.patch

diff --git a/component/boost-lib/buildout.cfg b/component/boost-lib/buildout.cfg
index ccdbdfa5a..f75d12f69 100644
--- a/component/boost-lib/buildout.cfg
+++ b/component/boost-lib/buildout.cfg
@@ -3,6 +3,7 @@ parts =
   boost-lib
 extends =
   ../bzip2/buildout.cfg
+  ../patch/buildout.cfg
   ../zlib/buildout.cfg
   ../xz-utils/buildout.cfg
 
@@ -12,7 +13,7 @@ shared = true
 url = http://downloads.sourceforge.net/sourceforge/boost/boost_1_67_0.tar.bz2
 md5sum = ced776cb19428ab8488774e1415535ab
 location = @@LOCATION@@
-configure-command = ./bootstrap.sh --prefix=${:location} --without-icu
+configure-command = ./bootstrap.sh --prefix=${:location} --without-icu $${PYTHON:+--with-python=$PYTHON}
 make-binary =
 make-options =
 make-targets = for a in $MAKEFLAGS; do case $a in -j*) j=$a; break;; esac; done;
@@ -23,4 +24,8 @@ environment =
   ZLIB_INCLUDE=${zlib:location}/include
   ZLIB_LIBPATH=${zlib:location}/lib
   LZMA_INCLUDE=${xz-utils:location}/include
-  LZMA_LIBRARY_PATH=${xz-utils:location}/lib
\ No newline at end of file
+  LZMA_LIBRARY_PATH=${xz-utils:location}/lib
+patch-options = -p1
+patches =
+  ${:_profile_base_location_}/fix-ftbfs-python-3.3.patch#c85fb479d51354deafd1cc7af78f25d2
+patch-binary = ${patch:location}/bin/patch
diff --git a/component/boost-lib/fix-ftbfs-python-3.3.patch b/component/boost-lib/fix-ftbfs-python-3.3.patch
new file mode 100644
index 000000000..4a3f9f691
--- /dev/null
+++ b/component/boost-lib/fix-ftbfs-python-3.3.patch
@@ -0,0 +1,18 @@
+Description: python3.3 has an extra multiarch include location
+Author: Dmitrijs Ledkovs <dmitrij.ledkov@ubuntu.com>
+Last-Update: 2012-10-26
+Forwarded: no
+
+--- boost1.65.1-1.65.1+dfsg.orig/tools/build/src/tools/python.jam
++++ boost1.65.1-1.65.1+dfsg/tools/build/src/tools/python.jam
+@@ -544,7 +544,9 @@
+     }
+     else
+     {
+-        includes ?= $(prefix)/include/python$(version) ;
++        python_includes = [ shell-cmd "printf `python$(version) -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc());'`" ] ;
++        python_platincludes = [ shell-cmd "printf `python$(version) -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc(plat_specific=1));'`" ] ;
++        includes ?= $(python_includes) $(python_platincludes) ;
+ 
+         local lib = $(exec-prefix)/lib ;
+         libraries ?= $(lib)/python$(version)/config $(lib) ;
-- 
2.30.9