Add a command line option to adjust sys.path? (was Re: Add a site.cfg to keep a persistent list of paths)

On Thu, Oct 21, 2010 at 4:46 AM, Ron Adam <rrr@ronadam.com> wrote:
A simple check to see if a supplied path was a directory or not would let us do both with one new option: -p Specify a directory or a .pth file (see site module docs) to be prepended to sys.path distutils2 could then provide a way to generate an appropriate .pth file instead of installing a distribution. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia

On 10/20/2010 09:32 PM, Nick Coghlan wrote:
Prepending would be great. ;-)
distutils2 could then provide a way to generate an appropriate .pth file instead of installing a distribution.
Where would the .pth file be and how would I run the application if I don't know I need to specify a .pth file? How would I know I need to specify a .pth file? (ie... if I'm trying to figure out what is wrong on some one else's computer.) If you have a default .pth file in the same directory as the .py file being run, then that would give a way to specify an alternative or local library of modules and packages that is program specific without doing anything special. It would be included in the distribution files as well, so distuitils2 doesn't have to generate anything. +1 on the -p option with .pth files also. Can .pth files use environment variables? Cheers, Ron

On Thu, Oct 21, 2010 at 2:36 PM, Ron Adam <rrr@ronadam.com> wrote:
This idea is only aimed at developers. To run an actual Python application that needs additional modules, either install it properly or put it in a zipfile or directory, put a __main__.py at the top level and just run the zipfile/directory directly. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia

On 10/21/2010 2:43 AM, Nick Coghlan wrote:
If this is only aimed at developers, then those developers why isn't, PYTHONPATH="versionA:${PYTHONPATH}" python run_tests.py PYTHONPATH="versionB:${PYTHONPATH}" python run_tests.py , completely and utterly sufficient for the job. -- Scott Dial scott@scottdial.com scodial@cs.indiana.edu

On Sat, Oct 23, 2010 at 2:55 PM, Scott Dial <scott+python-ideas@scottdial.com> wrote:
Without the addition of the ability to supply a .pth file instead, I would tend to agree with you. There's a reason I'd never actually made the suggestion before, despite first thinking of it ages ago. (Although, I'll also point out that your suggestion doesn't work on Windows, which has its own idiosyncratic way of dealing with environment variables). The proposed command line switch would also be compatible with -E, which is *not* the case for any approach based on modifying PYTHONPATH. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia

On 10/23/2010 2:32 PM, Ron Adam wrote:
When you say "developers", do you mean developers of python, or developers with python? I presumed the later.
I intended "developers" to mean anyone proficient with the use of python as a tool or anyone who should be bothered to read "--help" to find out about how to much with the path (e.g., PYTHONPATH).
Does anyone actually use -E? Is that a critical feature worth adding yet another way to add something to sys.path for? I don't find "-p" to be a confusing addition to the switch flag set, so I would say I am mostly a -0 on adding another flag for this purpose unless it has serious advantages over PYTHONPATH. -- Scott Dial scott@scottdial.com scodial@cs.indiana.edu

On 10/20/2010 09:32 PM, Nick Coghlan wrote:
Prepending would be great. ;-)
distutils2 could then provide a way to generate an appropriate .pth file instead of installing a distribution.
Where would the .pth file be and how would I run the application if I don't know I need to specify a .pth file? How would I know I need to specify a .pth file? (ie... if I'm trying to figure out what is wrong on some one else's computer.) If you have a default .pth file in the same directory as the .py file being run, then that would give a way to specify an alternative or local library of modules and packages that is program specific without doing anything special. It would be included in the distribution files as well, so distuitils2 doesn't have to generate anything. +1 on the -p option with .pth files also. Can .pth files use environment variables? Cheers, Ron

On Thu, Oct 21, 2010 at 2:36 PM, Ron Adam <rrr@ronadam.com> wrote:
This idea is only aimed at developers. To run an actual Python application that needs additional modules, either install it properly or put it in a zipfile or directory, put a __main__.py at the top level and just run the zipfile/directory directly. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia

On 10/21/2010 2:43 AM, Nick Coghlan wrote:
If this is only aimed at developers, then those developers why isn't, PYTHONPATH="versionA:${PYTHONPATH}" python run_tests.py PYTHONPATH="versionB:${PYTHONPATH}" python run_tests.py , completely and utterly sufficient for the job. -- Scott Dial scott@scottdial.com scodial@cs.indiana.edu

On Sat, Oct 23, 2010 at 2:55 PM, Scott Dial <scott+python-ideas@scottdial.com> wrote:
Without the addition of the ability to supply a .pth file instead, I would tend to agree with you. There's a reason I'd never actually made the suggestion before, despite first thinking of it ages ago. (Although, I'll also point out that your suggestion doesn't work on Windows, which has its own idiosyncratic way of dealing with environment variables). The proposed command line switch would also be compatible with -E, which is *not* the case for any approach based on modifying PYTHONPATH. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia

On 10/23/2010 2:32 PM, Ron Adam wrote:
When you say "developers", do you mean developers of python, or developers with python? I presumed the later.
I intended "developers" to mean anyone proficient with the use of python as a tool or anyone who should be bothered to read "--help" to find out about how to much with the path (e.g., PYTHONPATH).
Does anyone actually use -E? Is that a critical feature worth adding yet another way to add something to sys.path for? I don't find "-p" to be a confusing addition to the switch flag set, so I would say I am mostly a -0 on adding another flag for this purpose unless it has serious advantages over PYTHONPATH. -- Scott Dial scott@scottdial.com scodial@cs.indiana.edu
participants (3)
-
Nick Coghlan
-
Ron Adam
-
Scott Dial