EDIT : Looks like I've messed up the solution from the second post, but it's still giving me an error after I corrected it.
Edit : I tried importing using a full path but it gave me a relative import error. I made another post about it here
the directories looks like this:
project
   |__ utilities
   |      |__ foo.py
   |
   |__ boost_extensions
   |      |__ myclass.cpp
   |      |__ myclass.so
   |
   |__ someotherstuff
   |      |__ bar.py      
   |
   |__ __main__.py
From bar.py I can just import something from foo.py like this:
from ..utilities.foo import Foo
However, from myclass.cpp I'm not sure how to import it. I've tried
boost::python::object mod = boost::python::import("..utilities.foo");
and
boost::python::object mod = boost::python::import("../utilities/foo.py");
both gave me an error module not found error:
ModuleNotFoundError: No module named '.'
I've also seen this post and tried the accepted answer but it did not work (same error as before):
boost::python::object mod;
void set_global(){
    try{
        setenv("PYTHONPATH", ".", 1);
        Py_Initialize();
        mod = boost::python::import("..utilities.foo");
    }
}
I have also tried using sys and os however it still gave me an error (from an answer to this post ):
    try{
        setenv("PYTHONPATH", ".", 1);
        Py_Initialize();
        boost::python::object sys = import("sys");
        boost::python::object os = import("os");
        // sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'Common'))
        // os.path.dirname(__file__)
        boost::python::object arg1 = os.attr("path").attr("dirname")("__file__");
        // os.path.join(arg1, '..', 'Common')
        boost::python::object arg2 = os.attr("path").attr("join")(arg1, "..", "Common");
        // sys.path.append(arg2)
        sys.attr("path").attr("append")(arg2);
        mod = boost::python::import("..utilities.foo");
    } catch(int e){
        cout << "import failed" << endl;
    }
error message:
ModuleNotFoundError: No module named '.'
How am I supposed to import the module?
Thanks
