CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-pip

The PyPA recommended tool for installing Python packages.

91

1.07x
Overview
Eval results
Files

task.mdevals/scenario-1/

Safe Package Uninstaller

Build a Python utility that safely uninstalls Python packages with automatic rollback on failure.

Requirements

Implement a script safe_uninstall.py that uninstalls Python packages with automatic rollback on failure.

Behavior

  1. Accept one or more package names as command-line arguments
  2. Uninstall each package sequentially
  3. If any uninstallation fails, automatically rollback (reinstall) all previously uninstalled packages from that run
  4. Exit with code 0 on complete success, code 1 if rollback occurred

Example Usage

python safe_uninstall.py requests urllib3
# If urllib3 fails, requests should be automatically reinstalled

Test Cases

  • Given package "requests" is installed, uninstalling it succeeds and the package is removed @test
  • Given packages "requests" and "nonexistent-pkg" are provided, when "nonexistent-pkg" fails, "requests" is rolled back and remains installed @test
  • Given no packages are provided as arguments, the script exits with helpful usage information @test

Implementation

@generates

API

"""
Safe package uninstaller with rollback capability.

This module provides a command-line utility to safely uninstall Python packages
with automatic rollback if any uninstallation fails.
"""

def uninstall_packages(packages: list[str]) -> tuple[bool, list[str], list[str]]:
    """
    Uninstall packages with rollback on failure.

    Args:
        packages: List of package names to uninstall

    Returns:
        Tuple of (success, uninstalled_packages, failed_packages)
        - success: True if all packages uninstalled successfully, False otherwise
        - uninstalled_packages: List of packages that were successfully uninstalled
        - failed_packages: List of packages that failed to uninstall
    """
    pass

def main() -> int:
    """
    Main entry point for the command-line utility.

    Returns:
        Exit code: 0 for success, 1 for failure/rollback
    """
    pass

if __name__ == "__main__":
    exit(main())

Dependencies { .dependencies }

pip { .dependency }

Python package installer with uninstallation and rollback capabilities.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/pypi-pip

tile.json