Skip to content
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

Consider removing/relaxing dependency of libmagic #547

Open
mahmut-the-guy opened this issue Feb 2, 2024 · 1 comment
Open

Consider removing/relaxing dependency of libmagic #547

mahmut-the-guy opened this issue Feb 2, 2024 · 1 comment

Comments

@mahmut-the-guy
Copy link
Contributor

Problem to Solve

Currently, I don't use any file uploading logic in the platform and installing libmagic1 is a burden.

Currently there 7 use cases for magic and 6 of them uses filename to figure out the mime type. I think these cases be handled by following functionality from standard library:

https://docs.python.org/3/library/mimetypes.html#mimetypes.guess_type

The remaining case that uses the actual file buffer is not even a part of core library and found in examples:

mime_type = magic.from_buffer(file_data, mime=True)

Current Workaround

You need to install libmagic1 and relevant Python dependency. I could not find a way to get around this.

Proposed Solution

Remove magic dependency by using guess_type instead from stdlib.

If we really need magic for any reason, I propose making the dependency optional so those who don't do any file operations don't have to install it.

@mahmut-the-guy
Copy link
Contributor Author

@SamuelHassine what do you think about this? I could draft a PR if it sounds feasible.

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

No branches or pull requests

1 participant