Bug 1899279 - python-file-magic and python-magic conflict with each other
Summary: python-file-magic and python-magic conflict with each other
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: file
Version: 42
Hardware: All
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Vincent Mihalkovič
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1933591 2020606
TreeView+ depends on / blocked
 
Reported: 2020-11-18 19:42 UTC by Jan Drögehoff
Modified: 2025-05-12 12:09 UTC (History)
16 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2023-11-25 14:09:41 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Fedora Package Sources rpmlint pull-request 32 0 None None None 2023-11-25 12:37:54 UTC
Github rpm-software-management/rpmlint/commit/9fb26419ea2034460bf83efe3cc949e6eb6c3f5f 0 None None None 2023-11-25 12:37:54 UTC

Internal Links: 2029082

Description Jan Drögehoff 2020-11-18 19:42:48 UTC
Description of problem:
python-file-magic (provided by file) and python-magic conflict with each other

I personally have encountered this because I have fedora-package (among other) packages installed that depend on python-file-magic while also being a lutris user.

simply forcing lutris to use python-file-magic is not an option either, it heavily depends on functionality not present in it

according to this comment in another bug report
https://bugzilla.redhat.com/show_bug.cgi?id=632687#c4
the file-magic might have been merged into file-magic but I couldn't find anything confirming that

Comment 1 Kamil Dudka 2020-11-19 13:13:37 UTC
python3-magic was recently renamed to python3-file-magic to avoid unnecessary conflicts:

    bug #1793689

Comment 2 Jan Drögehoff 2020-11-19 15:18:39 UTC
the renaming did indeed take place but there is still a problem of both packages naturally conflicting and python-file-magic obsoleting python-magic stopping people with python-file-magic installed from installing any package that depends on python-magic

Comment 3 Kamil Páral 2020-11-20 11:05:40 UTC
Kamil, this is wrong. I can't install Lutris on F33:

$ sudo dnf install lutris
Last metadata expiration check: 1:42:52 ago on Fri 20 Nov 2020 10:14:53 AM CET.
Dependencies resolved.

 Problem: problem with installed package python3-file-magic-5.39-3.fc33.noarch
  - package python3-file-magic-5.39-3.fc33.noarch conflicts with python3-magic < 5.39-3.fc33 provided by python3-magic-0.4.15-4.fc33.noarch
  - installed package python3-file-magic-5.39-3.fc33.noarch obsoletes python3-magic < 5.39-3.fc33 provided by python3-magic-0.4.15-4.fc33.noarch
  - package python3-file-magic-5.39-3.fc33.noarch obsoletes python3-magic < 5.39-3.fc33 provided by python3-magic-0.4.15-4.fc33.noarch
  - package lutris-0.5.8-1.fc33.x86_64 requires python3.9dist(python-magic), but none of the providers can be installed
  - cannot install the best candidate for the job

Lutris requires python3-magic, while rpmlint (a dep for fedpkg) requires python3-file-magic, and those packages conflict. They both want to install /usr/lib/python3.9/site-packages/magic.py. This needs to be solved somehow, and I don't know how, I'm not a python packaging expert.

CC Miro Hrončok for advice, thanks!

Miro, for reference, we're talking about these two PyPI packages:
https://pypi.org/project/file-magic/
https://pypi.org/project/python-magic/

Comment 4 Kamil Páral 2020-11-20 11:07:30 UTC
(Making this bug public, because there is no private data here, I assume it was a mistake by the reporter)

Comment 5 Miro Hrončok 2020-11-20 11:28:36 UTC
There are several problems here:

1) python3-file-magic provides and obsoletes python3-magic, hence no package can reasonably use python3-magic as a dependency at all:

$ repoquery --repo=rawhide --obsoletes python3-file-magic
python3-magic < 5.39-3.fc34

$ repoquery --repo=rawhide python3-magic
python3-magic-0:0.4.15-4.fc33.noarch

$ sudo dnf upgrade
...
Installing:
 python3-file-magic  noarch  5.39-3.fc34  fedora  18 k
     replacing  python3-magic.noarch 0.4.15-4.fc33

This might be solvable by doing both of the following:

 - fix the obsoleted version instead of using %{version}-%{release}
 - introduce epoch to python3-magic


2) The packages have implicit file conflict. This should (at least for start) be accompanied by an explicit RPM Conflicts. That way, the packages still won't be able to install at the same time, but at least dnf will know before attempting to do so.


$ repoquery --repo=rawhide -l python3-magic
...
/usr/lib/python3.9/site-packages/magic.py
...

