[Bug 1838866] [NEW] Mailman 2.1: hardcoded site-packages dir prefix doesn't work on some 64 bit filesystem layouts

Public bug reported:
Mailman's paths.py.in contains code to add the python site-packages dir to the path. This uses a hardcoded "lib" prefix:
# Include Python's site-packages directory. sitedir = os.path.join(sys.prefix, 'lib', 'python'+sys.version[:3], 'site-packages') sys.path.append(sitedir)
On 64 bit systems this is usually lib64 and some distros started removing the compatibility symlink lib->lib64 and split up lib and lib64 (e.g. latest Gentoo profiles). So relying on "lib" as a prefix is not compatible any more.
Python has a function getsitepackages in the site module and I believe it's best to rely on python knowing best where its directories are. It returns an array, so this would look like this: sitedirs = site.getsitepackages() for sitedir in sitedirs: sys.path.append(sitedir)
Patch attached, please apply.
** Affects: mailman Importance: Undecided Status: New
** Attachment added: "fix sitedir path on 64 bit filesystem layouts" https://bugs.launchpad.net/bugs/1838866/+attachment/5280705/+files/mailman-f...

I appreciate the patch. Thank you.
One issue is that site.getsitepackages() requires Python 2.7. It is probably time to stop supporting older versions anyway, so this shouldn't be a problem.

I have now looked at the code for site.getsitepackages() at https://github.com/python/cpython/blob/master/Lib/site.py#L319 and it seems no better than what's in paths.py.in, so I'm not sure this will be effective unless your distro hacks site.py. Is that the case?
It appears Ubuntu does hack site.getsitepackages() to actually return ['/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist- packages'].
I am reluctant to do anything without a better understanding of what site.getsitepackages() returns in various distros.

I'm on Gentoo, seems it also patches the site.py accordingly:
https://gitweb.gentoo.org/repo/gentoo.git/tree/dev- lang/python/python-2.7.16.ebuild#n106

** Branch linked: lp:mailman/2.1

** Changed in: mailman Importance: Undecided => Low
** Changed in: mailman Status: New => Fix Committed
** Changed in: mailman Milestone: None => 2.1.30
** Changed in: mailman Assignee: (unassigned) => Mark Sapiro (msapiro)

** Also affects: ubuntu Importance: Undecided Status: New

** Package changed: ubuntu => mailman (Ubuntu)

Please could someone confirm if this actually requires patching in Ubuntu? I'm not aware that Ubuntu uses "lib64", and "/usr/local" isn't used by system-provided packages anyway. What is the use case that fails in Ubuntu?
Once answered please change the Ubuntu bug task status accordingly (Invalid or New depending on the answer I guess).
** Changed in: mailman (Ubuntu) Status: New => Incomplete

** Changed in: mailman Status: Fix Committed => Fix Released

It seems the Ubuntu task was created in error.
** Changed in: mailman (Ubuntu) Status: Incomplete => Invalid
participants (6)
-
Hanno Böck
-
Keith Brian Tomo
-
Launchpad Bug Tracker
-
Mark Sapiro
-
Paul White
-
Robie Basak