From: Nicholas Y. <su...@su...> - 2005-06-24 10:52:10
|
On Thu, 2005-06-23 at 10:58 -0600, Fernando Perez wrote: > Nicholas Young wrote: > > On Wed, 2005-06-22 at 11:45 -0600, Fernando Perez wrote: > > > >>os.environ['TEXMFOUTPUT'] = '/some/path' > > > > > > According to the online docs > > (http://docs.python.org/lib/os-procinfo.html) setting os.environ isn't > > safe/available for all platforms. You can use the subprocess module to > > set the environment of a subprocess under python 2.4 but I don't think > > there's a simple way to do this and capture the output for earlier > > versions. > > Well, after reading that I get that os.environ _is_ writable everywhere, it's > just that it may leak memory in OSX/BSD. What's not always available is the > putenv() call, but python will find its way around it if needed. To quote "If putenv() is not provided, this mapping may be passed to the appropriate process-creation functions to cause child processes to use a modified environment.". To me this implies that you have to pass os.environ to a process-creation function supporting the env keyword (os.execve, etc.) none of which seem to support capturing output. On the other hand does anyone actually run mpl on a platform which doesn't support putenv? > Since this would be a once-only call, I think that leaking a few bytes is an > acceptable price to pay to prevent a crash if the user happens to be > positioned on a non-writable dir. After reading an online copy of the freebsd man putenv it actually reads "Successive calls to setenv() or putenv() assigning a differently sized value to the same name will result in a memory leak." so setting this once wouldn't be a problem. So I was wrong and setting os.environ seems reasonable in this case - but it seems sensible to be aware of the potential for causing problems if anyone trys to get mpl working on an odd platform. Nick |