コード例 #1
0
    def test_repr(self):
        rule_repr = repr(PackageRule.from_packages([mkl_11_0_0, mkl_10_1_0, mkl_10_2_0], self.pool))
        self.assertEqual(rule_repr, "(+mkl-10.1.0 | +mkl-10.2.0 | +mkl-11.0.0)")

        rule_repr = repr(PackageRule([PackageNot.from_package(mkl_10_2_0, self.pool)], self.pool) \
                | PackageRule.from_packages([mkl_11_0_0], self.pool))
        self.assertEqual(rule_repr, "(-mkl-10.2.0 | +mkl-11.0.0)")
コード例 #2
0
    def test_multiple_install_provides(self):
        # Installed requirement has > 1 one provide
        repo = Repository([
            mkl_10_1_0, mkl_10_2_0, mkl_10_3_0, mkl_11_0_0, numpy_1_6_1,
            numpy_1_7_0
        ])
        pool = Pool()
        pool.add_repository(repo)

        r_rules = set()
        r_rules.add(PackageRule.from_string("numpy-1.7.0 | numpy-1.6.1", pool))
        r_rules.add(
            PackageRule.from_string("-numpy-1.7.0 | -numpy-1.6.1", pool))
        r_rules.add(
            PackageRule.from_string(
                "-numpy-1.7.0 | mkl-10.1.0 | mkl-10.2.0 | mkl-10.3.0 | mkl-11.0.0",
                pool))
        r_rules.add(
            PackageRule.from_string(
                "-numpy-1.6.1 | mkl-10.1.0 | mkl-10.2.0 | mkl-10.3.0 | mkl-11.0.0",
                pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-10.2.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-10.3.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-11.0.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.2.0 | -mkl-10.3.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.2.0 | -mkl-11.0.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.3.0 | -mkl-11.0.0", pool))

        self.assertEqual(r_rules, set(create_install_rules(pool, R("numpy"))))
コード例 #3
0
    def test_repr(self):
        rule_repr = repr(
            PackageRule.from_packages([mkl_11_0_0, mkl_10_1_0, mkl_10_2_0],
                                      self.pool))
        self.assertEqual(rule_repr,
                         "(+mkl-10.1.0 | +mkl-10.2.0 | +mkl-11.0.0)")

        rule_repr = repr(PackageRule([PackageNot.from_package(mkl_10_2_0, self.pool)], self.pool) \
                | PackageRule.from_packages([mkl_11_0_0], self.pool))
        self.assertEqual(rule_repr, "(-mkl-10.2.0 | +mkl-11.0.0)")
コード例 #4
0
    def test_multiple_provided_names_single_install_provide(self):
        # Installed requirement has 1 one provide, but multiple provides for
        # the same name are available in the pool
        repo = Repository([
            mkl_10_1_0, mkl_10_2_0, mkl_10_3_0, mkl_11_0_0, numpy_1_6_1,
            numpy_1_7_0
        ])
        pool = Pool()
        pool.add_repository(repo)

        r_rules = set()
        r_rules.add(PackageRule.from_string("numpy-1.7.0", pool))
        r_rules.add(
            PackageRule.from_string("-numpy-1.7.0 | -numpy-1.6.1", pool))
        r_rules.add(
            PackageRule.from_string(
                "-numpy-1.7.0 | mkl-10.1.0 | mkl-10.2.0 | mkl-10.3.0 | mkl-11.0.0",
                pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-10.2.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-10.3.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-11.0.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.2.0 | -mkl-10.3.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.2.0 | -mkl-11.0.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.3.0 | -mkl-11.0.0", pool))

        self.assertEqual(r_rules,
                         set(create_install_rules(pool, R("numpy == 1.7.0"))))
コード例 #5
0
    def test_iter_conflict_rules(self):
        # Making sure single package corner-case works
        self.assertEqual(set(), set(iter_conflict_rules(self.pool, [mkl_10_1_0])))

        # 3 packages conflicting with each other -> 3 rules (C_3^2)
        r_rules = set()
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-10.2.0", self.pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-10.3.0", self.pool))
        r_rules.add(PackageRule.from_string("-mkl-10.2.0 | -mkl-10.3.0", self.pool))

        self.assertEqual(r_rules,
                set(iter_conflict_rules(self.pool, [mkl_10_1_0, mkl_10_2_0, mkl_10_3_0])))
コード例 #6
0
    def test_str(self):
        rule = PackageRule.from_packages(
            self.pool, [self.mkl_11_0_0, self.mkl_10_1_0, self.mkl_10_2_0],
            None)
        rule_repr = str(rule)
        self.assertEqual(rule_repr,
                         "(+mkl-10.1.0 | +mkl-10.2.0 | +mkl-11.0.0)")

        rule_repr = str(
            PackageRule(self.pool, [-self.mkl_10_2_0.id, self.mkl_11_0_0.id],
                        None))
        self.assertEqual(rule_repr, "(-mkl-10.2.0 | +mkl-11.0.0)")
コード例 #7
0
    def test_str_simple(self):
        repository = Repository([P("mkl-10.1.0"),
                                 P("numpy-1.7.0; depends (MKL >= 10.1.0)"),
                                 P("scipy-0.12.0; depends (numpy >= 1.7.0)")])
        pool = Pool([repository])

        rule = PackageRule(pool, [1, 2], "job_install", "scipy")

        self.assertEqual(str(rule), "(+mkl-10.1.0 | +numpy-1.7.0)")

        rule = PackageRule(pool, [-1, 2], "job_install", "scipy")

        self.assertEqual(str(rule), "(-mkl-10.1.0 | +numpy-1.7.0)")
コード例 #8
0
    def test_from_package_string(self):
        rule = PackageRule.from_string("mkl-11.0.0", self.pool)
        self.assertEqual(rule,
                         PackageRule.from_packages([mkl_11_0_0], self.pool))

        rule = PackageRule.from_string("mkl-10.2.0 | mkl-11.0.0", self.pool)
        self.assertEqual(
            rule, PackageRule.from_packages([mkl_10_2_0, mkl_11_0_0],
                                            self.pool))

        rule = PackageRule.from_string("-mkl-10.2.0 | mkl-11.0.0", self.pool)
        self.assertEqual(
            rule,
            PackageRule([
                PackageNot.from_package(mkl_10_2_0, self.pool),
                PackageLiteral.from_package(mkl_11_0_0, self.pool)
            ], self.pool))

        rule = PackageRule.from_string("-mkl-10.2.0 | -mkl-11.0.0", self.pool)
        self.assertEqual(
            rule,
            PackageRule([
                PackageNot.from_package(mkl_10_2_0, self.pool),
                PackageNot.from_package(mkl_11_0_0, self.pool)
            ], self.pool))
コード例 #9
0
    def test_create_depends_rule(self):
        r_rule = PackageRule.from_string(
                    "-numpy-1.6.0 | mkl-10.1.0 | mkl-10.2.0 | mkl-10.3.0 | mkl-11.0.0",
                    self.pool)
        rule = create_depends_rule(self.pool, numpy_1_6_0, R("mkl"))

        self.assertEqual(rule, r_rule)
コード例 #10
0
def create_install_rules(pool, req):
    """Creates the list of rules for the given install requirement."""
    clauses = []
    clauses_set = set()

    def _append_rule(rule):
        if not rule in clauses_set:
            clauses_set.add(rule)
            clauses.append(rule)

    def _extend_rules(rules):
        for rule in rules:
            _append_rule(rule)

    def _add_dependency_rules(req):
        provided = pool.what_provides(req, 'include_indirect')
        if len(provided) < 1:
            raise MissingRequirementInPool(req)
        else:
            obsolete_provided = pool.what_provides(req, 'any')
            _extend_rules(iter_conflict_rules(pool, obsolete_provided))

            for candidate in provided:
                for dependency_req in candidate.dependencies:
                    _append_rule(create_depends_rule(pool, candidate, dependency_req))
                    _extend_rules(_add_dependency_rules(dependency_req))
            return clauses

    provided = pool.what_provides(req)
    rule = PackageRule.from_packages(provided, pool)
    _append_rule(rule)
    return _add_dependency_rules(req)
コード例 #11
0
    def test_create_depends_rule(self):
        r_rule = PackageRule.from_string(
            "-numpy-1.6.0 | mkl-10.1.0 | mkl-10.2.0 | mkl-10.3.0 | mkl-11.0.0",
            self.pool)
        rule = create_depends_rule(self.pool, numpy_1_6_0, R("mkl"))

        self.assertEqual(rule, r_rule)
コード例 #12
0
def create_install_rules(pool, req):
    """Creates the list of rules for the given install requirement."""
    clauses = []
    clauses_set = set()

    def _append_rule(rule):
        if not rule in clauses_set:
            clauses_set.add(rule)
            clauses.append(rule)

    def _extend_rules(rules):
        for rule in rules:
            _append_rule(rule)

    def _add_dependency_rules(req):
        provided = pool.what_provides(req, 'include_indirect')
        if len(provided) < 1:
            raise MissingRequirementInPool(req)
        else:
            obsolete_provided = pool.what_provides(req, 'any')
            _extend_rules(iter_conflict_rules(pool, obsolete_provided))

            for candidate in provided:
                for dependency_req in candidate.dependencies:
                    _append_rule(
                        create_depends_rule(pool, candidate, dependency_req))
                    _extend_rules(_add_dependency_rules(dependency_req))
            return clauses

    provided = pool.what_provides(req)
    rule = PackageRule.from_packages(provided, pool)
    _append_rule(rule)
    return _add_dependency_rules(req)
コード例 #13
0
    def test_str(self):
        rule = PackageRule.from_packages(self.pool, [self.mkl_11_0_0,
                                         self.mkl_10_1_0, self.mkl_10_2_0], None)
        rule_repr = str(rule)
        self.assertEqual(rule_repr, "(+mkl-10.1.0 | +mkl-10.2.0 | +mkl-11.0.0)")

        rule_repr = str(PackageRule(self.pool, [-self.mkl_10_2_0.id, self.mkl_11_0_0.id], None))
        self.assertEqual(rule_repr, "(-mkl-10.2.0 | +mkl-11.0.0)")
コード例 #14
0
    def test_already_installed_indirect_provided(self):
        # Installed requirement has one dependency with multiple provides for
        # the same name available in the pool, one of which is already
        # installed. Here: scipy depends on numpy, nomkl_numpy is also
        # available and already installed
        repo = Repository([mkl_11_0_0, nomkl_numpy_1_7_0, numpy_1_7_0, scipy_0_11_0])
        pool = Pool()
        pool.add_repository(repo)

        r_rules = set()
        r_rules.add(PackageRule.from_string("scipy-0.11.0", pool))
        r_rules.add(PackageRule.from_string("-scipy-0.11.0 | numpy-1.7.0 | nomkl_numpy-1.7.0", pool))
        r_rules.add(PackageRule.from_string("-numpy-1.7.0 | -nomkl_numpy-1.7.0", pool))
        r_rules.add(PackageRule.from_string(
            "-numpy-1.7.0 | mkl-11.0.0", pool))

        self.assertEqual(r_rules,
                set(create_install_rules(pool, R("scipy"))))
コード例 #15
0
    def test_iter_conflict_rules(self):
        # Making sure single package corner-case works
        self.assertEqual(set(),
                         set(iter_conflict_rules(self.pool, [mkl_10_1_0])))

        # 3 packages conflicting with each other -> 3 rules (C_3^2)
        r_rules = set()
        r_rules.add(
            PackageRule.from_string("-mkl-10.1.0 | -mkl-10.2.0", self.pool))
        r_rules.add(
            PackageRule.from_string("-mkl-10.1.0 | -mkl-10.3.0", self.pool))
        r_rules.add(
            PackageRule.from_string("-mkl-10.2.0 | -mkl-10.3.0", self.pool))

        self.assertEqual(
            r_rules,
            set(
                iter_conflict_rules(self.pool,
                                    [mkl_10_1_0, mkl_10_2_0, mkl_10_3_0])))
コード例 #16
0
    def test_already_installed_indirect_provided(self):
        # Installed requirement has one dependency with multiple provides for
        # the same name available in the pool, one of which is already
        # installed. Here: scipy depends on numpy, nomkl_numpy is also
        # available and already installed
        repo = Repository(
            [mkl_11_0_0, nomkl_numpy_1_7_0, numpy_1_7_0, scipy_0_11_0])
        pool = Pool()
        pool.add_repository(repo)

        r_rules = set()
        r_rules.add(PackageRule.from_string("scipy-0.11.0", pool))
        r_rules.add(
            PackageRule.from_string(
                "-scipy-0.11.0 | numpy-1.7.0 | nomkl_numpy-1.7.0", pool))
        r_rules.add(
            PackageRule.from_string("-numpy-1.7.0 | -nomkl_numpy-1.7.0", pool))
        r_rules.add(PackageRule.from_string("-numpy-1.7.0 | mkl-11.0.0", pool))

        self.assertEqual(r_rules, set(create_install_rules(pool, R("scipy"))))
コード例 #17
0
    def test_ctor_simple(self):
        repository = Repository([P("mkl-10.1.0"),
                                 P("numpy-1.7.0; depends (MKL >= 10.1.0)"),
                                 P("scipy-0.12.0; depends (numpy >= 1.7.0)")])
        pool = Pool([repository])

        rule = PackageRule(pool, [1, 2], "job_install", "scipy")

        self.assertEqual(rule.enabled, True)
        self.assertEqual(rule.literals, [1, 2])
        self.assertEqual(rule.reason, "job_install")
        self.assertEqual(rule.rule_hash, "05cf2")
コード例 #18
0
    def test_create_depends_rule(self):
        r_rule = PackageRule.from_string(self.pool,
                    "-numpy-1.6.0 | mkl-10.1.0 | mkl-10.2.0 | mkl-10.3.0 | mkl-11.0.0",
                    None)

        req = R("numpy")
        request = Request(self.pool)
        request.install(req)

        rules_generator = RulesGenerator(self.pool, request, OrderedDict())
        dependencies = self.pool.what_provides(self.numpy_1_6_0.dependencies[0])
        rule = rules_generator._create_dependency_rule(self.numpy_1_6_0, dependencies, None)

        self.assertTrue(rule.is_equivalent(r_rule))
コード例 #19
0
    def test_simple(self):
        repository = Repository([
            P("mkl-10.1.0"),
            P("numpy-1.7.0; depends (MKL >= 10.1.0)"),
            P("scipy-0.12.0; depends (numpy >= 1.7.0)")
        ])
        pool = Pool([repository])

        rule = PackageRule(pool, [1, 2], "job_install", "scipy")

        rules_set = RulesSet()
        rules_set.add_rule(rule, "package")

        self.assertEqual(len(rules_set), 1)
コード例 #20
0
    def test_multiple_install_provides(self):
        # Installed requirement has > 1 one provide
        repo = Repository([mkl_10_1_0, mkl_10_2_0, mkl_10_3_0, mkl_11_0_0,
            numpy_1_6_1, numpy_1_7_0])
        pool = Pool()
        pool.add_repository(repo)

        r_rules = set()
        r_rules.add(PackageRule.from_string("numpy-1.7.0 | numpy-1.6.1", pool))
        r_rules.add(PackageRule.from_string("-numpy-1.7.0 | -numpy-1.6.1", pool))
        r_rules.add(PackageRule.from_string(
            "-numpy-1.7.0 | mkl-10.1.0 | mkl-10.2.0 | mkl-10.3.0 | mkl-11.0.0", pool))
        r_rules.add(PackageRule.from_string(
            "-numpy-1.6.1 | mkl-10.1.0 | mkl-10.2.0 | mkl-10.3.0 | mkl-11.0.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-10.2.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-10.3.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-11.0.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.2.0 | -mkl-10.3.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.2.0 | -mkl-11.0.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.3.0 | -mkl-11.0.0", pool))

        self.assertEqual(r_rules,
                set(create_install_rules(pool, R("numpy"))))
コード例 #21
0
    def test_create_install_rules_simple(self):
        r_rules = set()
        r_rules.add(PackageRule.from_string(
            "mkl-10.1.0 | mkl-10.2.0 | mkl-10.3.0 | mkl-11.0.0", self.pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-10.2.0", self.pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-10.3.0", self.pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-11.0.0", self.pool))
        r_rules.add(PackageRule.from_string("-mkl-10.2.0 | -mkl-10.3.0", self.pool))
        r_rules.add(PackageRule.from_string("-mkl-10.2.0 | -mkl-11.0.0", self.pool))
        r_rules.add(PackageRule.from_string("-mkl-10.3.0 | -mkl-11.0.0", self.pool))

        self.assertEqual(r_rules,
                set(create_install_rules(self.pool, R("mkl"))))
コード例 #22
0
    def test_from_packages_simple(self):
        mkl = P("mkl-10.1.0")
        numpy = P("numpy-1.7.0; depends (MKL >= 10.1.0)")
        scipy = P("scipy-0.12.0; depends (numpy >= 1.7.0)")
        remote_repository = [mkl, numpy, scipy]

        i_mkl = P("mkl-10.1.0")
        installed_repository = [i_mkl]

        pool = Pool([Repository(remote_repository), Repository(installed_repository)])

        rule = PackageRule.from_packages(pool, [mkl, i_mkl], "job_install", "numpy")

        self.assertEqual(rule.enabled, True)
        self.assertEqual(rule.literals, [mkl.id, i_mkl.id])
        self.assertEqual(rule.reason, "job_install")
コード例 #23
0
    def test_multiple_provided_names_single_install_provide(self):
        # Installed requirement has 1 one provide, but multiple provides for
        # the same name are available in the pool
        repo = Repository([mkl_10_1_0, mkl_10_2_0, mkl_10_3_0, mkl_11_0_0,
            numpy_1_6_1, numpy_1_7_0])
        pool = Pool()
        pool.add_repository(repo)

        r_rules = set()
        r_rules.add(PackageRule.from_string("numpy-1.7.0", pool))
        r_rules.add(PackageRule.from_string("-numpy-1.7.0 | -numpy-1.6.1", pool))
        r_rules.add(PackageRule.from_string(
            "-numpy-1.7.0 | mkl-10.1.0 | mkl-10.2.0 | mkl-10.3.0 | mkl-11.0.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-10.2.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-10.3.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-11.0.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.2.0 | -mkl-10.3.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.2.0 | -mkl-11.0.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.3.0 | -mkl-11.0.0", pool))

        self.assertEqual(r_rules,
                set(create_install_rules(pool, R("numpy == 1.7.0"))))
コード例 #24
0
    def test_create_depends_rule(self):
        r_rule = PackageRule.from_string(
            self.pool,
            "-numpy-1.6.0 | mkl-10.1.0 | mkl-10.2.0 | mkl-10.3.0 | mkl-11.0.0",
            None)

        req = R("numpy")
        request = Request(self.pool)
        request.install(req)

        rules_generator = RulesGenerator(self.pool, request, OrderedDict())
        dependencies = self.pool.what_provides(
            self.numpy_1_6_0.dependencies[0])
        rule = rules_generator._create_dependency_rule(self.numpy_1_6_0,
                                                       dependencies, None)

        self.assertTrue(rule.is_equivalent(r_rule))
コード例 #25
0
    def test_from_package_string(self):
        r_rule = PackageRule.from_packages(self.pool, [self.mkl_11_0_0], None)

        rule = PackageRule.from_string(self.pool, "mkl-11.0.0", None)
        self.assertTrue(rule.is_equivalent(r_rule))

        r_rule = PackageRule.from_packages(self.pool, [self.mkl_10_2_0, self.mkl_11_0_0], None)
        rule = PackageRule.from_string(self.pool, "mkl-10.2.0 | mkl-11.0.0", None)
        self.assertTrue(rule.is_equivalent(r_rule))

        r_rule = PackageRule(self.pool, [-self.mkl_10_2_0.id, self.mkl_11_0_0.id], None)
        rule = PackageRule.from_string(self.pool, "-mkl-10.2.0 | mkl-11.0.0", None)
        self.assertTrue(rule.is_equivalent(r_rule))

        r_rule = PackageRule(self.pool, [-self.mkl_10_2_0.id, -self.mkl_11_0_0.id], None)
        rule = PackageRule.from_string(self.pool, "-mkl-10.2.0 | -mkl-11.0.0", None)
        self.assertTrue(rule.is_equivalent(r_rule))
コード例 #26
0
    def test_from_package_string(self):
        rule = PackageRule.from_string("mkl-11.0.0", self.pool)
        self.assertEqual(rule, PackageRule.from_packages([mkl_11_0_0], self.pool))

        rule = PackageRule.from_string("mkl-10.2.0 | mkl-11.0.0", self.pool)
        self.assertEqual(rule, PackageRule.from_packages([mkl_10_2_0, mkl_11_0_0], self.pool))

        rule = PackageRule.from_string("-mkl-10.2.0 | mkl-11.0.0", self.pool)
        self.assertEqual(rule,
                PackageRule([PackageNot.from_package(mkl_10_2_0, self.pool),
                             PackageLiteral.from_package(mkl_11_0_0, self.pool)], self.pool))

        rule = PackageRule.from_string("-mkl-10.2.0 | -mkl-11.0.0", self.pool)
        self.assertEqual(rule,
                PackageRule([PackageNot.from_package(mkl_10_2_0, self.pool),
                             PackageNot.from_package(mkl_11_0_0, self.pool)],
                            self.pool))
コード例 #27
0
    def test_from_package_string(self):
        r_rule = PackageRule.from_packages(self.pool, [self.mkl_11_0_0], None)

        rule = PackageRule.from_string(self.pool, "mkl-11.0.0", None)
        self.assertTrue(rule.is_equivalent(r_rule))

        r_rule = PackageRule.from_packages(self.pool,
                                           [self.mkl_10_2_0, self.mkl_11_0_0],
                                           None)
        rule = PackageRule.from_string(self.pool, "mkl-10.2.0 | mkl-11.0.0",
                                       None)
        self.assertTrue(rule.is_equivalent(r_rule))

        r_rule = PackageRule(self.pool,
                             [-self.mkl_10_2_0.id, self.mkl_11_0_0.id], None)
        rule = PackageRule.from_string(self.pool, "-mkl-10.2.0 | mkl-11.0.0",
                                       None)
        self.assertTrue(rule.is_equivalent(r_rule))

        r_rule = PackageRule(self.pool,
                             [-self.mkl_10_2_0.id, -self.mkl_11_0_0.id], None)
        rule = PackageRule.from_string(self.pool, "-mkl-10.2.0 | -mkl-11.0.0",
                                       None)
        self.assertTrue(rule.is_equivalent(r_rule))
コード例 #28
0
    def test_create_install_rules_simple(self):
        r_rules = set()
        r_rules.add(
            PackageRule.from_string(
                "mkl-10.1.0 | mkl-10.2.0 | mkl-10.3.0 | mkl-11.0.0",
                self.pool))
        r_rules.add(
            PackageRule.from_string("-mkl-10.1.0 | -mkl-10.2.0", self.pool))
        r_rules.add(
            PackageRule.from_string("-mkl-10.1.0 | -mkl-10.3.0", self.pool))
        r_rules.add(
            PackageRule.from_string("-mkl-10.1.0 | -mkl-11.0.0", self.pool))
        r_rules.add(
            PackageRule.from_string("-mkl-10.2.0 | -mkl-10.3.0", self.pool))
        r_rules.add(
            PackageRule.from_string("-mkl-10.2.0 | -mkl-11.0.0", self.pool))
        r_rules.add(
            PackageRule.from_string("-mkl-10.3.0 | -mkl-11.0.0", self.pool))

        self.assertEqual(r_rules,
                         set(create_install_rules(self.pool, R("mkl"))))
コード例 #29
0
    def test_or(self):
        rule = PackageRule.from_packages([mkl_10_1_0, mkl_10_2_0], self.pool)
        rule |= PackageNot.from_package(mkl_11_0_0, self.pool)

        self.assertTrue(rule.literals,
                        set([mkl_11_0_0.id, mkl_10_1_0.id, mkl_10_2_0.id]))
コード例 #30
0
    def test_complex_scenario_1(self):
        repo = Repository([
            mkl_10_1_0, mkl_10_2_0, mkl_10_3_0, mkl_11_0_0, numpy_1_6_0,
            numpy_1_6_1, numpy_1_7_0, scipy_0_11_0, scipy_0_12_0
        ])
        pool = Pool()
        pool.add_repository(repo)

        r_rules = set()
        r_rules.add(
            PackageRule.from_string("scipy-0.11.0 | scipy-0.12.0", pool))
        r_rules.add(
            PackageRule.from_string("-scipy-0.11.0 | -scipy-0.12.0", pool))
        r_rules.add(
            PackageRule.from_string(
                "-scipy-0.11.0 | numpy-1.6.0 | numpy-1.6.1 | numpy-1.7.0",
                pool))
        r_rules.add(
            PackageRule.from_string(
                "-scipy-0.12.0 | numpy-1.6.0 | numpy-1.6.1 | numpy-1.7.0",
                pool))
        r_rules.add(
            PackageRule.from_string("-numpy-1.7.0 | -numpy-1.6.1", pool))
        r_rules.add(
            PackageRule.from_string("-numpy-1.7.0 | -numpy-1.6.0", pool))
        r_rules.add(
            PackageRule.from_string("-numpy-1.6.0 | -numpy-1.6.1", pool))
        r_rules.add(
            PackageRule.from_string(
                "-numpy-1.7.0 | mkl-10.1.0 | mkl-10.2.0 | mkl-10.3.0 | mkl-11.0.0",
                pool))
        r_rules.add(
            PackageRule.from_string(
                "-numpy-1.6.1 | mkl-10.1.0 | mkl-10.2.0 | mkl-10.3.0 | mkl-11.0.0",
                pool))
        r_rules.add(
            PackageRule.from_string(
                "-numpy-1.6.0 | mkl-10.1.0 | mkl-10.2.0 | mkl-10.3.0 | mkl-11.0.0",
                pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-10.2.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-10.3.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-11.0.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.2.0 | -mkl-10.3.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.2.0 | -mkl-11.0.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.3.0 | -mkl-11.0.0", pool))

        self.assertEqual(r_rules, set(create_install_rules(pool, R("scipy"))))
コード例 #31
0
    def test_complex_scenario_1(self):
        repo = Repository([mkl_10_1_0, mkl_10_2_0, mkl_10_3_0, mkl_11_0_0,
            numpy_1_6_0, numpy_1_6_1, numpy_1_7_0, scipy_0_11_0, scipy_0_12_0])
        pool = Pool()
        pool.add_repository(repo)

        r_rules = set()
        r_rules.add(PackageRule.from_string("scipy-0.11.0 | scipy-0.12.0", pool))
        r_rules.add(PackageRule.from_string("-scipy-0.11.0 | -scipy-0.12.0", pool))
        r_rules.add(PackageRule.from_string(
                    "-scipy-0.11.0 | numpy-1.6.0 | numpy-1.6.1 | numpy-1.7.0",
                    pool))
        r_rules.add(PackageRule.from_string(
                    "-scipy-0.12.0 | numpy-1.6.0 | numpy-1.6.1 | numpy-1.7.0",
                    pool))
        r_rules.add(PackageRule.from_string("-numpy-1.7.0 | -numpy-1.6.1", pool))
        r_rules.add(PackageRule.from_string("-numpy-1.7.0 | -numpy-1.6.0", pool))
        r_rules.add(PackageRule.from_string("-numpy-1.6.0 | -numpy-1.6.1", pool))
        r_rules.add(PackageRule.from_string(
            "-numpy-1.7.0 | mkl-10.1.0 | mkl-10.2.0 | mkl-10.3.0 | mkl-11.0.0", pool))
        r_rules.add(PackageRule.from_string(
            "-numpy-1.6.1 | mkl-10.1.0 | mkl-10.2.0 | mkl-10.3.0 | mkl-11.0.0", pool))
        r_rules.add(PackageRule.from_string(
            "-numpy-1.6.0 | mkl-10.1.0 | mkl-10.2.0 | mkl-10.3.0 | mkl-11.0.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-10.2.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-10.3.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.1.0 | -mkl-11.0.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.2.0 | -mkl-10.3.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.2.0 | -mkl-11.0.0", pool))
        r_rules.add(PackageRule.from_string("-mkl-10.3.0 | -mkl-11.0.0", pool))

        self.assertEqual(r_rules,
                set(create_install_rules(pool, R("scipy"))))
コード例 #32
0
    def test_or(self):
        rule = PackageRule.from_packages([mkl_10_1_0, mkl_10_2_0], self.pool)
        rule |= PackageNot.from_package(mkl_11_0_0, self.pool)

        self.assertTrue(rule.literals, set([mkl_11_0_0.id, mkl_10_1_0.id, mkl_10_2_0.id]))