def get_egg_distribution_links(self, package, version=None, py_version=sys.version_info, dev=False, strict=False): """ Return links to available egg distributions. Parameters ---------- package : `str` name of the package version : `str` or `bool` version of the package. Optional, if not provided links for all available versions of the package will be returned. py_version : `str` or `distutils.version.Version` target Python version for distributions. Only those distributions which are compatible with the version of Python will be returned. Defaults to the Python version of the current interpreter. If None is provided will return distributions for all Python platforms. dev: `bool` If set, will only return dev versions. Otherwise, return only released versions. strict: `bool` If set, matches dev versions strictly. Eg: 0.0.dev OK, 2.33.dev3 -not OK. Returns ------- dists : `dict` a map of `str`->`pkg_resources.Distribution` (distribution URL -> distribution object) """ fn = ((util.is_strict_dev_version if strict else util.is_dev_version) if dev else (lambda v: not util.is_dev_version(v))) py_version = py_version and util.short_version(py_version, max_parts=2) dists = {} for l in self.get_links(package): if not l.endswith(".egg"): continue d = Distribution.from_filename(l.rsplit("/", 1)[-1]) if py_version and d.py_version != py_version: continue if not fn(d.version): continue if version and d.version != version: continue dists[l] = d return dists
def isdev(self): return util.is_dev_version(self.version)
def test_is_dev_version(): assert util.is_dev_version('1.2.3.dev1') is True assert util.is_dev_version('1.2.3.dev4') is True assert util.is_dev_version('1.2.3') is False assert util.is_dev_version('1.2.3dev4') is False