On Sat, Jul 28, 2012 at 6:47 PM, James William Pye <x@jwp.io> wrote:
I posted a question on c.l.py[1] looking for a feature and I suspect it doesn't exist. Some quick searches on -ideas and -dev didn't reveal anything either.
Has the idea of [python] environment initialization been pitched/rejected before or does it already exist?
Simply, I'm looking for a mechanism to automatically load some meta_path hooks after site initialization.
Without modifying libpython, I can achieve what I'm trying to do by:
* Mangling the site.py file to run the code. (in my case, "import c.lib; c.lib.install()")
No need to modify site.py. Either create a sitecustomize.py in your site-packages. Here are some references: http://docs.python.org/library/site.html http://www.python.org/dev/peps/pep-0370 Nothing new is needed. As to metapath hooks, one alternative is to make a helper function that puts the hooks in place (or otherwise manages your hooks). Then you can call that API in each script that needs those hooks. -eric