Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autodetect if symlinks are supported on target file system #663

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,27 @@ def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, sy
## Maybe it should delete everything with #!/path/to/venv/python in it
logger.notify('Not deleting %s', bin_dir)

# Check if symlinks are really supported by destination filesystem
if symlink:
if not hasattr(os, 'symlink'):
symlink = False
logger.info('Symlinks are not supported in this Python version')
else:
name = join(home_dir + '.symlink.test.file')
open(name, 'w').close()
try:
os.symlink(name, name + '.link')
except OSError as exc:
if exc.errno == 71: # [Errno 71] Protocol error
symlink = False
logger.notify('Symlinks are not supported on target file system')
else:
raise
else:
os.remove(name + '.link')
finally:
os.remove(name)

if hasattr(sys, 'real_prefix'):
logger.notify('Using real prefix %r' % sys.real_prefix)
prefix = sys.real_prefix
Expand All @@ -1115,7 +1136,7 @@ def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, sy
stdlib_dirs.append(join(os.path.dirname(stdlib_dirs[0]), 'DLLs'))
elif is_darwin:
stdlib_dirs.append(join(stdlib_dirs[0], 'site-packages'))
if hasattr(os, 'symlink'):
if symlink:
logger.info('Symlinking Python bootstrap modules')
else:
logger.info('Copying Python bootstrap modules')
Expand Down