Use <= to "pin" dnspython

This commit is contained in:
Brad Warren 2020-10-23 12:42:45 -07:00
parent 635fd7b534
commit 4d89718930
2 changed files with 22 additions and 9 deletions

View file

@ -26,7 +26,13 @@ coverage==4.5.4
decorator==4.4.1
deprecated==1.2.10
dns-lexicon==3.3.17
dnspython==1.15.0
# There is no version of dnspython that works on both Python 2 and Python 3.9.
# To work around this, we make use of the fact that subject to other
# constraints, pip will install the newest version of a package while ignoring
# versions that don't support the version of Python being used. The result of
# this is dnspython 2.0.0 is installed in Python 3 while dnspython 1.16.0 is
# installed in Python 2.
dnspython<=2.0.0
docker==4.3.1
docker-compose==1.26.2
docker-pycreds==0.4.0

View file

@ -1,8 +1,9 @@
#!/usr/bin/env python
"""Merges multiple Python requirements files into one file.
Requirements files specified later take precedence over earlier ones. Only
simple SomeProject==1.2.3 format is currently supported.
Requirements files specified later take precedence over earlier ones.
Only the simple formats SomeProject==1.2.3 or SomeProject<=1.2.3 are
currently supported.
"""
from __future__ import print_function
@ -16,17 +17,22 @@ def process_entries(entries):
:param list entries: List of entries
:returns: mapping from a project to its pinned version
:returns: mapping from a project to its version specifier
:rtype: dict
"""
data = {}
for e in entries:
e = e.strip()
if e and not e.startswith('#') and not e.startswith('-e'):
project, version = e.split('==')
if not version:
for comparison in ('==', '<=',):
parts = e.split(comparison)
if len(parts) == 2:
project_name = parts[0]
version = parts[1]
data[project_name] = comparison + version
break
else:
raise ValueError("Unexpected syntax '{0}'".format(e))
data[project] = version
return data
def read_file(file_path):
@ -44,10 +50,11 @@ def read_file(file_path):
def output_requirements(requirements):
"""Prepare print requirements to stdout.
:param dict requirements: mapping from a project to its pinned version
:param dict requirements: mapping from a project to its version
specifier
"""
return '\n'.join('{0}=={1}'.format(key, value)
return '\n'.join('{0}{1}'.format(key, value)
for key, value in sorted(requirements.items()))