Test that we have an executable *file*
Fixes #939
diff --git a/virtualenv.py b/virtualenv.py
index 4d4ab55..b482dc7 100755
--- a/virtualenv.py
+++ b/virtualenv.py
@@ -1547,6 +1547,7 @@
"""
# If the "executable" is a version number, get the installed executable for
# that version
+ orig_exe = exe
python_versions = get_installed_pythons()
if exe in python_versions:
exe = python_versions[exe]
@@ -1558,16 +1559,16 @@
exe = join(path, exe)
break
if not os.path.exists(exe):
- logger.fatal('The executable %s (from --python=%s) does not exist' % (exe, exe))
+ logger.fatal('The path %s (from --python=%s) does not exist' % (exe, orig_exe))
raise SystemExit(3)
if not is_executable(exe):
- logger.fatal('The executable %s (from --python=%s) is not executable' % (exe, exe))
+ logger.fatal('The path %s (from --python=%s) is not an executable file' % (exe, orig_exe))
raise SystemExit(3)
return exe
def is_executable(exe):
"""Checks a file is executable"""
- return os.access(exe, os.X_OK)
+ return os.path.isfile(exe) and os.access(exe, os.X_OK)
############################################################
## Relocating the environment: