Python site-packages directory

EDIT: Sorry, I realize that “other forums / development” is a better place for this. I have reposted there.

I’m writing a python package that uses a compiled library. Because the lib needs to be compiled for the different py versions, I want to put it in the site-packages subfolder that the rest of the package will reside in. But a python script needs to know the full path of the lib in order to access it.

The problem is that the default install directory for opensuse is:


But I don’t know a way to programmatically get this path either during packaging (to make sure the lib goes there) or at runtime (to access the lib correctly). distutils.sysconfig.get_python_lib() returns:


So I have been hard coding the install path. But I’m hoping there is a better way. Any suggestions?