Skip to main content

Smart pip requirements installer - Midna manages your installations

Project description

Downloads codecov License

Midna - The Smart Python Package Assistant

A CLI tool that automatically manages your Python dependencies by analyzing your actual code usage.

Note: Midna is a command-line tool, not a Python library. Install it with pip install midna and use it as a CLI command.

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 (only tomli for TOML parsing)

Development Setup

Want to contribute or modify Midna? Here's how to set up your development environment:

1. Clone the repository

git clone https://github.com/viraxi/midna.git
cd midna

2. Create a virtual environment

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

3. Install in editable mode with dev dependencies

pip install -e ".[dev]"

This installs:

  • pytest and pytest-cov for testing
  • black, flake8, isort, mypy for code quality
  • build and twine for packaging

4. Run tests

# Run all tests
pytest tests/

# Run with coverage
pytest tests/ --cov=midna --cov-report=html

# Run security checks
bandit -r midna/ -x tests,test
pip-audit

5. Code formatting

# Format code
black midna/ tests/
isort midna/ tests/

# Check linting
flake8 midna/ tests/ --max-line-length=100

Contributing

We welcome contributions! Whether it's bug fixes, new features, documentation improvements, or suggestions, your help is appreciated.

Quick Start for Contributors

  1. Fork the repository on GitHub
  2. Create a feature branch: git checkout -b feature/your-feature-name
  3. Make your changes following our code style guidelines
  4. Run tests and checks: Ensure all tests pass and code is formatted
  5. Commit your changes: Use conventional commit messages
  6. Submit a Pull Request with a clear description

Detailed Guidelines

For comprehensive contribution guidelines, including:

  • Development environment setup
  • Code style and formatting rules
  • Testing procedures
  • Commit message conventions
  • Pull request process

Please see CONTRIBUTING.md.

Reporting Issues

Found a bug or have a feature request? Open an issue with:

  • Clear description of the problem or feature
  • Steps to reproduce (for bugs)
  • Expected vs actual behavior
  • Your environment (Python version, OS)

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

Code of Conduct

This project adheres to a Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to jasemmanita@viraxi.tech or contact@viraxi.tech.

License

Apache 2.0 - see LICENSE

Author

Jassem Manita
GitHub: @viraxi Maintainer Email: jasemmanita@viraxi.tech Org Contact: contact@viraxi.tech

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.7.tar.gz (24.0 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.7-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: midna-1.0.7.tar.gz
  • Upload date:
  • Size: 24.0 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.7.tar.gz
Algorithm Hash digest
SHA256 e8cb5930c4866b9230aa8784e170d7da9d1f335ebe1f8d3125c56fa7a6c5ac77
MD5 c4d33fad990afaca2672e34d5fe8a458
BLAKE2b-256 63513f98527d8cf6357a87812bcccc54123b9426aa0ada663a11b5eefbfe3dc3

See more details on using hashes here.

Provenance

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

Publisher: release.yml on viraxi/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.7-py3-none-any.whl.

File metadata

  • Download URL: midna-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 24.4 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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d12a27418db7710feb57a1e740e4472a48be88c4d666232167f8d65d44ac9e6f
MD5 33838de49ad4a54e944e81952ab3c8a8
BLAKE2b-256 6f8405ee6bbbfec9ad459d630a529081e253fb138b04f752e43896f15795833a

See more details on using hashes here.

Provenance

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

Publisher: release.yml on viraxi/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