[Catalog-sig] Standardized way of getting to a package download URL in Cheeseshop
grig at gheorghiu.net
Mon Nov 14 06:50:18 CET 2005
--- "Phillip J. Eby" <pje at telecommunity.com> wrote:
> At 08:22 PM 11/13/2005 -0800, Grig Gheorghiu wrote:
> >My immediate goal is to download a package in a "sandbox" directory,
> >unpack it and examine its files and directories.
> >I found a way to download a package using setuptools by looking it
> >on PyPI by its "short" name (e.g. "funkload"). I do this in my code:
> >from setuptools.package_index import PackageIndex
> >pkgindex = PackageIndex()
> >output = pkgindex.download(name, sandbox)
> >This works just fine, but PackageIndex downloads the first package
> >finds -- which in many cases is an egg file. The problem with egg
> >packages is that they don't contain the source distribution, so my
> >Cheesecake module doesn't find docs, tests, special files, etc.
> >an egg.
> >Is there a way I can tell setuptools what type of package I want it
> >download (e.g. "tar.gz" or "zip")? I guess I could find the answer
> >this question myself by poring some more over the setuptools source
> >code, but if you know the answer already, I'd appreciate it!
> Use the 'fetch()' method instead of 'download()'. You will need a
> Requirement object, e.g.:
> from pkg_resources import Requirement
> output = pkgindex.fetch(Requirement.parse(name), sandbox,
> force_scan=True, source=True)
> 'force_scan' tells the index to check PyPI even if there's a
> locally-availablepackage of the given name. 'source' tells it to
> binary packages such as .egg and .exe.
Thanks a lot for the prompt answer, your solution worked beautifully.
More information about the Catalog-sig