autoreqgen


Nameautoreqgen JSON
Version 0.1.28 PyPI version JSON
download
home_pagehttps://github.com/harichselvamc/AutoReqGen
SummarySmarter pipreqs alternative with code formatting and documentation generation
upload_time2025-08-29 20:21:52
maintainerNone
docs_urlNone
authorHarichselvam
requires_python>=3.8
licenseMIT
keywords pipreqs automation requirements docgen formatter
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## Core Badges


[![PyPI version](https://badge.fury.io/py/autoreqgen.svg)](https://badge.fury.io/py/autoreqgen)
[![PyPI Downloads](https://static.pepy.tech/badge/autoreqgen/week)](https://pepy.tech/projects/autoreqgen)
[![PyPI Downloads](https://static.pepy.tech/badge/autoreqgen/month)](https://pepy.tech/projects/autoreqgen)
[![PyPI Downloads](https://static.pepy.tech/badge/autoreqgen)](https://pepy.tech/projects/autoreqgen)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

# AutoReqGen

> ⚡ A smarter alternative to pipreqs — AutoReqGen scans your entire project recursively, accurately generates requirements.txt with exact versions, formats your code using tools like Black or isort, and even auto-generates documentation from your docstrings. One tool to automate and optimize your Python workflow.


##  Activity & Maintenance

[![GitHub last commit](https://img.shields.io/github/last-commit/harichselvamc/autoreqgen.svg)](https://github.com/harichselvamc/autoreqgen/commits/main)
[![GitHub issues](https://img.shields.io/github/issues/harichselvamc/autoreqgen.svg)](https://github.com/harichselvamc/autoreqgen/issues)
[![GitHub pull requests](https://img.shields.io/github/issues-pr/harichselvamc/autoreqgen.svg)](https://github.com/harichselvamc/autoreqgen/pulls)
[![Contributors](https://img.shields.io/github/contributors/harichselvamc/autoreqgen.svg)](https://github.com/harichselvamc/autoreqgen/graphs/contributors)

## Repo Stats

[![GitHub stars](https://img.shields.io/github/stars/harichselvamc/autoreqgen.svg)](https://github.com/harichselvamc/autoreqgen/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/harichselvamc/autoreqgen.svg)](https://github.com/harichselvamc/autoreqgen/network/members)
[![GitHub watchers](https://img.shields.io/github/watchers/harichselvamc/autoreqgen.svg)](https://github.com/harichselvamc/autoreqgen/watchers)

## Features

- Auto-generate requirements.txt with or without version numbers
- Filters standard library & local modules
- Format code using black, isort, or autopep8
- Auto-generate DOCUMENTATION.md from your codebase docstrings
- Live import watching with autoreqgen watch
- Add packages with autoreqgen add (auto-installs and appends)
- autoreqgen freeze to lock all installed packages (sorted & deduplicated)
- autoreqgen start to create a new virtual environment using system Pythons
- --as-json and --all flag support
- Auto detects .env files for configuration
- CLI aliases like g for generate, f for format, etc.

## Quickstart

### Install the package

```bash
pip install autoreqgen
```

### Scan your project

```bash
autoreqgen scan .
```

### Generate requirements.txt with version numbers

```bash
autoreqgen generate .
```

### Add a package and update requirements.txt

```bash
autoreqgen add requests
```

### Format the code using black

```bash
autoreqgen format black .
```

### Generate documentation

```bash
autoreqgen docs . --output docs.md
```

### Watch your project and update requirements.txt on change

```bash
autoreqgen watch .
```

### Start a new project virtual environment

```bash
autoreqgen start
```

### Freeze your current environment into a clean requirements.txt

```bash
autoreqgen freeze
```

## 📁 Example Structure

```
myproject/
├── main.py
├── utils/
│   └── helper.py
├── requirements.txt
├── DOCUMENTATION.md
```

## Detailed Usage

### Scanning Projects

Scan a project to identify all Python imports:

```bash
autoreqgen scan /path/to/project
```

### Generating Requirements

Generate a requirements.txt file with all necessary packages:

```bash
# Default (with version numbers)
autoreqgen generate /path/to/project

# Without version numbers
autoreqgen generate /path/to/project --no-versions

# Output as JSON
autoreqgen generate /path/to/project --as-json

# Include all imports (even standard library)
autoreqgen generate /path/to/project --all
```

### Dependency Management

Add packages to your project and requirements.txt:

```bash
# Add single package
autoreqgen add requests

# Add multiple packages
autoreqgen add requests pandas numpy

# Add with specific version
autoreqgen add "requests>=2.25.0"
```

Freeze your environment to create a reproducible requirements.txt:

```bash
autoreqgen freeze
```

### Code Formatting

Format your code using different tools:

```bash
# Format with black
autoreqgen format black /path/to/project

# Format with isort
autoreqgen format isort /path/to/project

# Format with autopep8
autoreqgen format autopep8 /path/to/project

# Chain formatters
autoreqgen format black,isort /path/to/project
```

### Documentation Generation

Generate documentation from your docstrings:

```bash
# Basic usage
autoreqgen docs /path/to/project

# Specify output file
autoreqgen docs /path/to/project --output API.md

# Generate for specific modules
autoreqgen docs /path/to/project --modules main.py,utils
```

### Live Watching

Watch your project for changes and automatically update requirements.txt:

```bash
# Watch project
autoreqgen watch /path/to/project

# Watch with specific interval (in seconds)
autoreqgen watch /path/to/project --interval 5

# Watch and format on change
autoreqgen watch /path/to/project --format black
```

### Project Initialization

Start a new Python project with a virtual environment:

```bash
# Create a new virtual environment in the current directory
autoreqgen start

# Specify Python version
autoreqgen start --python 3.10

# Create with specific packages
autoreqgen start --packages "requests pandas"
```

## Configuration

AutoReqGen can be configured using environment variables or `.env` files:

```
AUTOREQGEN_DEFAULT_FORMAT=black
AUTOREQGEN_IGNORE_DIRS=tests,examples
AUTOREQGEN_INCLUDE_DEV=true
AUTOREQGEN_VERBOSE=true
```
# Google Colab Compatibility Disclaimer

**AutoReqGen** is designed to run in standard Python environments (local, virtualenv, Conda, etc.). While many features work fine in Google Colab, there are some important limitations to be aware of:

## Features that **work in Colab**:
| Feature             | Status  | Description |
|---------------------|---------|-------------|
| `scan`              | ✅       | Scans Python files or projects to detect external imports. |
| `generate`          | ✅       | Generates `requirements.txt` from scanned imports. |
| `add <package>`     | ✅       | Installs a package and appends it to `requirements.txt`. |
| `freeze`            | ✅       | Freezes the current environment (via `pip freeze`) into `requirements.txt`. |
| `docs`              | ✅       | Extracts module, class, and function docstrings and generates markdown docs. |

## 🚫 Features that **do NOT work in Colab**:
| Feature             | Status  | Reason |
|---------------------|---------|--------|
| `start` (virtualenv creation) | ❌       | Google Colab does not allow creating or managing virtual environments. |
| `watch` (live import updates) | ❌       | `watchdog` cannot run in sandboxed Colab environments due to limited file system access and event monitoring. |

## 📌 Colab-Specific Handling
When you run `AutoReqGen` inside Google Colab:
- The `start` command is **disabled** to prevent errors.
- A clear warning will be shown to the user:
  ```
  ⚠️  Virtual environment creation is not supported in Google Colab.
  ```

## 💡 Tip
You can still install `AutoReqGen` in Colab and use it like this:

```bash
!pip install autoreqgen
!autoreqgen scan .
!autoreqgen generate .
!autoreqgen freeze
```

---

For full functionality, we recommend running **AutoReqGen** in a local or server-based Python environment (outside Colab).
## 🔌 Integration Examples

### Pre-commit Integration

Add to your `.pre-commit-config.yaml`:

```yaml
repos:
-   repo: local
    hooks:
    -   id: autoreqgen
        name: AutoReqGen
        entry: autoreqgen generate .
        language: system
        pass_filenames: false
```

### GitHub Actions Workflow

```yaml
name: Update Requirements

on:
  push:
    paths:
      - '**.py'

jobs:
  update-requirements:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: '3.10'
      - name: Install AutoReqGen
        run: pip install autoreqgen
      - name: Update requirements.txt
        run: autoreqgen generate .
      - name: Commit changes
        uses: EndBug/add-and-commit@v9
        with:
          message: 'chore: update requirements.txt'
          add: 'requirements.txt'
```

### Docker Usage

Example Dockerfile:

```dockerfile
FROM python:3.10-slim

WORKDIR /app

COPY . .

RUN pip install autoreqgen
RUN autoreqgen generate .
RUN pip install -r requirements.txt

CMD ["python", "main.py"]
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/harichselvamc/AutoReqGen",
    "name": "autoreqgen",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "pipreqs, automation, requirements, docgen, formatter",
    "author": "Harichselvam",
    "author_email": "Harichselvam <harichselvamc@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/64/ff/f64794ad18a5727ef3eba60c48740f3465c77045919ff9155ac6533d396e/autoreqgen-0.1.28.tar.gz",
    "platform": null,
    "description": "## Core Badges\n\n\n[![PyPI version](https://badge.fury.io/py/autoreqgen.svg)](https://badge.fury.io/py/autoreqgen)\n[![PyPI Downloads](https://static.pepy.tech/badge/autoreqgen/week)](https://pepy.tech/projects/autoreqgen)\n[![PyPI Downloads](https://static.pepy.tech/badge/autoreqgen/month)](https://pepy.tech/projects/autoreqgen)\n[![PyPI Downloads](https://static.pepy.tech/badge/autoreqgen)](https://pepy.tech/projects/autoreqgen)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n\n# AutoReqGen\n\n> \u26a1 A smarter alternative to pipreqs \u2014 AutoReqGen scans your entire project recursively, accurately generates requirements.txt with exact versions, formats your code using tools like Black or isort, and even auto-generates documentation from your docstrings. One tool to automate and optimize your Python workflow.\n\n\n##  Activity & Maintenance\n\n[![GitHub last commit](https://img.shields.io/github/last-commit/harichselvamc/autoreqgen.svg)](https://github.com/harichselvamc/autoreqgen/commits/main)\n[![GitHub issues](https://img.shields.io/github/issues/harichselvamc/autoreqgen.svg)](https://github.com/harichselvamc/autoreqgen/issues)\n[![GitHub pull requests](https://img.shields.io/github/issues-pr/harichselvamc/autoreqgen.svg)](https://github.com/harichselvamc/autoreqgen/pulls)\n[![Contributors](https://img.shields.io/github/contributors/harichselvamc/autoreqgen.svg)](https://github.com/harichselvamc/autoreqgen/graphs/contributors)\n\n## Repo Stats\n\n[![GitHub stars](https://img.shields.io/github/stars/harichselvamc/autoreqgen.svg)](https://github.com/harichselvamc/autoreqgen/stargazers)\n[![GitHub forks](https://img.shields.io/github/forks/harichselvamc/autoreqgen.svg)](https://github.com/harichselvamc/autoreqgen/network/members)\n[![GitHub watchers](https://img.shields.io/github/watchers/harichselvamc/autoreqgen.svg)](https://github.com/harichselvamc/autoreqgen/watchers)\n\n## Features\n\n- Auto-generate requirements.txt with or without version numbers\n- Filters standard library & local modules\n- Format code using black, isort, or autopep8\n- Auto-generate DOCUMENTATION.md from your codebase docstrings\n- Live import watching with autoreqgen watch\n- Add packages with autoreqgen add (auto-installs and appends)\n- autoreqgen freeze to lock all installed packages (sorted & deduplicated)\n- autoreqgen start to create a new virtual environment using system Pythons\n- --as-json and --all flag support\n- Auto detects .env files for configuration\n- CLI aliases like g for generate, f for format, etc.\n\n## Quickstart\n\n### Install the package\n\n```bash\npip install autoreqgen\n```\n\n### Scan your project\n\n```bash\nautoreqgen scan .\n```\n\n### Generate requirements.txt with version numbers\n\n```bash\nautoreqgen generate .\n```\n\n### Add a package and update requirements.txt\n\n```bash\nautoreqgen add requests\n```\n\n### Format the code using black\n\n```bash\nautoreqgen format black .\n```\n\n### Generate documentation\n\n```bash\nautoreqgen docs . --output docs.md\n```\n\n### Watch your project and update requirements.txt on change\n\n```bash\nautoreqgen watch .\n```\n\n### Start a new project virtual environment\n\n```bash\nautoreqgen start\n```\n\n### Freeze your current environment into a clean requirements.txt\n\n```bash\nautoreqgen freeze\n```\n\n## \ud83d\udcc1 Example Structure\n\n```\nmyproject/\n\u251c\u2500\u2500 main.py\n\u251c\u2500\u2500 utils/\n\u2502   \u2514\u2500\u2500 helper.py\n\u251c\u2500\u2500 requirements.txt\n\u251c\u2500\u2500 DOCUMENTATION.md\n```\n\n## Detailed Usage\n\n### Scanning Projects\n\nScan a project to identify all Python imports:\n\n```bash\nautoreqgen scan /path/to/project\n```\n\n### Generating Requirements\n\nGenerate a requirements.txt file with all necessary packages:\n\n```bash\n# Default (with version numbers)\nautoreqgen generate /path/to/project\n\n# Without version numbers\nautoreqgen generate /path/to/project --no-versions\n\n# Output as JSON\nautoreqgen generate /path/to/project --as-json\n\n# Include all imports (even standard library)\nautoreqgen generate /path/to/project --all\n```\n\n### Dependency Management\n\nAdd packages to your project and requirements.txt:\n\n```bash\n# Add single package\nautoreqgen add requests\n\n# Add multiple packages\nautoreqgen add requests pandas numpy\n\n# Add with specific version\nautoreqgen add \"requests>=2.25.0\"\n```\n\nFreeze your environment to create a reproducible requirements.txt:\n\n```bash\nautoreqgen freeze\n```\n\n### Code Formatting\n\nFormat your code using different tools:\n\n```bash\n# Format with black\nautoreqgen format black /path/to/project\n\n# Format with isort\nautoreqgen format isort /path/to/project\n\n# Format with autopep8\nautoreqgen format autopep8 /path/to/project\n\n# Chain formatters\nautoreqgen format black,isort /path/to/project\n```\n\n### Documentation Generation\n\nGenerate documentation from your docstrings:\n\n```bash\n# Basic usage\nautoreqgen docs /path/to/project\n\n# Specify output file\nautoreqgen docs /path/to/project --output API.md\n\n# Generate for specific modules\nautoreqgen docs /path/to/project --modules main.py,utils\n```\n\n### Live Watching\n\nWatch your project for changes and automatically update requirements.txt:\n\n```bash\n# Watch project\nautoreqgen watch /path/to/project\n\n# Watch with specific interval (in seconds)\nautoreqgen watch /path/to/project --interval 5\n\n# Watch and format on change\nautoreqgen watch /path/to/project --format black\n```\n\n### Project Initialization\n\nStart a new Python project with a virtual environment:\n\n```bash\n# Create a new virtual environment in the current directory\nautoreqgen start\n\n# Specify Python version\nautoreqgen start --python 3.10\n\n# Create with specific packages\nautoreqgen start --packages \"requests pandas\"\n```\n\n## Configuration\n\nAutoReqGen can be configured using environment variables or `.env` files:\n\n```\nAUTOREQGEN_DEFAULT_FORMAT=black\nAUTOREQGEN_IGNORE_DIRS=tests,examples\nAUTOREQGEN_INCLUDE_DEV=true\nAUTOREQGEN_VERBOSE=true\n```\n# Google Colab Compatibility Disclaimer\n\n**AutoReqGen** is designed to run in standard Python environments (local, virtualenv, Conda, etc.). While many features work fine in Google Colab, there are some important limitations to be aware of:\n\n## Features that **work in Colab**:\n| Feature             | Status  | Description |\n|---------------------|---------|-------------|\n| `scan`              | \u2705       | Scans Python files or projects to detect external imports. |\n| `generate`          | \u2705       | Generates `requirements.txt` from scanned imports. |\n| `add <package>`     | \u2705       | Installs a package and appends it to `requirements.txt`. |\n| `freeze`            | \u2705       | Freezes the current environment (via `pip freeze`) into `requirements.txt`. |\n| `docs`              | \u2705       | Extracts module, class, and function docstrings and generates markdown docs. |\n\n## \ud83d\udeab Features that **do NOT work in Colab**:\n| Feature             | Status  | Reason |\n|---------------------|---------|--------|\n| `start` (virtualenv creation) | \u274c       | Google Colab does not allow creating or managing virtual environments. |\n| `watch` (live import updates) | \u274c       | `watchdog` cannot run in sandboxed Colab environments due to limited file system access and event monitoring. |\n\n## \ud83d\udccc Colab-Specific Handling\nWhen you run `AutoReqGen` inside Google Colab:\n- The `start` command is **disabled** to prevent errors.\n- A clear warning will be shown to the user:\n  ```\n  \u26a0\ufe0f  Virtual environment creation is not supported in Google Colab.\n  ```\n\n## \ud83d\udca1 Tip\nYou can still install `AutoReqGen` in Colab and use it like this:\n\n```bash\n!pip install autoreqgen\n!autoreqgen scan .\n!autoreqgen generate .\n!autoreqgen freeze\n```\n\n---\n\nFor full functionality, we recommend running **AutoReqGen** in a local or server-based Python environment (outside Colab).\n## \ud83d\udd0c Integration Examples\n\n### Pre-commit Integration\n\nAdd to your `.pre-commit-config.yaml`:\n\n```yaml\nrepos:\n-   repo: local\n    hooks:\n    -   id: autoreqgen\n        name: AutoReqGen\n        entry: autoreqgen generate .\n        language: system\n        pass_filenames: false\n```\n\n### GitHub Actions Workflow\n\n```yaml\nname: Update Requirements\n\non:\n  push:\n    paths:\n      - '**.py'\n\njobs:\n  update-requirements:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v3\n      - uses: actions/setup-python@v4\n        with:\n          python-version: '3.10'\n      - name: Install AutoReqGen\n        run: pip install autoreqgen\n      - name: Update requirements.txt\n        run: autoreqgen generate .\n      - name: Commit changes\n        uses: EndBug/add-and-commit@v9\n        with:\n          message: 'chore: update requirements.txt'\n          add: 'requirements.txt'\n```\n\n### Docker Usage\n\nExample Dockerfile:\n\n```dockerfile\nFROM python:3.10-slim\n\nWORKDIR /app\n\nCOPY . .\n\nRUN pip install autoreqgen\nRUN autoreqgen generate .\nRUN pip install -r requirements.txt\n\nCMD [\"python\", \"main.py\"]\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Smarter pipreqs alternative with code formatting and documentation generation",
    "version": "0.1.28",
    "project_urls": {
        "Changelog": "https://github.com/harichselvamc/AutoReqGen/releases",
        "Documentation": "https://github.com/harichselvamc/AutoReqGen#readme",
        "Homepage": "https://github.com/harichselvamc/AutoReqGen",
        "Issues": "https://github.com/harichselvamc/AutoReqGen/issues",
        "Repository": "https://github.com/harichselvamc/AutoReqGen",
        "Source": "https://github.com/harichselvamc/AutoReqGen"
    },
    "split_keywords": [
        "pipreqs",
        " automation",
        " requirements",
        " docgen",
        " formatter"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6a6d79a0d76d74b045fb0958e8d75d4dc023da988ba87ebfeee3e52e50f5e7eb",
                "md5": "bd24c998a4e0e86e5591ae7e8efe0f64",
                "sha256": "2b99d6b6595013e9a579bfa6fa36f9296bab542a1f05a38d880aab4a04efea43"
            },
            "downloads": -1,
            "filename": "autoreqgen-0.1.28-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bd24c998a4e0e86e5591ae7e8efe0f64",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 19588,
            "upload_time": "2025-08-29T20:21:51",
            "upload_time_iso_8601": "2025-08-29T20:21:51.424260Z",
            "url": "https://files.pythonhosted.org/packages/6a/6d/79a0d76d74b045fb0958e8d75d4dc023da988ba87ebfeee3e52e50f5e7eb/autoreqgen-0.1.28-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "64fff64794ad18a5727ef3eba60c48740f3465c77045919ff9155ac6533d396e",
                "md5": "a5d3047f699115108a3ce3a5d98bf52d",
                "sha256": "5ab3f07072dbc6cfe436354e0d3d4e2255e3c29fff39b0408ddf06667ca789db"
            },
            "downloads": -1,
            "filename": "autoreqgen-0.1.28.tar.gz",
            "has_sig": false,
            "md5_digest": "a5d3047f699115108a3ce3a5d98bf52d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 22764,
            "upload_time": "2025-08-29T20:21:52",
            "upload_time_iso_8601": "2025-08-29T20:21:52.846197Z",
            "url": "https://files.pythonhosted.org/packages/64/ff/f64794ad18a5727ef3eba60c48740f3465c77045919ff9155ac6533d396e/autoreqgen-0.1.28.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-29 20:21:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "harichselvamc",
    "github_project": "AutoReqGen",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "autoreqgen"
}
        
Elapsed time: 2.39748s