Skip to main content

Safe, typo-aware package installer for Python.

Project description

pkg-guard

PyPI version License: MIT

pkg-guard is a smart, typo-aware CLI wrapper for pip install — designed to prevent installing the wrong packages (e.g., reqeusts instead of requests).

It checks PyPI before installing, offers fuzzy suggestions, and lets you interactively choose the correct package with arrow keys — just like vite or npm init.


Features

✅ Detects misspelled packages before install
✅ Fuzzy matching & intelligent suggestions (powered by RapidFuzz)
✅ Interactive selection with arrow keys (InquirerPy)
✅ Spinner feedback using Rich
✅ Caching for faster lookups
✅ Extensible architecture (future support for npm, cargo, etc.)


Installation

From PyPI (after release)

pip install pkg-guard

From source (for developers)

git clone https://github.com/Prasad2357/pkg-guard
cd pkg-guard
pip install -e .

Usage

pkg-guard install reqeusts

Example

pkg-guard  checking PyPI for package: reqeusts ...
✖ Not found on PyPI: reqeusts

? Select package to install instead of 'reqeusts':
   requests
    request
    regex
    flask
    Other (type manually)
    Skip
  • Arrow keys to navigate
  • Press Enter to confirm
  • Type manually if your package isn’t listed

How it Works

  • Checks if the given package exists on PyPI

  • If not found, loads a local list of popular packages

  • Uses fuzzy matching (WRatio) to find closest matches

  • Presents them interactively via InquirerPy

  • Safely installs the chosen package with pip

Project Structure

pkg_guard/
├── __main__.py          # Entry point for `python -m pkg_guard
├── cli.py               # CLI definitions (Typer app)
│
├── core/
│   ├── installer.py     # Main install workflow   └── pypi_utils.py    # PyPI querying, caching, suggestions
│
└── ui/
    ├── console.py       # Rich-based spinner & console
    └── prompts.py       # Interactive fuzzy selection

Tech Stack

Component Library/Framework
CLI Framework Typer
Interactive Prompts InquirerPy
Fuzzy Matching RapidFuzz
Console UI Rich
HTTP Requests Requests

Development

Run in dev mode:

python -m pkg_guard install flask

Run linting (optional):

pip install black
black pkg_guard

Contributing

Contributions are welcome!
Feel free to fork this repo, open issues, or submit PRs.

License

This project is licensed under the terms of the MIT License — see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pkg_guard-0.1.2.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pkg_guard-0.1.2-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file pkg_guard-0.1.2.tar.gz.

File metadata

  • Download URL: pkg_guard-0.1.2.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for pkg_guard-0.1.2.tar.gz
Algorithm Hash digest
SHA256 da85fe135c9f0cc83b2d07e05b78e5d3de8c070c62592d3c3639b9c7f45bf29e
MD5 f1c750e5316c36dfa2c1886c4b064e06
BLAKE2b-256 e3c313b5895104cc607e86ac6187b15ad28ecfcc7836ab2b76cba9cff6cb227d

See more details on using hashes here.

File details

Details for the file pkg_guard-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pkg_guard-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for pkg_guard-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6d76addf17cbfc397434e31cd5744ddffb4fff67563d25caf20dd3e16c900edc
MD5 ed22fc8b964c6f90d9afeff6ae06f73f
BLAKE2b-256 29ce2c50dd6b00169d86353ba42270f1d47e7610f55dd7e18747f9104f841f10

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page