![]() |
Source code of Windows installer for Python interactive interpreter
I am writing a command-line application for Windows. I would like to reviewthe Python source code to find out how to install my application so that it doesn't have to be called using the path and file name (i.e. being able to type `python` into the Command prompt, instead of `C:\path\to\executable\python.exe`). How does Python achieve this?
Is the Python directory (i.e. "C:\Python33") assigned to the PATH variable using the Batch PATH built-in command? If so, where? The Python language source code[1] includes two seemingly relevant directories, `PC` and `PCbuild`. Otherwise I'm lost. This is likely a very simple statement buried in the complex Python source code. Thanks, Phil [1]: http://www.python.org/download/releases/ |
Re: Source code of Windows installer for Python interactiveinterpreter
On 2012.12.28 09:30, philip.a.molloy@gmail.com wrote:
> Is the Python directory (i.e. "C:\Python33") assigned to the PATH variable using the Batch PATH built-in command? If so, where? As of Python 3.3, there is a py.exe in the system32 directory that launches the appropriate version of Python for your application if you specify one in a shebang line. http://www.python.org/dev/peps/pep-0397/ -- CPython 3.3.0 | Windows NT 6.2.9200.16461 |
Re: Source code of Windows installer for Python interactiveinterpreter
On 12/28/2012 10:30 AM, philip.a.molloy@gmail.com wrote:
> I am writing a command-line application for Windows. I would like to review the Python source code to find out how to install my application so that it doesn't have to be called using the path and file name (i.e. being able to type `python` into the Command prompt, instead of `C:\path\to\executable\python.exe`). How does Python achieve this? I use linux, ubuntu. But I help others that use Windows, when necessary. Last time I installed python from python.org on a Windows machine (years ago), it didn't do such niceties for me. For that and other reasons, I switched to using the (free) version from ActiveState. It has a number of Windows extensions, and one of the extensions was actually fixing the path and the registry so that Python was directly available at the command line. That all could have changed, of course. But I'm assuming you just want to fix Windows, not somehow duplicate whatever the installer didn't do? Take a look in your install directory, same one that python.exe is located in, and see if there is a batch file there, and whether it knows where to find Python.exe. If so, just copy that to somewhere on your PATH, and you should be golden. I always had a c:\bat directory on my PATH for other purposes, so that was a perfect place to put it. > Is the Python directory (i.e. "C:\Python33") assigned to the PATH variable using the Batch PATH built-in command? If so, where? That's another option. Of course, if everyone did that, the PATH could get mighty long. And describing how to change the PATH globally is tricky, since Microsoft seems to change it with every release of Windows. If you were trying to do that programmatically, there is a registry entry somewhere. And if I needed to find the right registry entry, I'd put a weird directory name into the PATH the official way, then use regedit and F3 to search for the weird name. -- DaveA |
Re: Source code of Windows installer for Python interactiveinterpreter
On Fri, 28 Dec 2012 07:30:25 -0800 (PST), philip.a.molloy@gmail.com
declaimed the following in gmane.comp.python.general: > I am writing a command-line application for Windows. I would like to review the Python source code to find out how to install my application so that it doesn't have to be called using the path and file name (i.e. being able to type `python` into the Command prompt, instead of `C:\path\to\executable\python.exe`). How does Python achieve this? > Python DOESN'T... The Windows registry controls that... Through a convoluted double lookup... E:\UserData\Wulfraed\My Documents>assoc .py ..py=Python.File E:\UserData\Wulfraed\My Documents>ftype Python.File Python.File="E:\Python27\python.exe" "%1" %* E:\UserData\Wulfraed\My Documents> The ASSOC shows what internal "type" the specific file extension is associated with; the FTYPE shows what command line is used to execute a file of the specified "type". E:\UserData\Wulfraed\My Documents>echo %pathext% ..COM;.EXE;.BAT;.pyw;.py;.pyo;.pyc;.CMD;.VBS;.VBE; .JS;.JSE;.WSF;.WSH;.tcl;.PSC1 The PATHEXT environment variable defines what file extensions are to be considered "executable" programs (and hence, do not need to have the extension specified when entering the program name on the command line) PATH environment is used to locate the interpreter when all one has typed is the interpreter name (ie; python) on the command line. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/ |
| All times are GMT. The time now is 03:42 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.