The PyPA recommended tool for installing Python packages.
91
Build a command-line tool that helps users manage their Python package manager's cache.
Python package managers maintain a cache to speed up installations. Your tool should provide a simple interface to query and manage this cache, helping users understand cache usage and free up disk space when needed.
The tool must provide functionality to:
The tool must support:
The tool must allow:
The tool must support:
Your tool should support the following commands:
# Show cache directory location
python cache_manager.py info --directory
# Show cache statistics
python cache_manager.py info --stats
# List all cached items
python cache_manager.py list
# List items matching a pattern
python cache_manager.py list --pattern "numpy*"
# Remove items matching a pattern
python cache_manager.py remove --pattern "old-package*"
# Remove items with confirmation skip
python cache_manager.py remove --pattern "temp*" --yes
# Purge all cache
python cache_manager.py purge
# Purge without confirmation
python cache_manager.py purge --yes@generates
"""
Package cache management utility.
"""
import argparse
from typing import Optional, List, Dict
class CacheManager:
"""Manages package cache operations."""
def get_cache_directory(self) -> str:
"""
Returns the path to the package cache directory.
Returns:
str: Absolute path to the cache directory
"""
pass
def get_cache_stats(self) -> Dict[str, any]:
"""
Returns cache statistics.
Returns:
Dict with keys:
- 'item_count': Number of cached items
- 'total_size': Total size in bytes
"""
pass
def list_cached_items(self, pattern: Optional[str] = None) -> List[Dict[str, any]]:
"""
Lists cached wheel files, optionally filtered by pattern.
Args:
pattern: Optional glob pattern to filter items (e.g., "numpy*")
Returns:
List of dicts with keys:
- 'name': Package name
- 'filename': Full filename
- 'size': Size in bytes
"""
pass
def remove_cached_items(self, pattern: str, confirm: bool = True) -> Dict[str, any]:
"""
Removes cached items matching the pattern.
Args:
pattern: Glob pattern to match items for removal
confirm: If True, prompts for confirmation before removal
Returns:
Dict with keys:
- 'removed_count': Number of items removed
- 'space_freed': Bytes freed
"""
pass
def purge_cache(self, confirm: bool = True) -> Dict[str, any]:
"""
Removes all cached items.
Args:
confirm: If True, prompts for confirmation before purging
Returns:
Dict with keys:
- 'removed_count': Number of items removed
- 'space_freed': Bytes freed
"""
pass
def main():
"""Main entry point for the CLI."""
pass
if __name__ == "__main__":
main()Provides Python package management and caching functionality.
Install with Tessl CLI
npx tessl i tessl/pypi-pipevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10