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

--always-copy - do not use symlinks even when on supporting system #402

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
20 changes: 17 additions & 3 deletions virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def mkdir(path):

def copyfileordir(src, dest):
if os.path.isdir(src):
shutil.copytree(src, dest, True)
shutil.copytree(src, dest, not always_copy)
else:
shutil.copy2(src, dest)

Expand Down Expand Up @@ -905,11 +905,21 @@ def main():
dest='prompt',
help='Provides an alternative prompt prefix for this environment')

parser.add_option(
'--always-copy',
action='count',
dest='always_copy',
default=0,
help="Always copy files instead of symlink")

if 'extend_parser' in globals():
extend_parser(parser)

options, args = parser.parse_args()

global always_copy
always_copy = options.always_copy

global logger

if 'adjust_options' in globals():
Expand Down Expand Up @@ -1496,7 +1506,10 @@ def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear):
full_pth = join(bin_dir, pth)
if os.path.exists(full_pth):
os.unlink(full_pth)
os.symlink(py_executable_base, full_pth)
if always_copy:
copyfile(os.path.join(bin_dir, py_executable_base), full_pth)
else:
os.symlink(py_executable_base, full_pth)

if is_win and ' ' in py_executable:
# There's a bug with subprocess on Windows when using a first
Expand Down Expand Up @@ -1627,7 +1640,8 @@ def fix_local_scheme(home_dir):
for subdir_name in os.listdir(home_dir):
if subdir_name == 'local':
continue
os.symlink(os.path.abspath(os.path.join(home_dir, subdir_name)), \
cmd = (copyfile if always_copy else os.symlink)
cmd(os.path.abspath(os.path.join(home_dir, subdir_name)), \
os.path.join(local_path, subdir_name))

def fix_lib64(lib_dir):
Expand Down