From 6f14057f4e4a126d4d8ab6148e120e5c31e01ab2 Mon Sep 17 00:00:00 2001
From: Daira Hopwood <daira@jacaranda.org>
Date: Fri, 10 Jul 2015 06:27:56 +0100
Subject: [PATCH] __init__.py: support == requirements.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
---
 src/allmydata/__init__.py   | 18 ++++++++++++------
 src/allmydata/_auto_deps.py |  2 +-
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/allmydata/__init__.py b/src/allmydata/__init__.py
index 0b0c5f81..9f08f768 100644
--- a/src/allmydata/__init__.py
+++ b/src/allmydata/__init__.py
@@ -269,10 +269,10 @@ def get_package_versions_and_locations():
 
 
 def check_requirement(req, vers_and_locs):
-    # We support only conjunctions of <=, >=, and !=
+    # We support only conjunctions of <=, >=, ==, and !=
 
     reqlist = req.split(',')
-    name = reqlist[0].split('<=')[0].split('>=')[0].split('!=')[0].strip(' ').split('[')[0]
+    name = reqlist[0].split('<=')[0].split('>=')[0].split('==')[0].split('!=')[0].strip(' ').split('[')[0]
     if name not in vers_and_locs:
         raise PackagingError("no version info for %s" % (name,))
     if req.strip(' ') == name:
@@ -308,13 +308,19 @@ def match_requirement(req, reqlist, actualver):
                 if not (actualver >= normalized_version(required, what="required minimum version %r in %r" % (required, req))):
                     return False  # minimum requirement not met
             else:
-                s = r.split('!=')
+                s = r.split('==')
                 if len(s) == 2:
                     required = s[1].strip(' ')
-                    if not (actualver != normalized_version(required, what="excluded version %r in %r" % (required, req))):
-                        return False  # not-equal requirement not met
+                    if not (actualver == normalized_version(required, what="required exact version %r in %r" % (required, req))):
+                        return False  # exact requirement not met
                 else:
-                    raise PackagingError("no version info or could not understand requirement %r" % (req,))
+                    s = r.split('!=')
+                    if len(s) == 2:
+                        required = s[1].strip(' ')
+                        if not (actualver != normalized_version(required, what="excluded version %r in %r" % (required, req))):
+                            return False  # not-equal requirement not met
+                    else:
+                        raise PackagingError("no version info or could not understand requirement %r" % (req,))
 
     return True
 
diff --git a/src/allmydata/_auto_deps.py b/src/allmydata/_auto_deps.py
index 615e82a0..c2d01c5e 100644
--- a/src/allmydata/_auto_deps.py
+++ b/src/allmydata/_auto_deps.py
@@ -13,7 +13,7 @@
 #   * >= X, != Y, != Z, ... where X < Y < Z...
 #
 # (In addition, check_requirement in allmydata/__init__.py only supports
-# >=, <= and != operators.)
+# >=, <=, ==, and != operators.)
 
 install_requires = [
     # We require newer versions of setuptools (actually
-- 
2.45.2