Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Source code of Windows installer for Python interactive interpreter

Reply
Thread Tools

Source code of Windows installer for Python interactive interpreter

 
 
philip.a.molloy@gmail.com
Guest
Posts: n/a
 
      12-28-2012
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/
 
Reply With Quote
 
 
 
 
Andrew Berg
Guest
Posts: n/a
 
      12-28-2012
On 2012.12.28 09:30, http://www.velocityreviews.com/forums/(E-Mail Removed) 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
 
Reply With Quote
 
 
 
 
Dave Angel
Guest
Posts: n/a
 
      12-28-2012
On 12/28/2012 10:30 AM, (E-Mail Removed) 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

 
Reply With Quote
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      12-28-2012
On Fri, 28 Dec 2012 07:30:25 -0800 (PST), (E-Mail Removed)
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
(E-Mail Removed) HTTP://wlfraed.home.netcom.com/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running an interactive interpreter inside a python R. Bernstein Python 4 05-15-2008 07:07 PM
The Python interactive interpreter has no command history ThomasC Python 6 02-26-2007 03:49 PM
Python Interactive Interpreter Breakage Simon Eves Python 0 12-16-2006 12:07 AM
can distutils windows installer invoke another distutils windows installer timw.google Python 1 05-11-2006 10:07 PM
linux-python arrow-key problem when in interactive interpreter Gabriel Cooper Python 1 04-27-2004 08:05 PM



Advertisments