Fails to install on Windows

Create issue
Issue #49 resolved
Jason R. Coombs created an issue

Using from fails on windows in python_cmd due to command escaping errors.

Using from hg trunk results in the following error:

{{{ PS C:\Users\jaraco\Desktop> .\ Traceback (most recent call last): File "C:\Users\jaraco\Desktop\", line 244, in <module> main(sys.argv[1:]) File "C:\Users\jaraco\Desktop\", line 192, in main pkg_resources.require(req) File "build\bdist.win32\egg\", line 626, in require File "build\bdist.win32\egg\", line 524, in resolve pkg_resources.DistributionNotFound: distribute>=0.6 }}}

I was going to suggest a patch for the 0.6.1 issue, but it appears the has changed significantly since that release. Any suggestions on getting distribute running on Windows? How can I help?

Comments (6)

  1. Jason R. Coombs reporter

    The dev script has the same issue as the released version.

    The error is:

    PS C:\Users\jaraco\Desktop> .\
    Extracting in c:\users\jaraco\appdata\local\temp\tmp0grgax
    Now working in c:\users\jaraco\appdata\local\temp\tmp0grgax\distribute-0.6.2dev
    Installing Distribute
    C:\Python\python.exe: can't open file ' install': [Errno 2] No such file or directory
    Traceback (most recent call last):
      File "C:\Users\jaraco\Desktop\", line 413, in <module>
      File "C:\Users\jaraco\Desktop\", line 410, in main
      File "C:\Users\jaraco\Desktop\", line 64, in _install
        assert python_cmd(' install')

    The problem is in python_cmd where the full command-line is first quoted, then split.

    def python_cmd(cmd):
        python = quote(sys.executable)
        cmd = quote(cmd)
        if IS_JYTHON:
            return subprocess.Popen([python, cmd]).wait() == 0
        args = [os.P_WAIT, python, python] + cmd.split() + [os.environ]
        return os.spawnle(*args) == 0

    I noticed that you're already importing subprocess, which is very robust under Windows. I suggest you replace the quote and python_cmd functions with the following.

    def python_cmd(cmd):
        python = sys.executable
        if isinstance(cmd, basestring):
            cmd = cmd.split()
        return subprocess.Popen([python] + cmd).wait() == 0

    I've tested this fix in my environment, and now distribute_setup_dev completed successfully.

    If you want to maintain Python 2.3 compatibility (which I'm guesing you don't because you're already importing subprocess), you can co-opt the list2cmdline from Python 2.5, and then use that instead of quote before calling POpen. If you're interested in this option, let me know; I'm happy to implement it.

    Cheers Jason

  2. Tarek Ziadé repo owner

    I first thaught py3 support was making it impossible to keep 2.3, but in seems not, so yes please go ahead !

    I can add you to the commiters for conveniency if you want, let me know

  3. Jason R. Coombs reporter

    Thanks for fixing this. I'm on vacation, so taking some time getting up to speed with Mercurial tags. I'm still happy to restore Python 2.3 compatibility and I'm grateful for the offer for commit access. Yes, please add me to the commiters list. I'll be respectful of the code base and will limit any commits to minor changes until some credibility has been earned.

  4. Tarek Ziadé repo owner

    we had a mini-sprint tonite, we took car of if to speed up the release of 0.6.2

    I have added you in the commiters for your next contribution ;) thanks !

  5. Log in to comment