Skip to content

fix: Make magika an optional dependency #1296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mohiuddin-khan-shiam
Copy link

Problem

The magika package was a hard dependency, causing import failures if not installed, even when basic functionality would work with Python's built-in mimetypes.

Changes

  • Made magika import optional with graceful fallback
  • Updated MarkItDown to handle missing magika gracefully
  • Maintained all existing functionality when magika is available
  • Falls back to standard mimetypes when magika is not available

Impact

  • CLI and library now work without magika installed
  • Better out-of-the-box experience for users
  • More robust error handling for file-type detection
  • No breaking changes to existing functionality

## Problem
The `magika` package was a hard dependency, causing import failures if not installed, even when basic functionality would work with Python's built-in `mimetypes`.

## Changes
- Made `magika` import optional with graceful fallback
- Updated [MarkItDown](cci:2://file:///d:/Github/markitdown/packages/markitdown/src/markitdown/_markitdown.py:95:0-784:26) to handle missing `magika` gracefully
- Maintained all existing functionality when `magika` is available
- Falls back to standard `mimetypes` when `magika` is not available

## Impact
- CLI and library now work without `magika` installed
- Better out-of-the-box experience for users
- More robust error handling for file-type detection
- No breaking changes to existing functionality
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant