This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author webmaven
Recipients cjw296, gotgenes, mejo, webmaven
Date 2014-09-09.12:26:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1410265608.45.0.436703242866.issue7744@psf.upfronthosting.co.za>
In-reply-to
Content
The lack of a left-append option for site.addsitedir(path), or an site.insertsitedir(index, path) (which is what I would consider a better solution), causes quite a few contortions on some hosted platforms, notably Google App Engine, for vendored packages.

I've been trying to find a more elegant solution than the following code, but haven't been able to find anything:

import os
import site
import sys

dirname = 'lib'
dirpath = os.path.join(os.path.dirname(__file__), dirname)

sys.path, remainder = sys.path[:1], sys.path[1:]
site.addsitedir(dirpath)
sys.path.extend(remainder)

And even asked on StackOverflow: http://stackoverflow.com/questions/25709832/what-is-the-cleanest-way-to-add-a-directory-of-third-party-packages-to-the-begin

Having a site.insertsitedir(index, path) available would make things so much simpler.
History
Date User Action Args
2014-09-09 12:26:48webmavensetrecipients: + webmaven, gotgenes, cjw296, mejo
2014-09-09 12:26:48webmavensetmessageid: <1410265608.45.0.436703242866.issue7744@psf.upfronthosting.co.za>
2014-09-09 12:26:48webmavenlinkissue7744 messages
2014-09-09 12:26:47webmavencreate