Skip to content

Fix unpack directory contains symlinks on py3k #813

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

Closed
wants to merge 1 commit into from
Closed

Fix unpack directory contains symlinks on py3k #813

wants to merge 1 commit into from

Conversation

alquerci
Copy link

Q A
Bug fix? yes
New feature? no
BC breaks? no
Tests pass? yes
Fixed tickets #611
License MIT

Hello,

On python3 installation fail when the source directory contains symlinks.
See: https://api.travis-ci.org/jobs/4900020/log.txt?deansi=true

Before apply this fix tests fails on py32 and py33. https://travis-ci.org/alquerci/pip/builds/4980091

Symbolic links are not followed.


exc = None;

try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A try with run_pip() and finally with the removes looks better, and no except statement, like other tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed

@alquerci
Copy link
Author

After reading issues list I've seen this PR fix #611

shutil.copytree(source, location)
# The py3k version of `shutil.copytree` fails when symlinks point on
# directories. So `symlinks` argument must be True
shutil.copytree(source, location, symlinks=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does symlinks=True work on Windows? Specifically, I assume copytree doesn't fail if symlinks=True is set, and if symlinks are present, what is the behaviour? Note that creating symlinks on Windows requires an elevated process, which most Python processes won't be...

Symlinks on Windows are rare, so the main issue here is that this change doesn't stop the normal (non-symlink) case working on Windows.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shutil.copytree on py2
http://hg.python.org/cpython/file/2.7/Lib/shutil.py#l145

shutil.copytree on py3
http://hg.python.org/cpython/file/3.3/Lib/shutil.py#l259

The shutil.copytree function on py3 don't care about if the file pointed by a symlink is a directory or a file. It passed to copy_function (copy2 by default) and so fails with a directory.

symlinks=True is same as follow_symlinks=False

With this fix all symlinks on the source directory are not followed. It break the current behaviour indeed. So for keep the current behaviour we need to do that: alquerci@66a0cef2e11fe1f057c68ba716a55978b0e982ec

What is the better behaviour in your mind?

@qwcode
Copy link
Contributor

qwcode commented Nov 13, 2013

closing this, so we can focus on #1311 .
I know this one came before, but the test suite has changed, and that one has a compliant test.

@qwcode qwcode closed this Nov 13, 2013
@alquerci alquerci deleted the fix_unpack_file_url branch November 4, 2014 12:39
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants