Repository: conda/conda

Issue:
build_number comparison not functional in match_spec
Version comparisons work.

    conda search 'python[version="<3"]'

Seems that build_number comparisons do not.

    conda search 'python[build_number="<5"]'


Discussion:

Resolving patch:
diff --git a/conda/models/version.py b/conda/models/version.py
--- a/conda/models/version.py
+++ b/conda/models/version.py
@@ -545,10 +545,13 @@ def __new__(cls, spec):
         return self
 
     def exact_match_(self, vspec):
-        return self.spec == vspec
+        try:
+            return int(self.spec) == int(vspec)
+        except ValueError:
+            return False
 
     def veval_match_(self, vspec):
-        return self.op(VersionOrder(vspec), self.cmp)
+        return self.op(VersionOrder(text_type(vspec)), self.cmp)
 
     def triv_match_(self, vspec):
         return True


Test patch:
diff --git a/tests/models/test_match_spec.py b/tests/models/test_match_spec.py
--- a/tests/models/test_match_spec.py
+++ b/tests/models/test_match_spec.py
@@ -395,6 +395,24 @@ def test_key_value_features_match(self):
         assert c.match(DPkg(dst, track_features='nomkl'))
         assert c.match(DPkg(dst, track_features='blas=nomkl debug'))
 
+    def test_bracket_matches(self):
+        record = {
+            'name': 'numpy',
+            'version': '1.11.0',
+            'build': 'py34_7',
+            'build_number': 7,
+        }
+
+        assert MatchSpec("numpy<2").match(record)
+        assert MatchSpec("numpy[version<2]").match(record)
+        assert not MatchSpec("numpy>2").match(record)
+        assert not MatchSpec("numpy[version='>2']").match(record)
+
+        assert MatchSpec("numpy[build_number='7']").match(record)
+        assert MatchSpec("numpy[build_number='<8']").match(record)
+        assert not MatchSpec("numpy[build_number='>7']").match(record)
+        assert MatchSpec("numpy[build_number='>=7']").match(record)
+
 
 class TestArg2Spec(TestCase):
 
@@ -642,3 +660,47 @@ def test_parse_parens(self):
             # "target": "blarg",  # suppressing these for now
             # "optional": True,
         }
+
+    def test_parse_build_number_brackets(self):
+        assert _parse_spec_str("python[build_number=3]") == {
+            "name": "python",
+            "build_number": '3',
+        }
+        assert _parse_spec_str("python[build_number='>3']") == {
+            "name": "python",
+            "build_number": '>3',
+        }
+        assert _parse_spec_str("python[build_number='>=3']") == {
+            "name": "python",
+            "build_number": '>=3',
+        }
+
+        assert _parse_spec_str("python[build_number='<3']") == {
+            "name": "python",
+            "build_number": '<3',
+        }
+        assert _parse_spec_str("python[build_number='<=3']") == {
+            "name": "python",
+            "build_number": '<=3',
+        }
+
+        # # these don't work right now, should they?
+        # assert _parse_spec_str("python[build_number<3]") == {
+        #     "name": "python",
+        #     "build_number": '<3',
+        # }
+        # assert _parse_spec_str("python[build_number<=3]") == {
+        #     "name": "python",
+        #     "build_number": '<=3',
+        # }
+
+        # # these don't work right now, should they?
+        # assert _parse_spec_str("python[build_number>3]") == {
+        #     "name": "python",
+        #     "build_number": '>3',
+        # }
+        # assert _parse_spec_str("python[build_number>=3]") == {
+        #     "name": "python",
+        #     "build_number": '>=3',
+        # }
+