Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 716482 - dev-python/python-magic: conflict with dev-python/filemagic (was: dev-util/diffoscope fails with 'Magic' object has no attribute 'from_file')
Summary: dev-python/python-magic: conflict with dev-python/filemagic (was: dev-util/di...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Ian Whyman (thev00d00) (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-06 17:54 UTC by Helmut Jarausch
Modified: 2020-05-23 09:48 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
ebuild for dev-python/magicfile (magicfile-0.4.22.ebuild,462 bytes, text/plain)
2020-04-06 17:54 UTC, Helmut Jarausch
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Helmut Jarausch 2020-04-06 17:54:09 UTC
Created attachment 630872 [details]
ebuild for dev-python/magicfile

I don't know if it's a Python3.8 problem, but I doubt it.
Running diffoscope here I get
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/diffoscope/main.py", line 739, in main
    sys.exit(run_diffoscope(parsed_args))
  File "/usr/lib/python3.8/site-packages/diffoscope/main.py", line 691, in run_diffoscope
    difference = compare_root_paths(path1, path2)
  File "/usr/lib/python3.8/site-packages/diffoscope/comparators/utils/compare.py", line 71, in compare_root_paths
    file1 = specialize(FilesystemFile(path1, container=container1))
  File "/usr/lib/python3.8/site-packages/diffoscope/comparators/utils/specialize.py", line 49, in specialize
    if try_recognize(file, cls, cls.recognizes):
  File "/usr/lib/python3.8/site-packages/diffoscope/comparators/utils/specialize.py", line 36, in try_recognize
    if not recognizes(file):
  File "/usr/lib/python3.8/site-packages/diffoscope/comparators/utils/file.py", line 155, in recognizes
    file.magic_file_type,
  File "/usr/lib/python3.8/site-packages/diffoscope/comparators/utils/file.py", line 284, in magic_file_type
    self._magic_file_type = File.guess_file_type(self.path)
  File "/usr/lib/python3.8/site-packages/diffoscope/comparators/utils/file.py", line 93, in guess_file_type
    return maybe_decode(self._mimedb.from_file(path))
AttributeError: 'Magic' object has no attribute 'from_file'

AFIAK the magic module doesn't have a 'from_file' method.

My workaround is to install the 'magicfile' module (ebuild attached)
and to fix diffoscope by

sed -i -e's/import magic/import magicfile as magic/' diffoscope/comparators/utils/file.py

which can be done in the src_prepare part of the ebuild.
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2020-04-06 21:21:24 UTC
I'd like to reproduce failure first. Please post your output of:
    $ emerge --info dev-util/diffoscope

diffoscope seems to work fine for me. Also note: diffoscope does not yet have python3_8 compat marking (for no real reason, just nobody added it).
Comment 2 Helmut Jarausch 2020-04-15 13:03:43 UTC
It turned out that I had installed both
dev-python/filemagic
and
dev-python/python-magic

which both offer a 'magic' module.
Unfortunately, this wasn't flagged by Python, and dev-python/filemagic
got precedence over dev-python/python-magic and its 'magic' modules doesn't have a from_file method.

Probably, dev-python/filemagic showed by changed or remove from the tree.
Comment 3 Sergei Trofimovich (RETIRED) gentoo-dev 2020-04-15 23:03:14 UTC
Oh, that's a nasty namespace collision. I wonder how one is supposed to deal with it.
Comment 4 Sergei Trofimovich (RETIRED) gentoo-dev 2020-04-15 23:16:47 UTC
I think one overrides another here and both packages should not be installed together:

# qfile /usr/lib64/python3.6/site-packages/magic.py /usr/lib64/python3.6/site-packages/magic/__init__.py
dev-python/filemagic: /usr/lib64/python3.6/site-packages/magic/__init__.py
dev-python/python-magic: /usr/lib64/python3.6/site-packages/magic.py

I suggest adding blockers into one another unless there is a way to unambiguosly load needed module.
Comment 5 Larry the Git Cow gentoo-dev 2020-04-15 23:21:08 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5eb37ab51998e04cec8c82252ca167cfe8ac5242

commit 5eb37ab51998e04cec8c82252ca167cfe8ac5242
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2020-04-15 23:20:38 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2020-04-15 23:21:01 +0000

    dev-util/diffoscope: add blocker against dev-python/filemagic
    
    dev-python/filemagic conflicts with dev-python/python-magic
    and takes precedence when loaded with 'import magic.py'.
    
    Let's block the incompatible package until it's sorted
    across these libraries.
    
    Reported-by: Helmut Jarausch
    Bug: https://bugs.gentoo.org/716482
    Package-Manager: Portage-2.3.99, Repoman-2.3.22
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 dev-util/diffoscope/diffoscope-140-r1.ebuild | 71 ++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2020-05-23 09:48:57 UTC
filemagic is gone now.