(Possibly hacky) adjustment to support file-magic (Possibly Fixes #3292) #3320
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So I had installed lutris using pacman on arch (so it was on 0.5.8), I hadn't realized this at first but I was experiencing issue #3281.
I was getting the "your version of python-magic is too old." message and am pretty sure that python-magic is the file-magic package in pacman.
(the URL is what leads me to believe this).
Importing magic in a python shell confirmed that
from_filewas not an attribute of themagicmodule (because I'm pretty sure I had file-magic installed). I noticed that it had a similar attributedetect_form_filename.Please note that this is my first time interacting with libmagic.
YOLOing a bit here I thought I'd try monkey-patching it and give it a shot.
Much to my pleasure it appeared to solve my issue. (then I switched back to master and tested again to see that my shortcuts still worked, then read the changelog and saw that the real problem I was experiencing was #3281 - DOH!)
I do believe that this monkey-patch works though. In separate python shells I used both python-magic's
from_fileand file-magic'sdetect_from_filenameand then did a fewstring in resulton the results from the respective methods and noticed they behaved similarly.Granted, this might confuse a reader of this module because
from_filereturns a string whereasdetect_from_filenamereturns amagic.FileMagicobject. Fortunately,magic.FileMagicobjects do support the__contains__method so lines 48 through 56 end up behaving the same (or at least similarly) in both scenarios.I didn't see any unit tests for the find_linux_game_executable. I imagine it would be difficult to write tests against both python-magic and file-magic.
I'd love to hear what y'all think. I'm really not sure if this should be merged or not, but thought this was worthy of some discussion at least.
Thanks for your time everyone!