Mark Mc Mahon wrote:
> On 11/16/05, Phillip J. Eby <[EMAIL PROTECTED]> wrote:
> >
> > At 01:19 PM 11/16/2005 -0500, Phillip J. Eby wrote:
> > >At 10:17 PM 11/15/2005 -0600, Ian Bicking wrote:
> > > >[EMAIL PROTECTED] wrote:
> > > > > Perhaps this has been mentioned already. So, forgive me if it has.
> > > > >
> > > > > I install Python into 'C:/Program Files/Python24' as I do not like to
> > > > > clutter up the C:/ portion of my file system. After installing
> > > > > turbogears and trying to begin the tutorial, I get the below error 
> > > > > when
> > > > > I do this 'tg-admin quickstart':
> > > > >
> > > > > Program: can't open file 'Files\Python24\python.exe' : [Error 2] No
> > > > > such file or directory
> > > > >
> > > > > The same thing happens when I try to run easy_install.exe
> > > > >
> > > > > The .py versions of tg-admin and easy_install work fine... it's just
> > > > > the .exe versions that crash. I have named this the 'hard-coded python
> > > > > path bug'.
> > >
> > >Actually, it's not hardcoding that's the issue.  It's that something
> > >somewhere is using spaces to parse the #! line.  I'll look into this, as
> > >I'm not sure whether it's in the setuptools #! line code, or in the .exe's
> > >#! parser.
> >
> > Okay, it's more subtle than that.  The problem is that something about how
> > Python is spawned by the launcher, is causing Python to think that the
> > space in its filename means that the part after the space is an
> > argument.  (I'd like to have an argument, please!)  So I'm not quite sure
> > how to fix it, exactly, particularly because I don't know if it's Python
> > that's the problem, or the way the launcher is invoking Python.  :(
> >
>
> I would guess that you have already looked at this but could it be
> something as simple as putting inverted comma's around the command
> line?
>
> c:\Program Files\Python24\Python.exe -> "c:\Program Files\Python24\Python.exe"

I tried various ways of doing that in the .exe, and none of them
worked.


> Another alternative if you don't figure out another way is to use
> GetShortPathName
> (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/getshortpathname.asp)
> but that is of course very platform specific - so maybe not what you
> want.

No, it's probably exactly what I want.  I believe that the issue has to
do with Windows' command-line processing.  I'm using execv and/or
spawnv in the .exe launchers, and I think that what's happening is
Python doesn't receive exactly the same arguments as I pass it; some
part of Windows or Python is re-parsing the command line, turning it
into:

   "C:\Program" "Files\Python24\Python.exe"

Python then thinks its name is "Program", and that it's supposed to run
a Python script called "Files\Python24\Python.exe"!  I'm able to
reproduce this behavior.

Probably the issue here is that I need to be using some Windows API to
invoke Python instead of execv/spawnv, in order to prevent the command
line from being re-parsed.  :(
Failing that, using the short name API might be the best workaround,
although technically I believe a short name can have a space in it too!
 It's just not as likely to.

Reply via email to