boost, boost-python, dlib, python3, on centos aws ami

At cambackup.com we do camera cloud recording and we do recognition of faces , scene and objects.
we use aws for almost everything, everything is packed with packer and with ansible playbooks.
We use amazon ami is based on centos and centos is based on redhat, very secure well updated.

Recently played a lot with dlib on my mac , and I decided to make some feature in cambackup.
unfurtonanly this packages are not easy to install on a centos machine if you are using python3
So I made this simple article for my self and hope this article will catch up in the search engine and help others with the same problem.

What I basically did is make the packages from source instead of the ones you caninstall with with yum.

So here are the commands

first install python3  in this case python3.6
sudo yum install python36* -y

We need g++  cmake , gcc and gcc-c++ to compile dlib and boost

download boost and dlib 

wget https://dl.bintray.com/boostorg/release/1.65.1/source/boost_1_65_1.tar.gz
wget http://dlib.net/files/dlib-19.7.tar.bz2
tar -xvf boost_1_65_1.tar.gz
tar -xvf dlib-19.7.tar.bz2
sudo rm boost_1_65_1.tar.gz
sudo rm dlib-19.7.tar.bz2

cd ../boost_1_65_1/
sudo ./bootstrap.sh --with-python=python3.6 --with-libraries=python --prefix=/usr
sudo vim project-config.jam

# Boost.Build Configuration
# Automatically generated by bootstrap.sh

import option ;
import feature ;

# Compiler configuration. This definition will be used unless
# you already have defined some toolsets in your user-config.jam
# file.
if ! gcc in [ feature.values <toolset> ]
{
    using gcc ;
}

project : default-build <toolset>gcc ;

# Python configuration
import python ;
if ! [ python.configured ]
{
    #using python : 3.6 : /usr/bin/python3.6 ;
using python : 3.6 : /usr/bin/python3.6 : /usr/include/python3.6m : /usr/lib64 ;
}

# List of --with-<library> and --without-<library>
# options. If left empty, all libraries will be built.
# Options specified on the command line completely
# override this variable.
libraries =  --with-python ;

# These settings are equivivalent to corresponding command-line
# options.
option.set prefix : /usr ;
option.set exec-prefix : /usr ;
option.set libdir : /usr/lib64 ;
option.set includedir : /usr/include ;

# Stop on first error
option.set keep-going : false ;


sudo ./b2

export BOOST_INCLUDEDIR=/home/ec2-user/boost_1_65_1
sudo -E python3 setup.py install
export BOOST_ROOT=/home/ec2-user/boost_1_65_1
sudo -E python3 setup.py install
export BOOST_LIBRARYDIR=/home/ec2-user/boost_1_65_1/stage/lib

cd dlib-19.7/
mkdir build
cd build
sudo cmake ..
sudo cmake --build .
cd ..
sudo -E python3 setup.py install

export LD_LIBRARY_PATH=/home/ec2-user/boost_1_65_1/stage/lib/:$LD_LIBRARY_PATH

sudo ldconfig