From: Daniel Browne <dbrowne@(email surpressed)> Subject: Python Library Paths Date: Fri, 10 Jun 2011 16:14:49 -0400 |
Msg# 2110 View Complete Thread (2 articles) | All Threads Last Next |
Hi to all the python experts on the list, We try to centralize scripts and libraries on our NAS-based NFS shares. One issue I've encountered which I'm not sure how to resolve is creating a network based python library, i.e. "/NFS/Python/" and have all of the sub directories within it be automatically traversed and searched for modules to load. At the moment any sub-directories (i.e. /NFS/Python/2.6 or /NFS/Python/common) have to be appended explicitly with sys.path.append(). From what I have read this appears to be an inherent "safety" feature of Python, but is there a way to override it without having to alter config files on each individual client machine? From a programming and maintenance standpoint it's incredibly inconvenient to have to do so many explicit appends or make constant additions to the PYTHONPATH environment variable. Thanks, -Dan ---------- Dan "Doc" Browne System Administrator Evil Eye Pictures dbrowne@(email surpressed) Office: (415) 777-0666 x105 |
From: Greg Ercolano <erco@(email surpressed)> Subject: Re: Python Library Paths Date: Fri, 10 Jun 2011 16:34:48 -0400 |
Msg# 2111 View Complete Thread (2 articles) | All Threads Last Next |
On 06/10/11 13:14, Daniel Browne wrote: > [posted to rush.general] > > Hi to all the python experts on the list, > > We try to centralize scripts and libraries on our NAS-based NFS shares. On= > e issue I've encountered which I'm not sure how to resolve is creating a ne= > twork based python library, i.e. "/NFS/Python/" and have all of the sub dir= > ectories within it be automatically traversed and searched for modules to l= > oad. At the moment any sub-directories (i.e. /NFS/Python/2.6 or /NFS/Pyth= > on/common) have to be appended explicitly with sys.path.append(). From what= > I have read this appears to be an inherent "safety" feature of Python, but= > is there a way to override it without having to alter config files on each= > individual client machine? From a programming and maintenance standpoint i= > t's incredibly inconvenient to have to do so many explicit appends or make = > constant additions to the PYTHONPATH environment variable. I can't weigh in on the safety features of python (you might want to ask on one of the python forums about this). But if you want the PYTHONPATH variable to be initialized at render time before python is executed, I'd consider two approaches that should be relatively easy to maintain from a sysadmin's point of view: 1) If the target machines are unix, modify the rush/etc/S99rush boot script to set the PYTHONPATH environment variable. Restart the daemon for the change to take effect. 2) If the target machines are windows, you can change environment variables with the 'setenv' command that comes with rush (c:\rush\etc\bin\setenv.exe). In fact, the install.bat script uses this program to add rush to the system PATH. Just run that program without any arguments to see its usage. (C source code was included for this public domain program, in case you're curious) The other way to approach this would be to write a wrapper script that sets the variable before executing the python script. -- Greg Ercolano, erco@(email surpressed) Seriss Corporation Rush Render Queue, http://seriss.com/rush/ Tel: (Tel# suppressed)ext.23 Fax: (Tel# suppressed) Cel: (Tel# suppressed) |