Title: #5636: Improve assertion when verifying paths for Python modules
If I understand this test cases correctly the steps are (based on `pyhbac` usecase):
1) Create temporary `MODPATH` subdirectory under `TEST_DIR`
2) Depending on python version make symbolic link to correct `pyhbac.so` version in the
3) Import `pyhbac`
4) Confirm that imported `pyhbac` module path is the same as created `pyhbac.so` symlink
What `chroot` breaks is injection of prefix `/<<PKGBUILDDIR>>/build/` into
loaded module path.
By using `realpath()` you forcing following symbolic links for both: chroot path and the
link we created in steep (2).
I think functionally it is correct. What I am wondering is, if we should detect and thread
chroot environment special here.
For example instead of calling `realpath()` - subtract "chroot" piece from
Can you check if any module loaded into chroot environment will have this chroot-specific
prefix added to `module.__file__`? Maybe this should be addressed in Python directly.
See the full comment at https://github.com/SSSD/sssd/pull/5636#issuecomment-843620673