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

python-magic-bin not available for ARM Mac #567

Closed
h4x0r opened this issue Oct 16, 2023 · 10 comments
Closed

python-magic-bin not available for ARM Mac #567

h4x0r opened this issue Oct 16, 2023 · 10 comments

Comments

@h4x0r
Copy link

h4x0r commented Oct 16, 2023

pip installing requirements stopped with:

ERROR: Could not find a version that satisfies the requirement python-magic-bin==0.4.14 (from versions: none)
ERROR: No matching distribution found for python-magic-bin==0.4.14

I see that the spec does cater to ARM Mac:
python-magic==0.4.24; platform_system == "Linux"
python-magic-bin==0.4.14; platform_system == "Windows"
python-magic-bin==0.4.14; platform_system == "Darwin"
python-magic; platform_system == "Darwin" and platform_machine == "arm64"

So I've no idea why it still stopped with an error. Any idea please? Right now I just comment out the lines with python-magic-bin and it seems to work.

@JamesHabben
Copy link
Collaborator

pull request in R to address this it seems.

abrignoni/RLEAPP#171

@abrignoni
Copy link
Owner

Getting this error on a brand new ARM mac:
ImportError('failed to find libmagic. Check your installation')

Any thoughts?

@abrignoni
Copy link
Owner

Ended up adding libmagic via MacPorts. Worked.

@Johann-PLW
Copy link
Collaborator

Also works with brew.
Have a look to Discussion #622

@JamesHabben
Copy link
Collaborator

I think I have seen this on a windows also. May need an adjustment to the requirements text file

@Johann-PLW
Copy link
Collaborator

As mentioned on the PyPI for python-magic web page, this module is a simple wrapper around the libmagic C library, which must also be installed.
More than just adjusting the requirements.txt file, I think we should consider an alternative solution, as it may become a little more complicated for the user to have to install brew or macports on Mac or DLLs on Windows in order to use iLEAPP.
As the magic module is not widely used in iLEAPP, we could stop using it and use instead an alternative one which appears to offer identical functionality for retrieving the extension and mime type of a file.
This is the filetype module, which is simply installed with pip install filetype and requires no special dependencies. This wouldn't require too many changes to the current code.

With python-magic module:
mimetype = magic.from_file(filepath, mime=True)
Output examples: image/jpeg, image/png, audio/amr, audio/x-wav, video/mp4

With the new filetype module:
mimetype = filetype.guess(filepath).mime
Output examples: image/jpeg, image/png, audio/amr, audio/x-wav, video/mp4

New signatures can easily be added as required.

@abrignoni If you think this is a possible alternative, I'm willing to create a branch in my own repository for testing purposes.

@abrignoni
Copy link
Owner

abrignoni commented Dec 13, 2023 via email

@Johann-PLW
Copy link
Collaborator

python-magic is only used in

  • ilapfuncs.py for the media_to_html function
  • fsCachedData.py to indicate the filetype in a column of the HTML report
  • protonMail.py (this part of the code could use the media_to_html)

@Johann-PLW
Copy link
Collaborator

@abrignoni @JamesHabben @stark4n6
If you want, you can test this fork of iLEAPP (https://github.com/Johann-PLW/iLEAPP/tree/filetype) where python-magic module was replaced with filetype module.
I have not observed any major differences, except with the fsCachedData parser. The Mime Type column is empty when filetype module does not recognise the file header. But this is something we could fix by adding the missing signatures.

  • With python-magic module:
image
  • With filetype module:
image

@abrignoni
Copy link
Owner

abrignoni commented Dec 13, 2023

@Johann-PLW Lets change it. No need to have a dependency that causes issues for no benefit.
This helps a lot.

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

4 participants