Exemple #1
0
def command(opts, parser, extra_arg_groups=None):
    if opts.package:
        remove_package(opts, parser)
    elif opts.ignored_since is not None:
        remove_ignored_since(opts, parser)
    else:
        parser.error("Must specify either --package or --ignored-since")
Exemple #2
0
def remove_package(opts, parser):
    from rez.vendor.version.requirement import VersionedObject
    from rez.package_remove import remove_package

    if opts.dry_run:
        parser.error("--dry-run is not supported with --package")

    if not opts.PATH:
        parser.error("Must specify PATH with --package")

    obj = VersionedObject(opts.package)

    if remove_package(obj.name, obj.version, opts.PATH):
        print("Package removed.")
    else:
        print("Package not found.", file=sys.stderr)
        sys.exit(1)
Exemple #3
0
    def test_package_remove(self):
        """Test package remove."""
        pkg_name = "pydad"
        pkg_version = Version("2")

        # copy packages to a temp repo
        repo_path = os.path.join(self.root, "tmp4_packages")
        shutil.copytree(self.solver_packages_path, repo_path)

        # verify that source pkg exists
        src_pkg = get_package_from_repository(pkg_name, pkg_version, repo_path)
        self.assertNotEqual(src_pkg, None)

        # remove it
        was_removed = remove_package(pkg_name, pkg_version, repo_path)
        self.assertTrue(was_removed)

        # verify that source pkg no longer exists (and isn't simply ignored)
        repo = package_repository_manager.get_repository(repo_path)
        i = repo.unignore_package(pkg_name, pkg_version)
        self.assertEqual(i, -1)
Exemple #4
0
    def test_package_family_remove(self):
        """Test package family remove."""
        pkg_name = "pydad"

        # copy packages to a temp repo
        repo_path = os.path.join(self.root, "tmp6_packages")
        shutil.copytree(self.solver_packages_path, repo_path)

        # verify that source fam exists
        src_fam = get_package_family_from_repository(pkg_name, repo_path)
        self.assertNotEqual(src_fam, None)

        # remove it, will fail as not empty
        with self.assertRaises(PackageRepositoryError):
            remove_package_family(pkg_name, repo_path)

        # remove all pydad packages
        versions = [pkg.version for pkg in src_fam.iter_packages()]
        for version in versions:
            self.assertTrue(remove_package(pkg_name, version, repo_path))

        # now it should remove successfully
        self.assertTrue(remove_package_family(pkg_name, repo_path))

        # verify that the fam no longer exists
        self.assertFalse(remove_package_family(pkg_name, repo_path))

        pkg_name2 = "pymum"

        # get another fam
        src_fam2 = get_package_family_from_repository(pkg_name2, repo_path)
        self.assertNotEqual(src_fam2, None)

        # force remove another fam
        self.assertTrue(remove_package_family(pkg_name2, repo_path,
                                              force=True))

        # verify that the fam no longer exists
        self.assertEqual(
            get_package_family_from_repository(pkg_name2, repo_path), None)