Source code of Windows installer for Python interactive interpreter

P

philip.a.molloy

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/
 
D

Dave Angel

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.
 
D

Dennis Lee Bieber

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top