Source code of Windows installer for Python interactive interpreter

Discussion in 'Python' started by philip.a.molloy@gmail.com, Dec 28, 2012.

  1. Guest

    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/
    , Dec 28, 2012
    #1
    1. Advertising

  2. Andrew Berg Guest

    Re: Source code of Windows installer for Python interactiveinterpreter

    On 2012.12.28 09:30, 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
    Andrew Berg, Dec 28, 2012
    #2
    1. Advertising

  3. Dave Angel Guest

    Re: Source code of Windows installer for Python interactiveinterpreter

    On 12/28/2012 10:30 AM, 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
    Dave Angel, Dec 28, 2012
    #3
  4. Re: Source code of Windows installer for Python interactiveinterpreter

    On Fri, 28 Dec 2012 07:30:25 -0800 (PST),
    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
    HTTP://wlfraed.home.netcom.com/
    Dennis Lee Bieber, Dec 28, 2012
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gabriel Cooper
    Replies:
    1
    Views:
    972
    vincent wehren
    Apr 27, 2004
  2. timw.google
    Replies:
    1
    Views:
    527
    Serge Orlov
    May 11, 2006
  3. Simon Eves
    Replies:
    0
    Views:
    343
    Simon Eves
    Dec 16, 2006
  4. ThomasC
    Replies:
    6
    Views:
    353
  5. R. Bernstein
    Replies:
    4
    Views:
    725
    R. Bernstein
    May 15, 2008
Loading...

Share This Page