Python site-packages directory

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:

/usr/local/lib/pythonV.v/site-packages/mypackage

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:

/usr/lib/pythonV.v/site-packages

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

If I understand correctly, you want just to check some directory like /usr/local/lib/pythonV.v/site-packages/mypackage and be sure about library (is there or not), right?
…or you have to find the path for this library?