$ repoquery --repo=rawhide -l python3-file-magic
...
/usr/lib/python3.9/site-packages/magic.py
...



It is literately impossible to solve this conflict without also patching all consumers of (at least one of) the packages to either use a different module name or different sys.path. If you have both packages installed at once and do "import magic" you will either have one or another.

The only possible way of solving this is to:

a) See if the API is compatible or not. If it is, try seeing which of the packages is "better" (less dead upstream, more features, etc.) and switch all of the depending packages to it. If not, try to make them compatible, or...

b) See if one of the upstreams is willing to change the module name. That would still require fixing all the dependents, but at least it would have not been a downstream only hack.

c) Cry.

Comment 6 Jan Drögehoff 2020-11-20 13:49:22 UTC
a) python-file-magic and python-magic are not API compatible for example:
to use each of the libraries on a file you have to do

python-file-magic: magic.detect_from_filename
python-magic: magic.from_file

b) python-magic seems to be more up to date but I don't think simply migrating to it a viable option

With lutris there is the option of adding support for python-file-magic alongside python-magic but that does not solve the problem only postpone it(In reply to Kamil Páral from comment #4)

> (Making this bug public, because there is no private data here, I assume it
> was a mistake by the reporter)

This was a mistake on my part, I am always having trouble finding my way around Bugzilla

Comment 7 Jason Tibbitts 2020-11-20 16:11:31 UTC
One interesting note is that if you look at the PKG-INFO file included within python3-file-magic, the version indicated is 0.4.0 which doesn't correlate with the main version of the file package.  python3-magic has 0.4.15 currently.  I do not know if this is mere coincidence.

Both modules are at least a decade old; python3-magic dates from 2010 and python3-file-magic from 2003.  Surely this conflict must have been discussed somewhere before, and indeed while looking I found https://github.com/ahupp/python-magic/issues/21.  I made a note of this bugzilla ticket there.

Comment 8 Chris King 2020-11-20 18:26:58 UTC
Hey I'm the Lutris package maintainer checking in.

I've passed this bug onto the dev-team & asked them if they've run into the issue on other distributions. I'll let you know what they say.

As to actually resolving the issue I'd be quite out of my depth technically, so I'm glad that there are others working on this.

Comment 9 Jason Tibbitts 2020-11-20 18:35:59 UTC
According to https://github.com/ahupp/python-magic/issues/21, Mageia has also recently run into this and may take the route of patching Lutris.  It might be useful to communicate with them as well, at least to get a temporary solution.

Also according to that issue, the maintainer of the standalone module was going to work on compatibility code to implement the API of the module in the file source but that doesn't seem to have happened yet.  Anyway, I'm far from the expert here so I'll leave the solutions to those who know better.

Comment 10 Chris King 2020-11-21 03:12:00 UTC
I got this response from the Lutris devs (not that this resolves our problem):

"Did a very quick source dive, it's used as part of the new automatic installers for gog and humble. Lutris degrades gracefully if it's not present — the install will complete, but you'll need to manually select the executable in the game's options afterward. Installers from Lutris.net should continue to work normally."

For someone with more experience packaging than I have, is there a way to allow installations without this dependency (but nonetheless suggest it) until we fix this issue given that its not integral to the functioning of Lutris?

Comment 11 Jan Drögehoff 2020-11-21 10:32:42 UTC
(In reply to Chris King from comment #10)
> allow installations without this dependency

a simple sed should do the job

sed -i "s/python-magic//g" setup.py

Comment 12 Miro Hrončok 2020-11-21 11:06:32 UTC
That would leave this:

    install_requires=[
        'PyYAML',
        'PyGObject',
        'evdev',
        'requests',
        ''
    ],


What about:

sed -i '/python-magic/d' setup.py

Comment 13 Jan Drögehoff 2020-11-21 15:52:27 UTC
(In reply to Miro Hrončok from comment #12)
> What about:
> 
> sed -i '/python-magic/d' setup.py
an empty string would be ignored so doing either of the sed's would lead to the same behavior but perhaps this deleting the line is the better option

Comment 14 Jan Drögehoff 2020-11-28 18:00:31 UTC
the hard dependency on python-magic in lutris has been changed to allow file-magic to act as an alternative
https://github.com/lutris/lutris/commit/116dac759db01b50dd36b27fb66853c815d177ea

but this is issue still persists
I don't think either project is going to either implement the others API for compatibility or change their module name
so I propose a fourth solution:

d) a compatibility layer that will work with both libmagic wrappers and expose API endpoints available in both of them

Comment 15 Chris King 2020-11-29 23:11:28 UTC
I've updated the Lutris package with that edit. Sorry it took me so long to get around to this. The patch I've made (per your suggestions) removes python-file-magic altogether, along with the functionality it provides, unless I'm misunderstanding something. 

Hopefully we can get this bug sorted out soon so that Fedora users can have the functionality provided by python-file-magic in Lutris.

Comment 16 Ben Cotton 2021-11-04 16:53:43 UTC
This message is a reminder that Fedora 33 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 33 on 2021-11-30.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '33'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 33 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 17 Dominik 'Rathann' Mierzejewski 2021-11-05 11:00:58 UTC
Still an issue on F35. This breaks mimetype.py plugin in eyeD3, for example. At minimum, the Obsoletes: python3-magic < 5.40-9.fc35 must be removed as it's just not true. Both projects are still actively developed.

Comment 18 Dominik 'Rathann' Mierzejewski 2021-11-05 11:16:27 UTC
Also, python-magic upstream implemented a compatibility layer: https://github.com/ahupp/python-magic/issues/21#issuecomment-936253287 that's present in 0.4.19+. I think it's high time to stop obsoleting python3-magic here.

Comment 19 Chris King 2022-01-05 14:22:35 UTC
Any updates on this?

Comment 20 Kamil Dudka 2022-01-05 14:44:14 UTC
(In reply to Dominik 'Rathann' Mierzejewski from comment #17)
> At minimum, the Obsoletes: python3-magic < 5.40-9.fc35 must be removed as
> it's just not true. Both projects are still actively developed.

The obsolete is there because the file's subpackage was originally named python3-magic (see bug #1793689).  If we remove it, it will complicate upgrades across major versions of CentOS.

Comment 21 Jan Drögehoff 2022-01-09 16:07:27 UTC
(In reply to Kamil Dudka from comment #20)
> (In reply to Dominik 'Rathann' Mierzejewski from comment #17)
> > At minimum, the Obsoletes: python3-magic < 5.40-9.fc35 must be removed as
> > it's just not true. Both projects are still actively developed.
> 
> The obsolete is there because the file's subpackage was originally named
> python3-magic (see bug #1793689).  If we remove it, it will complicate
> upgrades across major versions of CentOS.

Since python-magic implements a compatibility layer it should be fine to lower the obsoletes to versions under 0.4.20.


(In reply to Chris King from comment #19)
> Any updates on this?

In the time between opening this and now Lutris has implemented check for which package is installed and acted accordingly [1]
and now they have decided to outright vendor python-magic [2]

[1] https://github.com/lutris/lutris/pull/3320
[2] https://github.com/lutris/lutris/commit/fbdafa6eed4b9c750fc8881b920125d4495b6a4c#diff-85a93ccc27334ffc74985116d0b6a9b958611985db1c32376f0f3d61a148adab

Comment 22 Todd Zullinger 2022-09-17 05:11:31 UTC
_Iff_ python3-file-magic is going to obsolete python3-magic, it seems that it needs to provide python3.10dist(python-magic).  Right now, it prevents installing packages where upstream depends on python-magic, as rpmlint-2.3.0 does, for example.

Comment 23 Ben Cotton 2022-11-29 16:50:24 UTC
This message is a reminder that Fedora Linux 35 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 35 on 2022-12-13.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '35'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 35 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 24 Miro Hrončok 2022-11-29 18:04:21 UTC
Both packages still exist in rawhide.

Comment 25 Ben Cotton 2023-02-07 14:51:36 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 38 development cycle.
Changing version to 38.

Comment 26 Zephyr Lykos 2023-11-25 12:37:54 UTC
This happens (again) in rawhide if you have fedora-packager installed due to rpmlint's migration to pyproject.toml.
See attached links.

Comment 28 Fedora Update System 2023-11-25 14:06:32 UTC
FEDORA-2023-2ed6d85eb0 has been submitted as an update to Fedora 40. https://bodhi.fedoraproject.org/updates/FEDORA-2023-2ed6d85eb0

Comment 29 Fedora Update System 2023-11-25 14:09:41 UTC
FEDORA-2023-2ed6d85eb0 has been pushed to the Fedora 40 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 30 Dominik 'Rathann' Mierzejewski 2024-02-28 11:45:40 UTC
I think this closure was a mistake. rpmlint update does not fix the conflict.

Comment 31 Aoife Moloney 2025-02-26 12:51:01 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 42 development cycle.
Changing version to 42.


Note You need to log in before you can comment on or make changes to this bug.