Skip to main content

ScanReq

PyPI - Version PyPI - Python Version Build Status Code Style

ScanReq - Python tool to scan all unused packages in requirements.txt file for your project.

Background

One popular tool for checking requirements in a Python project is pipdeptree. However, the problem arises when we don't know which packages listed in the requirements.txt file are actually being used in the project or not. It's easy to check if your project is small, but as your project grows larger, it becomes a headache to check one by one.

So, this tool comes in handy for easily identifying which exact packages are actually unused in our project.

Benefits

  1. Save Money: Remove unused dependencies to lower hosting costs.
  2. Speed Up: Faster installation and build times mean quicker development.
  3. Use Resources Wisely: Free up disk and memory space by removing what you don't use.
  4. Easier Maintenance: Keep your project cleaner and simpler for easier management.
  5. Focus Better: Work with only what you need, enhancing productivity.
  6. Update Efficiently: Ensure your dependencies are up-to-date for smoother compatibility.
  7. Stay Safe: Reduce the chance of security vulnerabilities by trimming unnecessary dependencies.
  8. Stay Legal: Avoid licensing issues by managing dependencies more effectively.
  9. Work Together: Simplify collaboration with a consistent set of dependencies.
  10. Code Better: Keep your documentation and codebase cleaner for improved quality.

Installation

pip3 install scanreq

Usage

Note: Ensure you're working on python environment & already installed all your project requirements.txt

scanreq -r requirements.txt -p . -o unused-requirements.txt -i black,flake8
[i] Please wait! It may take few minutes to complete...
[i] Scanning unused packages:
 1.  Module: rcssmin                       -> Package: rcssmin
 2.  Module: model_utils                   -> Package: django-model-utils
 3.  Module: pinax_theme_bootstrap         -> Package: pinax-theme-bootstrap
 4.  Module: phonenumbers                  -> Package: phonenumbers
cat unused-requirements.txt
rcssmin
django-model-utils
pinax-theme-bootstrap
phonenumbers

Cool right? 😎

scanreq --help
usage: scanreq [-h] [-r REQUIREMENTS] [-p PATH] [-o OUTPUT] [-i IGNORED_PACKAGES]

Scan for unused Python packages.

optional arguments:
  -h, --help            show this help message and exit
  -r REQUIREMENTS, --requirements REQUIREMENTS
                        Path to the requirements.txt file to read packages from.
  -p PATH, --path PATH  Project path to scan for unused packages (default: current directory).
  -o OUTPUT, --output OUTPUT
                        Path to the output file where unused packages will be saved.
  -i IGNORED_PACKAGES, --ignored-packages IGNORED_PACKAGES
                        Comma separated list of package names to be ignored.

Note: Don't forget to cross-check the unused packages after finding them, because sometimes they are used in different cases without being imported in the code. For example: argon2-cffi used in settings.PASSWORD_HASHERS = ["django.contrib.auth.hashers.Argon2PasswordHasher", ...] for Django.

ToDo List

  • Support argument parser (command arguments)
    • Directory to scan
    • Requirement file to scan
    • Option to write the output of unused packages
    • Option to exclude or ignore some packages
    • Option to auto replace the package from requirements.txt file
  • Support CLI - make it as a command
  • Write some tests
  • Publish to PyPi
  • Support multiple python versions
  • Support multiple devices (Linux, Macbook, and Windows)
  • Support scan the pyproject.toml

Metadata

Release files for scanreq 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scanreq 0.0.9
File Size Uploaded Provenance
scanreq-0.0.9.tar.gz 9.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for scanreq 0.0.9
File Interpreter ABI Platform
scanreq-0.0.9-py3-none-any.whl Python 3 none any Details

Total release size: 16.7 kB

Release files / scanreq-0.0.9.tar.gz

Download URL scanreq-0.0.9.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
18030f232615d6761cdf18fe1702930c654f8f1214362c5c58e63b34c624d6d2
BLAKE2b-256 checksum
How to use checksums
0f51d7619dd275d3fb009fcaaeb08b2c8860dc4911805243b23b7be5a4cbd0a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.27.0

Release files / scanreq-0.0.9-py3-none-any.whl

Download URL scanreq-0.0.9-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
872d839d2f8fd84ac1bbfac82dd523a4af00b010538ece441524ff35e8acf269
BLAKE2b-256 checksum
How to use checksums
ad47977002e4d2bf002517489337acd23bd286cc90eecdd0b111336d10204db3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.27.0

Security for scanreq 0.0.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page