diff options
author | Richard Ipsum <richard.ipsum@codethink.co.uk> | 2014-10-16 19:44:38 +0100 |
---|---|---|
committer | Richard Ipsum <richard.ipsum@codethink.co.uk> | 2014-11-04 12:40:56 +0000 |
commit | 5dd6f208d0a12069cdeb59690f875d1d91ece02d (patch) | |
tree | 0e0e0452c369110f93489db64f1c5902a64c2b30 | |
parent | 4a12a06e724e2e88bc554e8df31fa184df672db7 (diff) | |
download | import-5dd6f208d0a12069cdeb59690f875d1d91ece02d.tar.gz |
Handle version constraints
-rwxr-xr-x | import/pip_lorry.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/import/pip_lorry.py b/import/pip_lorry.py index 89f4d4a..88dd6ab 100755 --- a/import/pip_lorry.py +++ b/import/pip_lorry.py @@ -118,6 +118,13 @@ def filter_urls(urls): return filter(allowed_extension, urls) +def specs_satisfied(version, specs): + opmap = {'==' : lambda x, y: x == y, '!=' : lambda x, y: x != y, + '<=' : lambda x, y: x <= y, '>=' : lambda x, y: x >= y, + '<': lambda x, y: x < y, '>' : lambda x, y: x > y} + + return all([opmap[op](version, sv) for (op, sv) in specs]) + def generate_tarball_lorry(requirement): try: client = xmlrpclib.ServerProxy(PYPI_URL) @@ -128,8 +135,11 @@ def generate_tarball_lorry(requirement): if len(releases) == 0: error("Couldn't find any releases for package %s" % requirement.name) - # filter releases if package_version is not None + releases = [v for v in releases if specs_satisfied(v, requirement.specs)] + if len(releases) == 0: + error("Couldn't find any releases that satisfy version constraints: %s" + % requirement.specs) def get_description(release): return client.release_data(requirement.name, |