From 048c9763a8459ba3fcb007a2236d561e6e583aed Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 9 Nov 2013 23:57:34 +0000 Subject: [PATCH 1/3] Add failing test case for installing when there are symlinks to directories --- tests/data/packages/symlinks/doc/intro | 0 tests/data/packages/symlinks/docs | 1 + tests/data/packages/symlinks/setup.cfg | 3 +++ tests/data/packages/symlinks/setup.py | 8 ++++++++ tests/data/packages/symlinks/symlinks/__init__.py | 1 + tests/functional/test_install.py | 12 ++++++++++++ 6 files changed, 25 insertions(+) create mode 100644 tests/data/packages/symlinks/doc/intro create mode 120000 tests/data/packages/symlinks/docs create mode 100644 tests/data/packages/symlinks/setup.cfg create mode 100644 tests/data/packages/symlinks/setup.py create mode 100644 tests/data/packages/symlinks/symlinks/__init__.py diff --git a/tests/data/packages/symlinks/doc/intro b/tests/data/packages/symlinks/doc/intro new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/data/packages/symlinks/docs b/tests/data/packages/symlinks/docs new file mode 120000 index 00000000000..325ab0db62d --- /dev/null +++ b/tests/data/packages/symlinks/docs @@ -0,0 +1 @@ +doc \ No newline at end of file diff --git a/tests/data/packages/symlinks/setup.cfg b/tests/data/packages/symlinks/setup.cfg new file mode 100644 index 00000000000..01bb954499e --- /dev/null +++ b/tests/data/packages/symlinks/setup.cfg @@ -0,0 +1,3 @@ +[egg_info] +tag_build = dev +tag_svn_revision = true diff --git a/tests/data/packages/symlinks/setup.py b/tests/data/packages/symlinks/setup.py new file mode 100644 index 00000000000..b71e35f1e1e --- /dev/null +++ b/tests/data/packages/symlinks/setup.py @@ -0,0 +1,8 @@ +from setuptools import setup + +version = '0.1' + +setup(name='symlinks', + version=version, + packages=["symlinks"], + ) diff --git a/tests/data/packages/symlinks/symlinks/__init__.py b/tests/data/packages/symlinks/symlinks/__init__.py new file mode 100644 index 00000000000..792d6005489 --- /dev/null +++ b/tests/data/packages/symlinks/symlinks/__init__.py @@ -0,0 +1 @@ +# diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py index bf0ed96c6a2..4527c96f53a 100644 --- a/tests/functional/test_install.py +++ b/tests/functional/test_install.py @@ -208,6 +208,18 @@ def test_install_from_local_directory(script, data): assert egg_info_folder in result.files_created, str(result) +def test_install_from_local_directory_with_symlinks_to_directories(script, data): + """ + Test installing from a local directory containing symlinks to directories. + """ + to_install = data.packages.join("symlinks") + result = script.pip('install', to_install, expect_error=False) + pkg_folder = script.site_packages/'symlinks' + egg_info_folder = script.site_packages/'symlinks-0.1dev-py%s.egg-info' % pyversion + assert pkg_folder in result.files_created, str(result.stdout) + assert egg_info_folder in result.files_created, str(result) + + def test_install_from_local_directory_with_no_setup_py(script, data): """ Test installing from a local directory with no 'setup.py'. From f579c178bc206004ac332c38ed9155f6e58ccfd3 Mon Sep 17 00:00:00 2001 From: Steven Myint Date: Tue, 25 Jun 2013 20:43:30 -0700 Subject: [PATCH 2/3] Keep symlinks as symlinks when installing Without this, "pip install" crashes when encountering symlinks that point to external paths. The culprit is "shutil.copytree()", which throws an error in such cases if the "symlinks" parameter is not set to "True". This fixes #1006. --- pip/download.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pip/download.py b/pip/download.py index 73f7baa0c02..4f50795bf9e 100644 --- a/pip/download.py +++ b/pip/download.py @@ -359,7 +359,7 @@ def unpack_file_url(link, location): # delete the location since shutil will create it again :( if os.path.isdir(location): rmtree(location) - shutil.copytree(source, location) + shutil.copytree(source, location, symlinks=True) else: unpack_file(source, location, content_type, link) From 99a4f6f4e17a3a3643c1289b1306363943b766d5 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 10 Nov 2013 00:05:13 +0000 Subject: [PATCH 3/3] Add symlinks=True to copytree invocation so that tests pass in Python 3 --- tests/lib/path.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lib/path.py b/tests/lib/path.py index bbdcafa91e2..3bd608ddf97 100644 --- a/tests/lib/path.py +++ b/tests/lib/path.py @@ -264,7 +264,7 @@ def copytree(self, to): """ Copies a directory tree to another path. """ - return shutil.copytree(self, to) + return shutil.copytree(self, to, symlinks=True) def move(self, to): """