buildout fails to when the value of the buildout:executable is with POSIX-style path seperator

Bug #771811 reported by Guy Rozendorn
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Buildout
New
Undecided
Unassigned

Bug Description

Consider the following environment:
* Running Python 2.6 on Windows
* Changing the default value of ${buildout:executable} to path/to/python.

When running bin\buildout.exe, its crashes in zc.buildout.easy_install._get_version:
line 190, in _get_version
    pystring, version = version.split()
ValueError: need more than 0 values to unpack

This is because the Python process was not executed, because the file-path is in a bad format:
The POSIX-style path separators ('\n') should be replaced to sys.path.sep (and not just '\\', in order to support localized versions of Windows).

Revision history for this message
Guy Rozendorn (guy-rozendorn) wrote :

attaching a suggestion for patch for this issue.
this patch is post to the latter patch i suggested for issue #449262.

Revision history for this message
Guy Rozendorn (guy-rozendorn) wrote :

had a syntax error in the previous patch, sorry :)

Revision history for this message
Guy Rozendorn (guy-rozendorn) wrote :

Hi,

A month has passed since I uploaded the patch.
Can someone please review it and merge it to the source?

Revision history for this message
Jim Fulton (jim-zope) wrote :

This patch seems to address more than just the executable problem.

I'm unclear under what situations the problem would occur.
This would probably be clarified by test that's missing from the patch. :)

Please provide a test that illustrates the problem and tests the patch.

Revision history for this message
Guy Rozendorn (guy-rozendorn) wrote :

The patch also includes the patch of #449262. If there was a pull/push request mechanism like in github, you would've seen that.

Anyway, the changeset for this specific issue is:

--- a/src/zc/buildout/easy_install.py
+++ b/src/zc/buildout/easy_install.py
@@ -92,7 +92,7 @@ def _has_broken_dash_S(executable):
     # file does not pass the -script.py's returncode back properly, at least in
     # some circumstances. Therefore...print statements.
     stdout, stderr = subprocess.Popen(
- [executable, '-S', '-c',
+ [executable.replace('/', os.path.sep), '-S', '-c',
          'try:\n'
          ' import ConfigParser\n'
          'except ImportError:\n'
@@ -125,7 +125,7 @@ def _get_system_paths(executable):
     # the context of code that has manipulated the sys.path--for
     # instance, to add local zc.buildout or setuptools eggs.
     def get_sys_path(*args, **kwargs):
- cmd = [executable]
+ cmd = [executable.replace('/', os.path.sep)]
         cmd.extend(args)
         cmd.extend([
             "-c", "import sys, os;"
@@ -155,11 +155,11 @@ def _get_system_paths(executable):
     return (stdlib, site_paths)

 def _get_version_info(executable):
- cmd = [executable, '-Sc',
+ cmd = [executable.replace('/', os.path.sep), '-Sc',
            'import sys; print(repr(tuple(x for x in sys.version_info)))']
     _proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- stdout, stderr = _proc.communicate();
+ stdout, stderr = _proc.communicate()
     if _proc.returncode:
         raise RuntimeError(
             'error trying to get system packages:\n%s' % (stderr,))
@@ -412,7 +412,7 @@ class Installer:
             links.insert(0, self._download_cache)

         self._index_url = index
- self._executable = executable
+ self._executable = executable.replace('/', os.path.sep)
         self._has_broken_dash_S = _has_broken_dash_S(self._executable)
         if always_unzip is not None:
             self._always_unzip = always_unzip

@@ -1636,7 +1636,7 @@ def _get_module_file(executable, name, silent=False):
     - executable is a path to the desired Python executable.
     - name is the name of the (pure, not C) Python module.
     """
- cmd = [executable, "-Sc",
+ cmd = [executable.replace('/', os.path.sep), "-Sc",
            "import imp; "
            "fp, path, desc = imp.find_module(%r); "
            "fp.close(); "

Revision history for this message
Guy Rozendorn (guy-rozendorn) wrote :

a) the description is pretty much clear on when this happens: use /some/posix/style/path for the executable on windows.
b) i'm not sure that it is feasible to have a tests for this that fails on posix system, so I would make this test skip on non-windows systems
c) I'm not familiar with the tests style. don't you use nose? how do you run the tests?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.