Skip to main content

Generate requirements.txt for Python projects, using an AI to resolve complex and ambiguous dependencies.

Project description

AI-Reqs: The Intelligent requirements.txt Generator

Tired of messy requirements.txt files? Frustrated that tools like pipreqs fail on your complex data science projects and Jupyter Notebooks?

ai-reqs is a next-generation dependency scanner for Python that uses the power of Google's Gemini AI to solve the problems other tools can't. It intelligently scans your project, including .py files and .ipynb notebooks, and generates a clean, accurate requirements.txt file.

Why is ai-reqs better?

Feature pipreqs / pipreqsnb ai-reqs (This Tool)
Notebook Support Often fails or requires a separate fork (pipreqsnb). Yes, built-in.
Dependency Resolution Uses a static, internal list of common packages. 🧠 AI-Powered. Uses Gemini to resolve even the most obscure or confusing imports (cv2 -> opencv-python, PIL -> Pillow).
Robustness Can crash on files with non-standard characters. Handles encoding errors gracefully.
Future-Proof Needs to be updated manually for new packages. 🚀 Always up-to-date. The AI can identify new packages as they are released.

Installation

pip install ai-reqs

Quick Start

  1. Get a Gemini API Key:

  2. Set the API Key: You can either set it as an environment variable (recommended) or pass it as an argument.

    # Recommended: Set as an environment variable
    export GEMINI_API_KEY="YOUR_API_KEY_HERE"
    
  3. Run ai-reqs: Navigate to your project's root directory in your terminal and run the command:

    ai-reqs
    

    That's it! A clean requirements.txt will be generated in your project directory.

Usage

The command-line interface is simple and straightforward.

Usage

usage: ai-reqs [-h] [--path PATH] [--api-key API_KEY]

Generate a requirements.txt file for a Python project using AI for dependency resolution.

options:
  -h, --help         show this help message and exit
  --path PATH        The path to the project directory to scan. Defaults to
                     the current directory.
  --api-key API_KEY  Your Gemini API key. Can also be set via the
                     GEMINI_API_KEY environment variable.

How It Works

The tool scans all Python scripts and Jupyter Notebooks in your project to find all import statements. It then uses a hybrid approach to find the correct package for each import:

  1. It first checks your local Python environment's metadata.
  2. For any import it can't resolve locally (like sklearn or cv2), it queries the Gemini API to get the correct pip package name.
  3. Finally, it generates a requirements.txt file with the correct package names and their currently installed versions.

Contributing

Contributions are welcome! Please feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License.

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

ai_reqs-0.1.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

ai_reqs-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file ai_reqs-0.1.0.tar.gz.

File metadata

  • Download URL: ai_reqs-0.1.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.8

File hashes

Hashes for ai_reqs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5854f431937c1a7a931b403615ec599868bb4af7ab4e10c2482309754c145244
MD5 73a2337af79e3ec9311e5315e229d422
BLAKE2b-256 2b9e455f7e5795def4947884f7a3a427b7d87c902bc9499f9f6169476c64f31e

See more details on using hashes here.

File details

Details for the file ai_reqs-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ai_reqs-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.8

File hashes

Hashes for ai_reqs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 25b490ee74829d3214a53862b0e0b8394fa86328f54d2aaf15c442e97f1e2d3d
MD5 e25642335817abbf7b34f6e587c5ccbb
BLAKE2b-256 f513fb7350e4fa26968542f0a754a53d7a67f98f38f8dc435ba43c778e0dc53d

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