[Checkins] SVN: zc.buildout/branches/gary-betafix/ Windows test fixes.

Gary Poster gary.poster at canonical.com
Thu Aug 5 18:57:18 EDT 2010


Log message for revision 115514:
  Windows test fixes.

Changed:
  U   zc.buildout/branches/gary-betafix/bootstrap/bootstrap.py
  U   zc.buildout/branches/gary-betafix/dev.py
  U   zc.buildout/branches/gary-betafix/src/zc/buildout/easy_install.py
  U   zc.buildout/branches/gary-betafix/src/zc/buildout/tests.py
  U   zc.buildout/branches/gary-betafix/src/zc/buildout/virtualenv.txt

-=-
Modified: zc.buildout/branches/gary-betafix/bootstrap/bootstrap.py
===================================================================
--- zc.buildout/branches/gary-betafix/bootstrap/bootstrap.py	2010-08-05 21:30:54 UTC (rev 115513)
+++ zc.buildout/branches/gary-betafix/bootstrap/bootstrap.py	2010-08-05 22:57:17 UTC (rev 115514)
@@ -32,12 +32,17 @@
 else:
     quote = str
 
-# Detect https://bugs.launchpad.net/virtualenv/+bug/572545 .
-proc = subprocess.Popen(
-    [sys.executable, '-Sc', 'import ConfigParser'],
-    stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-proc.communicate()
-has_broken_dash_S = bool(proc.returncode)
+# See zc.buildout.easy_install._has_broken_dash_S for motivation and comments.
+stdout, stderr = subprocess.Popen(
+    [sys.executable, '-Sc',
+     'try:\n'
+     '    import ConfigParser\n'
+     'except ImportError:\n'
+     '    print 1\n'
+     'else:\n'
+     '    print 0\n'],
+    stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
+has_broken_dash_S = bool(int(stdout.strip()))
 
 # In order to be more robust in the face of system Pythons, we want to
 # run without site-packages loaded.  This is somewhat tricky, in

Modified: zc.buildout/branches/gary-betafix/dev.py
===================================================================
--- zc.buildout/branches/gary-betafix/dev.py	2010-08-05 21:30:54 UTC (rev 115513)
+++ zc.buildout/branches/gary-betafix/dev.py	2010-08-05 22:57:17 UTC (rev 115514)
@@ -122,7 +122,7 @@
 env = os.environ.copy() # Windows needs yet-to-be-determined values from this.
 env['PYTHONPATH'] = os.path.dirname(pkg_resources.__file__)
 
-cmd = [quote(sys.executable),
+cmd = [sys.executable,
        'setup.py', '-q', 'develop', '-m', '-x', '-d', 'develop-eggs']
 
 if not has_broken_dash_S:

Modified: zc.buildout/branches/gary-betafix/src/zc/buildout/easy_install.py
===================================================================
--- zc.buildout/branches/gary-betafix/src/zc/buildout/easy_install.py	2010-08-05 21:30:54 UTC (rev 115513)
+++ zc.buildout/branches/gary-betafix/src/zc/buildout/easy_install.py	2010-08-05 22:57:17 UTC (rev 115514)
@@ -85,11 +85,22 @@
 
 def _has_broken_dash_S(executable):
     """Detect https://bugs.launchpad.net/virtualenv/+bug/572545 ."""
-    proc = subprocess.Popen(
-        [executable, '-Sc', 'import ConfigParser'],
-        stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-    proc.communicate()
-    return bool(proc.returncode)
+    # The first attempt here was to simply have the executable attempt to import
+    # ConfigParser and return the return code. That worked except for tests on
+    # Windows, where the return code was wrong for the fake Python executable
+    # generated by the virtualenv.txt test, apparently because setuptools' .exe
+    # file does not pass the -script.py's returncode back properly, at least in
+    # some circumstances. Therefore...print statements.
+    stdout, stderr = subprocess.Popen(
+        [executable, '-Sc',
+         'try:\n'
+         '    import ConfigParser\n'
+         'except ImportError:\n'
+         '    print 1\n'
+         'else:\n'
+         '    print 0\n'],
+        stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
+    return bool(int(stdout.strip()))
 
 def _get_system_paths(executable):
     """Return lists of standard lib and site paths for executable.

Modified: zc.buildout/branches/gary-betafix/src/zc/buildout/tests.py
===================================================================
--- zc.buildout/branches/gary-betafix/src/zc/buildout/tests.py	2010-08-05 21:30:54 UTC (rev 115513)
+++ zc.buildout/branches/gary-betafix/src/zc/buildout/tests.py	2010-08-05 22:57:17 UTC (rev 115514)
@@ -4150,6 +4150,10 @@
                  'setuptools.egg'),
                 (re.compile('zc.buildout-\S+-'),
                  'zc.buildout.egg'),
+                (re.compile(re.escape('#!"/executable_buildout/bin/py"')),
+                 '#!/executable_buildout/bin/py'), # Windows.
+                (re.compile(re.escape('/broken_s/')),
+                 '/broken_S/'), # Windows.
                 ]),
             ))
 

Modified: zc.buildout/branches/gary-betafix/src/zc/buildout/virtualenv.txt
===================================================================
--- zc.buildout/branches/gary-betafix/src/zc/buildout/virtualenv.txt	2010-08-05 21:30:54 UTC (rev 115513)
+++ zc.buildout/branches/gary-betafix/src/zc/buildout/virtualenv.txt	2010-08-05 22:57:17 UTC (rev 115514)
@@ -43,11 +43,17 @@
 first.
 
     >>> import os, sys
+    >>> from zc.buildout.easy_install import _safe_arg
     >>> py_path, site_packages_path = make_py()
-    >>> py_file = open(py_path)
+    >>> if sys.platform == 'win32':
+    ...     py_script_path = py_path + '-script.py'
+    ... else:
+    ...     py_script_path = py_path
+    ...
+    >>> py_file = open(py_script_path)
     >>> py_lines = py_file.readlines()
     >>> py_file.close()
-    >>> py_file = open(py_path, 'w')
+    >>> py_file = open(py_script_path, 'w')
     >>> extra = '''\
     ... new_argv = argv[:1]
     ... for ix, val in enumerate(argv[1:]):
@@ -109,11 +115,11 @@
     ... ''' % (py_path,))
     >>> sitecustomize_file.close()
     >>> print call_py(
-    ...     py_path,
+    ...     _safe_arg(py_path),
     ...     "import ConfigParser")
     <BLANKLINE>
     >>> print 'X'; print call_py(
-    ...     py_path,
+    ...     _safe_arg(py_path),
     ...     "import ConfigParser",
     ...     '-S') # doctest: +ELLIPSIS
     X...Traceback (most recent call last):
@@ -152,7 +158,7 @@
     ... ''')
     >>> write('bootstrap.py', open(bootstrap_py).read())
     >>> print 'X'; print system(
-    ...     zc.buildout.easy_install._safe_arg(py_path)+' '+
+    ...     _safe_arg(py_path)+' '+
     ...     'bootstrap.py'); print 'X' # doctest: +ELLIPSIS
     X...
     Generated script '/broken_S/bin/buildout'.



More information about the checkins mailing list