Skip to main content

Smart pip requirements installer - Midna manages your installations

Project description

codecov Security Scan

Midna - The Smart Python Package Assistant

An intelligent tool that automatically manages your Python dependencies by analyzing your actual code usage.

What is Midna?

Midna - The smart Python package assistant that automatically discovers what packages your Python project uses by scanning your code for imports. No more manually maintaining requirements.txt files or trying to remember what you installed.

midna                    # Auto-discovers and installs what you need
midna --dry-run          # See what it would install first
midna --uninstall        # Remove packages you don't use anymore

Why Midna exists

Common Python package management challenges:

  • Manual maintenance of requirements.txt files
  • Difficulty tracking essential package dependencies
  • Unnecessary installation of unused packages
  • Inconsistencies between requirements and actual code usage

Midna addresses these challenges through intelligent code analysis and automated dependency management, ensuring your project only includes the packages it actually needs.

Installation

Simply run:

pip install midna

Once installed, Midna is available system-wide and ready to optimize your Python package management.

How to use it

Auto-discovery (the main feature)

midna                    # Install missing packages
midna --dry-run          # Preview what would be installed
midna --uninstall        # Remove unused packages
midna --verbose          # See what it's doing

Traditional mode (if you have requirements files)

midna requirements.txt
midna requirements.txt --dry-run

How it works

  1. Looks for requirements files first - requirements.txt, pyproject.toml, setup.py, etc.
  2. If none found, scans your .py files for import statements
  3. Filters out standard library stuff - only suggests real packages
  4. Shows you what it found and what needs to be installed
  5. Does the installation (or uninstallation) if you want

Example output

$ midna --dry-run
Auto-discovering requirements...
Found 4 packages (import analysis)

Already installed (1):
  + requests

Missing packages (3):
  - click
  - numpy  
  - pandas

DRY RUN: Would install the following packages:
  - click
  - numpy
  - pandas

Commands

midna [requirements_file] [options]

Options:
  --uninstall, -u    Remove packages instead of installing
  --dry-run, -n      Show what would happen without doing it
  --verbose, -v      More detailed output
  --version          Show version
  --help, -h         This help message

Key Features

  • Intelligent Package Detection - Installs only required dependencies
  • Standard Library Awareness - Automatically excludes built-in Python modules
  • Smart Directory Filtering - Ignores non-project directories (.git, __pycache__, .venv)
  • Multi-Format Support - Compatible with requirements.txt, pyproject.toml, and Pipfile
  • Safe Execution - Provides dry-run mode for verification
  • Robust Error Handling - Ensures reliable operation across diverse codebases

Security

Midna implements automated security scanning to ensure safe package management:

  • Dependency Vulnerability Scanning - Weekly checks for known CVEs using pip-audit
  • Code Security Analysis - Bandit security linting on every commit
  • Secure Subprocess Execution - Explicit shell=False in all pip calls
  • Minimal Attack Surface - Only tomli dependency for TOML parsing

Security reports are automatically generated and can be found in the Actions tab.

For security-related issues, please see SECURITY.md.

Use cases

New project setup:

git clone some-repo
cd some-repo
midna  # installs exactly what the code needs

Clean up your environment:

midna --uninstall --dry-run  # see what can be removed
midna --uninstall            # actually remove it

Check what your project uses:

midna --dry-run --verbose  # detailed analysis

Project structure

midna/
├── core.py          # Main CLI logic
├── discovery.py     # Auto-discovery engine  
├── parser.py        # Requirements file parsing
├── installer.py     # Package installation
├── uninstaller.py   # Package removal
├── checker.py       # Check what's installed
└── logger.py        # Logging

Requirements

  • Python 3.8 or newer
  • pip (comes with Python)
  • That's it - no external dependencies

Contributing

Found a bug or want to add a feature?

  1. Fork it
  2. Create a branch: git checkout -b my-feature
  3. Install dev dependencies: pip install -e ".[dev]"
  4. Run tests: pytest tests/
  5. Run security checks: bandit -r midna/ -x tests,test
  6. Submit a PR

All contributions are automatically tested for security issues using Bandit and pip-audit.

License

Apache 2.0 - see LICENSE

Author

Jassem Manita
GitHub: @jassem-manita
Email: jasemmanita00 [at] gmail.com

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

midna-1.0.6.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

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

midna-1.0.6-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file midna-1.0.6.tar.gz.

File metadata

  • Download URL: midna-1.0.6.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for midna-1.0.6.tar.gz
Algorithm Hash digest
SHA256 da90f7f1957b20594a38fad1883c1745fadcbd1bd38bfef212612327403eee8d
MD5 5047413cfafa15fa62a5c5a5e522aaeb
BLAKE2b-256 714708cd721b454d062dd49d0ccbdb3986319ecb826296b61adaf8a9dae11a61

See more details on using hashes here.

Provenance

The following attestation bundles were made for midna-1.0.6.tar.gz:

Publisher: release.yml on jassem-manita/midna

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file midna-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: midna-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for midna-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9ac171fb165d82d830670faa0584e506f0154e5eef96267cd74032462a90e5e9
MD5 978b9f02672a86aa502ffc2f680cfc4f
BLAKE2b-256 9cd22d91a40e224fe0f6aae951d48fad4593eb4615a6acdbaebb8b149b33d65e

See more details on using hashes here.

Provenance

The following attestation bundles were made for midna-1.0.6-py3-none-any.whl:

Publisher: release.yml on jassem-manita/midna

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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