[Distutils] [setuptools] Sophisticated package requirements

Phillip J. Eby pje at telecommunity.com
Mon Aug 7 00:10:40 CEST 2006


At 08:18 PM 8/4/2006 +0200, =?ISO-8859-2?Q?Micha=B3_Kwiatkowski?= wrote:
>I'm using setuptools interface to fetch packages from PyPI. Version
>requirements work fine, but more sophisticated conditions are needed.
>In particular, I would like to hint setuptools to prefer source
>distributions (tar/subversion/..) over eggs and prefer fetching
>distributions from PyPI over relying on locally installed releases
>(even if version numbers match). Currently my code looks something
>like that:
>
>from setuptools.package_index import PackageIndex
>from pkg_resources import Requirement
>
>pkgindex = PackageIndex()

Pass an empty search path, e.g. PackageIndex(search_path=[])

This will create an index that doesn't include any installed eggs.


>path = pkgindex.fetch(Requirement.parse(REQUIREMENTS),
>     TMP_DIR, force_scan=True)
>
>According to documentation, setting force_scan to False would inhibit
>checking local filesystem,

I don't know where you're getting that from.  The docstring says:

"""If necessary, or if the `force_scan` flag is set, the requirement is
searched for in the (online) package index as well as the locally
installed packages."""

Note the "as well as".  Anyway, creating the PackageIndex with search_path 
set to an empty list should do what you want, except you also want to pass 
'source=True' to 'fetch()' if you want it to find only source packages.



More information about the Distutils-SIG mailing list