Created attachment 372082 [details, diff] distutils-r1-install-lib.patch Python sucks at cross-compiling. We all know this. I'm not proposing to fix the cross-compiling of native modules, I'll leave that to upstream, but we can at least install modules to the correct lib directory. This will mean that non-native modules install correctly. I am building on amd64 for arm and my modules install to ${ROOT}/usr/lib64/pythonX.X, which obviously isn't right. The --install-lib flag is all that's needed to fix this. See the very simple attached patch. I checked the tree for ebuilds for that already give --install-lib. * app-accessibility/sphinx3 doesn't use this eclass. * games-action/slune and games-strategy/outerspace pass $(python_get_sitedir) like the patch does. * games-engines/renpy passes $(python_get_sitedir)/renpy${MYSLOT} but this takes precedence over the previous value so no problem.
As you already know, Python sucks a lot. So now, you need to check for side effects. In other words, make sure that passing --install-lib won't break random stuff, e.g. by disabling some files or moving them around. I'm a bit afraid there are some packages that may set some defaults for this, and those defaults would get overriden by the eclass.
And just to be clear, I'm saying that because things like this used to happen with various stuff passed by the eclass. That's why we set build-purelib & build-platlib separately. That's why most of the directory overrides are set weakly via .pydistutils.cfg and not passed via command-line. In fact, I'm not sure if we still need to pass --root= explicitly since we set it in .cfg anyway. Maybe I missed removing the explicit option. Maybe it had some side effects ;). So who's working on a tinderbox again?
Unfortunately even using this locally no longer works since fd4001e9682ed11db9f6b2cf87f3e89ed291fe02 when you stopped hardcoding PYTHON_SITEDIR. :(
For what it's worth, this gives me the right answer for CPython but it's probably no good for the others, especially since it depends on sysconfig, which you said cannot be used. :( realpath -ms $(PYTHONPATH="${EROOT}usr/lib/${impl}" "${PYTHON}" -c 'import site; print(site.getsitepackages()[0])')
Actually I didn't think to try the same trick with the distutils snippet you already have. It does work. realpath -ms $(PYTHONPATH="${EROOT}"usr/$(get_libdir)/${impl} "${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())') I'll find out whether it works for non-CPython. The only crappy part is adjusting PYTHONPATH for jython.
Feel free to reopen when you have a patch or a clear idea how to proceed here.
*** Bug 680194 has been marked as a duplicate of this bug. ***