David
David

Reputation: 39

C++ python module linking on MacOS

I'm building a C++ python module on MacOS.

On my machine I have python, installed in directory /Library/Frameworks/Python.framework/Versions/3.9. I'm specifing python includes directory as -I/Library/Frameworks/Python.framework/Versions/3.9/Headers and libraries directory as -L/Library/Frameworks/Python.framework/Versions/3.9/lib -lpython3.9.

So it builds good and runs good on my machine and other machines, where python is installed into /Library/Frameworks/Python.framework/Versions/3.9.

But when I move my library to machine, where python is installed into another folder, like /usr/local/Cellar/[email protected]/3.9.12/Frameworks/Python.framework/Versions/3.9, I'm getting import module error.

otool -L _mymodule.so command returns hardcoded absolute path to /Library/Frameworks/Python.framework/Versions/3.9. I know, that I can change the path using install_name_tool, but I don't want to ask and explain my module users to do that, as well as to make a symlink.

How can I make module more portable and python install path independent?

Upvotes: 3

Views: 301

Answers (0)

Related Questions