Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
`--download` fails when using local `--find-links` #1111
As discovered in #1107,
you get no error, but you get the contents of the archive dumped into the download dir, and not the archive.
Maybe we shouldn't support this, and just raise a command error saying the options are incompatible. It's odd in the first place to want to download from a local store.
+1 for supporting --download with local --find-links.
Here is my actual use case: I want to download all of the requirements of a Python application using a pip command and the requirements.txt for that application. Some of the requirements are available on PyPI, but others are available locally, in a sub-directory named "local".
Contents of my requirements.txt:
Contents of my "local" sub-directory:
(acpython-1.3.tar.gz is a source tarball created using "python setup.py sdist".)
Afterwards, the download directory contains the downloaded python-glanceclient and python-novaclient .tar.gz files, but also the extracted contents of acpython, which is not helpful.
Here is the result of my investigation. I hope this is helpful.
Pip unpacks every package and looks at its egg info, even when you are just trying to download. When you are only downloading, pip creates a temporary directory for each package, into which it tries to unpack the downloaded package, so that it can look at its egg info. So far, so good.
The problem is that the unpack method behaves differently depending on whether the package was downloaded from a file url or from an http url. See the unpack_url() method:
def unpack_url(self, link, location, only_download=False): if only_download: loc = self.download_dir else: loc = location if is_vcs_url(link): return unpack_vcs_link(link, loc, only_download) # a local file:// index could have links with hashes elif not link.hash and is_file_url(link): return unpack_file_url(link, loc) else: if self.download_cache: self.download_cache = os.path.expanduser(self.download_cache) retval = unpack_http_url(link, location, self.download_cache, self.download_dir) if only_download: write_delete_marker_file(location) return retval
In my case, this method is called with:
For some reason, if only_download is true, unpack_url() chooses to ignore the location parameter, and the file is unpacked into the download directory instead of into the temp directory that pip just created.
pip fails after it returns from this method, because the later code that gets the egg info expects the unpacked contents to be in the temp directory, not in the download directory.
referenced this issue
Sep 26, 2013
Also, to address the question of use-cases: this is important for