Since this does not really have an answer, I will offer it for posterity. I also do not have access to a Mac, so for you this might be a little different than Linux. In addition, for this it is necessary to establish the required dependencies so that this can be done, but it is usually quite easy to understand.
Create working directory
mkdir ~/embeddedpython cd ~/embeddedpython
Download Python Source
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
Create an installation directory for Python
mkdir ./installation
Extract downloaded source files
tar xvf Python-3.6.1.tgz
Enter the newly created source directory
cd Python-3.6.1
Configure Python to install in our installation directory
./configure --prefix="/home/<username>/embeddedpython/installation"
Make and Install Python
make && make install
Return to the working directory
cd ..
Create a new PYTHONHOME directory where the library will be located
mkdir home && mkdir home/lib
Copy the Python library to our new home directory
cp -r ./installation/lib/python3.6 ./home/lib/
Create a new C ++ source file (embeddedpython.cpp) with the following code taken from the python documentation , except for the setenv function call.
#include <Python.h> #include <cstdlib> int main(int argc, char *argv[]) { setenv("PYTHONHOME", "./home", 1); wchar_t *program = Py_DecodeLocale(argv[0], NULL); if (program == NULL) { fprintf(stderr, "Fatal error: cannot decode argv[0]\n"); exit(1); } Py_SetProgramName(program); /* optional but recommended */ Py_Initialize(); PyRun_SimpleString("from time import time,ctime\n" "print('Today is', ctime(time()))\n"); if (Py_FinalizeEx() < 0) { exit(120); } PyMem_RawFree(program); return 0; }
Compile and run
g++ embeddedpython.cpp -I ./installation/include/python3.6m/ ./installation/lib/libpython3.6m.a -lpthread -ldl -lutil ./a.out > Today is Fri Apr 14 16:06:54 2017
This is now the standard built-in python, as usual. Using this method, the "home" directory must be included in your deployment, and the PYTHONHOME environment PYTHONHOME must be set to point to it before any python-related code is executed.