Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyPI Package Analyzer

Python Version License: MIT

PyPI Package Analyzer is a command-line tool written in Python to fetch, analyze, and store metadata about packages available on the Python Package Index (PyPI). It helps in gathering quick insights about Python libraries.

Features

  • Fetch Data: Retrieves comprehensive package metadata directly from the official PyPI JSON API.
  • Analyze: Extracts key information like latest version, author, license, summary, Python version requirements, etc.
  • Store Results:
    • Saves the raw, complete JSON response from PyPI for each package (optional).
    • Saves the processed, summarized analysis into a clean CSV file for easy viewing and further processing.
  • Command-Line Interface: Easy-to-use CLI built with argparse for specifying packages and output options.
  • Robustness: Includes error handling for common issues like network errors, timeouts, and non-existent packages.
  • Logging: Provides informative logs during execution.
  • Testing: Includes unit tests using pytest and pytest-mock to ensure core functionality works as expected.
  • Modularity: Code is structured into logical components (fetching, analyzing, storage).

How it Works

  1. The tool takes a list of package names as input via the command line.
  2. For each package name, it constructs the PyPI JSON API URL (e.g., https://pypi.org/pypi/requests/json).
  3. It sends an HTTP GET request to the URL using the requests library.
  4. If the request is successful, it parses the JSON response. Error handling is in place for network issues or if the package isn't found (404).
  5. (Optional) The raw JSON data for all successfully fetched packages is saved to a single JSON file.
  6. The collected raw data is processed using the pandas library. Key fields are extracted into a structured format.
  7. The processed data is organized into a pandas DataFrame.
  8. This DataFrame, containing the summarized analysis, is saved to a CSV file in the data/ directory.

Installation

Follow these steps to set up the project locally:

  1. Clone the repository:

    git clone <https://github.com/stex4cs/PyPi-Analyzer.git> 
    cd pypi_analyzer
  2. Create and activate a virtual environment: This isolates project dependencies.

    # Create the environment (use python3 if python maps to Python 2)
    python -m venv venv
    
    # Activate the environment:
    # On Windows (Git Bash or WSL):
    # source venv/Scripts/activate
    # On Windows (Command Prompt/PowerShell):
    # .\venv\Scripts\activate
    # On macOS/Linux:
    source venv/bin/activate

    You should see (venv) at the beginning of your terminal prompt.

  3. Install dependencies:

    pip install -r requirements.txt

Usage

The tool is run from the command line within the project's root directory. Make sure your virtual environment is activated.

Basic Command:

python -m pypi_analyzer.main --packages <package1> <package2> ...

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages