Mailman 2.1: hardcoded site-packages dir prefix doesn't work on some 64 bit filesystem layouts

Bug #1838866 reported by Hanno Böck
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Mailman
Low
Mark Sapiro
mailman (Ubuntu)
Undecided
Unassigned

Bug Description

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.

Related branches

Revision history for this message
Hanno Böck (hanno-hboeck) wrote :
Revision history for this message
Mark Sapiro (msapiro) wrote :

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.

Revision history for this message
Mark Sapiro (msapiro) wrote :

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.

Revision history for this message
Hanno Böck (hanno-hboeck) wrote :

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

Mark Sapiro (msapiro)
Changed in mailman:
assignee: nobody → Mark Sapiro (msapiro)
importance: Undecided → Low
milestone: none → 2.1.30
status: New → Fix Committed
Changed in mailman:
status: Fix Committed → Confirmed
status: Confirmed → Fix Committed
Paul White  (paulw2u)
affects: ubuntu → mailman (Ubuntu)
Revision history for this message
Robie Basak (racb) wrote :

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
Mark Sapiro (msapiro)
Changed in mailman:
status: Fix Committed → Fix Released
Revision history for this message
Paul White  (paulw2u) wrote :

It seems the Ubuntu task was created in error.

Changed in mailman (Ubuntu):
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers