[Catalog-sig] Standardized way of getting to a package download URL in Cheeseshop
Phillip J. Eby
pje at telecommunity.com
Mon Nov 14 05:53:11 CET 2005
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 up
>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 it
>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. inside
>an egg.
>
>Is there a way I can tell setuptools what type of package I want it to
>download (e.g. "tar.gz" or "zip")? I guess I could find the answer to
>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 ignore
binary packages such as .egg and .exe.
More information about the Catalog-sig
mailing list