Commit 29a8e5dd authored by Gary Poster's avatar Gary Poster

Windows test fixes.

parent 35f81f2e
...@@ -32,12 +32,17 @@ if sys.platform == 'win32': ...@@ -32,12 +32,17 @@ if sys.platform == 'win32':
else: else:
quote = str quote = str
# Detect https://bugs.launchpad.net/virtualenv/+bug/572545 . # See zc.buildout.easy_install._has_broken_dash_S for motivation and comments.
proc = subprocess.Popen( stdout, stderr = subprocess.Popen(
[sys.executable, '-Sc', 'import ConfigParser'], [sys.executable, '-Sc',
stdout=subprocess.PIPE, stderr=subprocess.PIPE) 'try:\n'
proc.communicate() ' import ConfigParser\n'
has_broken_dash_S = bool(proc.returncode) '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 # 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 # run without site-packages loaded. This is somewhat tricky, in
......
...@@ -122,7 +122,7 @@ except ImportError: ...@@ -122,7 +122,7 @@ except ImportError:
env = os.environ.copy() # Windows needs yet-to-be-determined values from this. env = os.environ.copy() # Windows needs yet-to-be-determined values from this.
env['PYTHONPATH'] = os.path.dirname(pkg_resources.__file__) env['PYTHONPATH'] = os.path.dirname(pkg_resources.__file__)
cmd = [quote(sys.executable), cmd = [sys.executable,
'setup.py', '-q', 'develop', '-m', '-x', '-d', 'develop-eggs'] 'setup.py', '-q', 'develop', '-m', '-x', '-d', 'develop-eggs']
if not has_broken_dash_S: if not has_broken_dash_S:
......
...@@ -85,11 +85,22 @@ if os.path.normpath(setuptools_loc) != os.path.normpath(buildout_loc): ...@@ -85,11 +85,22 @@ if os.path.normpath(setuptools_loc) != os.path.normpath(buildout_loc):
def _has_broken_dash_S(executable): def _has_broken_dash_S(executable):
"""Detect https://bugs.launchpad.net/virtualenv/+bug/572545 .""" """Detect https://bugs.launchpad.net/virtualenv/+bug/572545 ."""
proc = subprocess.Popen( # The first attempt here was to simply have the executable attempt to import
[executable, '-Sc', 'import ConfigParser'], # ConfigParser and return the return code. That worked except for tests on
stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Windows, where the return code was wrong for the fake Python executable
proc.communicate() # generated by the virtualenv.txt test, apparently because setuptools' .exe
return bool(proc.returncode) # 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): def _get_system_paths(executable):
"""Return lists of standard lib and site paths for executable. """Return lists of standard lib and site paths for executable.
......
...@@ -4150,6 +4150,10 @@ def test_suite(): ...@@ -4150,6 +4150,10 @@ def test_suite():
'setuptools.egg'), 'setuptools.egg'),
(re.compile('zc.buildout-\S+-'), (re.compile('zc.buildout-\S+-'),
'zc.buildout.egg'), '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.
]), ]),
)) ))
......
...@@ -43,11 +43,17 @@ behavior as the problematic one we care about from virtualenv. Let's do that ...@@ -43,11 +43,17 @@ behavior as the problematic one we care about from virtualenv. Let's do that
first. first.
>>> import os, sys >>> import os, sys
>>> from zc.buildout.easy_install import _safe_arg
>>> py_path, site_packages_path = make_py() >>> 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_lines = py_file.readlines()
>>> py_file.close() >>> py_file.close()
>>> py_file = open(py_path, 'w') >>> py_file = open(py_script_path, 'w')
>>> extra = '''\ >>> extra = '''\
... new_argv = argv[:1] ... new_argv = argv[:1]
... for ix, val in enumerate(argv[1:]): ... for ix, val in enumerate(argv[1:]):
...@@ -109,11 +115,11 @@ first. ...@@ -109,11 +115,11 @@ first.
... ''' % (py_path,)) ... ''' % (py_path,))
>>> sitecustomize_file.close() >>> sitecustomize_file.close()
>>> print call_py( >>> print call_py(
... py_path, ... _safe_arg(py_path),
... "import ConfigParser") ... "import ConfigParser")
<BLANKLINE> <BLANKLINE>
>>> print 'X'; print call_py( >>> print 'X'; print call_py(
... py_path, ... _safe_arg(py_path),
... "import ConfigParser", ... "import ConfigParser",
... '-S') # doctest: +ELLIPSIS ... '-S') # doctest: +ELLIPSIS
X...Traceback (most recent call last): X...Traceback (most recent call last):
...@@ -152,7 +158,7 @@ First, let's try running bootstrap. ...@@ -152,7 +158,7 @@ First, let's try running bootstrap.
... ''') ... ''')
>>> write('bootstrap.py', open(bootstrap_py).read()) >>> write('bootstrap.py', open(bootstrap_py).read())
>>> print 'X'; print system( >>> print 'X'; print system(
... zc.buildout.easy_install._safe_arg(py_path)+' '+ ... _safe_arg(py_path)+' '+
... 'bootstrap.py'); print 'X' # doctest: +ELLIPSIS ... 'bootstrap.py'); print 'X' # doctest: +ELLIPSIS
X... X...
Generated script '/broken_S/bin/buildout'. Generated script '/broken_S/bin/buildout'.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment