diff options
author | Adam Sampson <ats-github@offog.org> | 2018-12-19 10:51:54 +0000 |
---|---|---|
committer | Bernát Gábor <gaborjbernat@gmail.com> | 2018-12-19 10:51:54 +0000 |
commit | 89c734bac9b4d5621fa665e86de2c79549bb50e5 (patch) | |
tree | 628145d817fa2dc0916316debb13217abe8bbe13 | |
parent | 27adc7695ed0876400d2426ba094926daca0174e (diff) | |
download | virtualenv-89c734bac9b4d5621fa665e86de2c79549bb50e5.tar.gz |
Use os.path.realpath to resolve the symlink. (#1259)
This simplifies the code; it's still covered by the test I added for #956.
Thanks to @lilydjwg for the suggestion!
-rwxr-xr-x | src/virtualenv.py | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/src/virtualenv.py b/src/virtualenv.py index dd352d8..87822dd 100755 --- a/src/virtualenv.py +++ b/src/virtualenv.py @@ -398,14 +398,10 @@ def copyfile(src, dest, symlink=True): if not os.path.exists(os.path.dirname(dest)): logger.info("Creating parent directories for %s", os.path.dirname(dest)) os.makedirs(os.path.dirname(dest)) - srcpath = src - while os.path.islink(srcpath): - srcpath = os.path.join(os.path.dirname(srcpath), os.readlink(srcpath)) - srcpath = os.path.abspath(srcpath) if symlink and hasattr(os, "symlink") and not is_win: logger.info("Symlinking %s", dest) try: - os.symlink(srcpath, dest) + os.symlink(os.path.realpath(src), dest) except (OSError, NotImplementedError): logger.info("Symlinking failed, copying to %s", dest) copyfileordir(src, dest, symlink) |