installing scripts into the user's PATH
"Scripts are files containing Python source code, intended to be started from the command line." http://docs.python.org/dist/node11.html I want to do that. I am hoping that once it is done, it will be in a dir that is in the user's OS PATH. (if that sounds restrictive, I didn't say it right. at this point, I don't care what dir it is in, as long as the user doesn't have to type it. like /usr/bin on linux. not sure where the right place would be on mac/win.) Is this supported? Carl K
At 12:03 PM 1/3/2008 -0600, Carl Karsten wrote:
"Scripts are files containing Python source code, intended to be started from the command line." http://docs.python.org/dist/node11.html
I want to do that. I am hoping that once it is done, it will be in a dir that is in the user's OS PATH. (if that sounds restrictive, I didn't say it right. at this point, I don't care what dir it is in, as long as the user doesn't have to type it. like /usr/bin on linux. not sure where the right place would be on mac/win.)
Is this supported?
The default locations on everything but Windows will generally have this work. For Windows, there isn't much you can do except tell people to make sure the Python "Scripts" directory is added to their PATH.
I take it there's nothing in distutils that can actually update the user's OS PATH? On Jan 3, 2008 4:37 PM, Phillip J. Eby <pje@telecommunity.com> wrote:
At 12:03 PM 1/3/2008 -0600, Carl Karsten wrote:
"Scripts are files containing Python source code, intended to be started from the command line." http://docs.python.org/dist/node11.html
I want to do that. I am hoping that once it is done, it will be in a dir that is in the user's OS PATH. (if that sounds restrictive, I didn't say it right. at this point, I don't care what dir it is in, as long as the user doesn't have to type it. like /usr/bin on linux. not sure where the right place would be on mac/win.)
Is this supported?
The default locations on everything but Windows will generally have this work. For Windows, there isn't much you can do except tell people to make sure the Python "Scripts" directory is added to their PATH.
_______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig
Phillip J. Eby wrote:
At 12:03 PM 1/3/2008 -0600, Carl Karsten wrote:
"Scripts are files containing Python source code, intended to be started from the command line." http://docs.python.org/dist/node11.html
I want to do that. I am hoping that once it is done, it will be in a dir that is in the user's OS PATH. (if that sounds restrictive, I didn't say it right. at this point, I don't care what dir it is in, as long as the user doesn't have to type it. like /usr/bin on linux. not sure where the right place would be on mac/win.)
Is this supported?
The default locations on everything but Windows will generally have this work. For Windows, there isn't much you can do except tell people to make sure the Python "Scripts" directory is added to their PATH.
so if I do: scripts=['foo.py', 'bar.py'] where will they be copied? Carl K
At 02:17 PM 1/3/2008 -0600, Carl Karsten wrote:
Phillip J. Eby wrote:
"Scripts are files containing Python source code, intended to be started from the command line." http://docs.python.org/dist/node11.html
I want to do that. I am hoping that once it is done, it will be in a dir that is in the user's OS PATH. (if that sounds restrictive, I didn't say it right. at this point, I don't care what dir it is in, as long as the user doesn't have to type it. like /usr/bin on linux. not sure where the right place would be on mac/win.)
Is this supported? The default locations on everything but Windows will generally have
At 12:03 PM 1/3/2008 -0600, Carl Karsten wrote: this work. For Windows, there isn't much you can do except tell people to make sure the Python "Scripts" directory is added to their PATH.
so if I do: scripts=['foo.py', 'bar.py']
where will they be copied?
On unixes, they will typically go to the same directory where the `python` executable itself lives. On Windows, they'll go to the Scripts subdirectory of the Python installation directory.
Phillip J. Eby wrote:
At 12:03 PM 1/3/2008 -0600, Carl Karsten wrote:
"Scripts are files containing Python source code, intended to be started from the command line." http://docs.python.org/dist/node11.html
I want to do that. I am hoping that once it is done, it will be in a dir that is in the user's OS PATH. (if that sounds restrictive, I didn't say it right. at this point, I don't care what dir it is in, as long as the user doesn't have to type it. like /usr/bin on linux. not sure where the right place would be on mac/win.)
Is this supported?
The default locations on everything but Windows will generally have this work. For Windows, there isn't much you can do except tell people to make sure the Python "Scripts" directory is added to their PATH.
Just curious, but is there a reason setuptools uses 'Scripts' on Windows instead of the 'Tools' dir? Unless I'm mistaken, a a new install of Python 2.5 puts scripts in 'Tools'. -- Dave
At 05:00 PM 1/3/2008 -0600, Dave Peterson wrote:
Just curious, but is there a reason setuptools uses 'Scripts' on Windows instead of the 'Tools' dir? Unless I'm mistaken, a a new install of Python 2.5 puts scripts in 'Tools'.
It puts Python-supplied scripts there, yes, but the convention of installing user scripts in the Scripts subdirectory goes back at least a decade. Which doesn't mean it's right, but it's certainly not *new*. :) (Oh, and it's *distutils* that chooses that location, not setuptools.)
Phillip J. Eby wrote:
At 05:00 PM 1/3/2008 -0600, Dave Peterson wrote:
Just curious, but is there a reason setuptools uses 'Scripts' on Windows instead of the 'Tools' dir? Unless I'm mistaken, a a new install of Python 2.5 puts scripts in 'Tools'.
It puts Python-supplied scripts there, yes, but the convention of installing user scripts in the Scripts subdirectory goes back at least a decade.
Which doesn't mean it's right, but it's certainly not *new*. :)
(Oh, and it's *distutils* that chooses that location, not setuptools.)
Right, sorry for the confusion on which package was doing it. I just wish either distutils or the .msi installer was changed because it is confusing to describe what to do to users (especially those new to Python and/or Windows) when the Python .msi on windows doesn't even create the "Scripts" sub-dir, much less add it to a path environment variable for you. :-( -- Dave
I am attaching a thread I started privately with Ian. The question is multi-part and somewhat complicated so please be patient. Background: I am running python2.5.1, the system python, i.e., default on Leopard: /System/Library/Frameworks/Python.framework/Versions/2.5/bin/ python2.5 I have installed virtualenv via easy_install. I use virtualenv where an entry point was setup in /usr/local/bin/ virtualenv to create a separate virtualenv. This is the buffer from my terminal: (note I use virtualenv to create a groknoahgift virtual env and then run easy_install grokproject egg from there).
The main problem I have is this traceback: [ngift@Macintosh-6][H:10944][J:0]> virtualenv groknoahgift New python executable in groknoahgift/bin/python Installing setuptools............done. [ngift@Macintosh-6][H:10945][J:0]> groknoahgift [ngift@Macintosh-6][H:10946][J:0]> ll total 0 drwxr-xr-x 7 ngift staff 238 Jan 3 09:46 bin drwxr-xr-x 3 ngift staff 102 Jan 3 09:46 lib [ngift@Macintosh-6][H:10947][J:0]> bin/easy_install grokproject Searching for grokproject Best match: grokproject 0.6 Processing grokproject-0.6-py2.5.egg Adding grokproject 0.6 to easy-install.pth file Installing grokproject script to /Users/ngift/src/groknoahgift/bin Using /Library/Python/2.5/site-packages/grokproject-0.6-py2.5.egg Processing dependencies for grokproject Finished processing dependencies for grokproject [ngift@Macintosh-6][H:10948][J:0]> pwd /Users/ngift/src/groknoahgift [ngift@Macintosh-6][H:10949][J:0]> ll total 0 drwxr-xr-x 8 ngift staff 272 Jan 3 09:46 bin drwxr-xr-x 3 ngift staff 102 Jan 3 09:46 lib [ngift@Macintosh-6][H:10950][J:0]> bin/grokproject noahgift Traceback (most recent call last): File "bin/grokproject", line 5, in <module> from pkg_resources import load_entry_point File "build/bdist.linux-i686/egg/pkg_resources.py", line 2561, in <module> File "build/bdist.linux-i686/egg/pkg_resources.py", line 626, in require File "build/bdist.linux-i686/egg/pkg_resources.py", line 524, in resolve pkg_resources.DistributionNotFound: PasteScript>=1.3
In trying to track down this problem, I then realized that for Grok, I need to use python2.4.4, so I did this to get around the problem, as Ian suggested: [ngift@Macintosh-6][H:10996][J:0]> curl http://svn.colorstudy.com/virtualenv/trunk/virtualenv.py
virtualenv-2.4 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 35516 100 35516 0 0 45505 0 --:--:-- --:--:-- --:--:-- 80395 [ngift@Macintosh-6][H:10997][J:0]> python2.4 virtualenv-2.4 src/py24ENV New python executable in src/py24ENV/bin/python Installing setuptools.................done. [ngift@Macintosh-6][H:10998][J:0]> cd src/py24ENV [ngift@Macintosh-6][H:10999][J:0]> bin/easy_install grokproject
Question: Does it make sense two follow the easy-install example and make an entrypoint that corresponds to the python path?
Speaking of PATH, here is a wad of code I wrote to add a path in Win. If such a thing already exists, I couldn't find it. pretty much the 2 key lines are: SetValueEx(h, 'path', 0, REG_EXPAND_SZ, NewPath ) rc, dwReturnValue = win32gui.SendMessageTimeout(win32con.HWND_BROADCAST,.... Add it to the reg, use it now (otherwise it doesn't get used till you reboot.) Carl K # addtopath.py """ Adds the passed parameter to the windows PATH Checks to make sure the dir exists and is not already in the path. """ import sys import os from _winreg import * import win32gui, win32con if len(sys.argv)==1: # add the python dir to the path DirToAdd = os.path.dirname( sys.executable ) else: DirToAdd = os.path.abspath(sys.argv[1]) if not os.path.exists(DirToAdd): print "dir %s does not exist." % DirToAdd sys.exit(1) hive = HKEY_LOCAL_MACHINE key=r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment" subkey = 'Path' h = OpenKeyEx( hive, key, 0, KEY_READ ) curPath = QueryValueEx(h, subkey)[0] CloseKey(h) if DirToAdd in curPath.split(';'): print "dir %s already in current path:" % DirToAdd print curPath sys.exit(2) print "adding dir %s" % DirToAdd h = OpenKeyEx( hive, key, 0, KEY_SET_VALUE ) NewPath = curPath + ';' + DirToAdd SetValueEx(h, 'path', 0, REG_EXPAND_SZ, NewPath ) CloseKey(h) print "Path set to", NewPath rc, dwReturnValue = win32gui.SendMessageTimeout(win32con.HWND_BROADCAST, win32con.WM_SETTINGCHANGE, 0, "Environment", win32con.SMTO_ABORTIFHUNG, 5000) sys.exit(0)
participants (5)
-
Carl Karsten
-
Dave Peterson
-
Noah Gift
-
phil jones
-
Phillip J. Eby