Skip to content

Add libmagic1 to Dockerfile dependencies#310

Open
nijel wants to merge 1 commit into
pre-commit-ci:mainfrom
nijel:patch-1
Open

Add libmagic1 to Dockerfile dependencies#310
nijel wants to merge 1 commit into
pre-commit-ci:mainfrom
nijel:patch-1

Conversation

@nijel

@nijel nijel commented Oct 7, 2025

Copy link
Copy Markdown
Contributor

This allows us to use language bindings such as python-magic inside pre-commit checks.

This allows us to use language bindings such as python-magic inside pre-commit checks.
@nijel

nijel commented Oct 7, 2025

Copy link
Copy Markdown
Contributor Author

Discovered via fsfe/reuse-tool#1244, it falls back to less performant and worse working detection using other libraries.

@carmenbianca

Copy link
Copy Markdown

You could also consider installing file instead of libmagic1. file has a dependency on libmagic1 and is a fairly useful and standard Unix-y util.

nijel added a commit to WeblateOrg/meta that referenced this pull request Oct 8, 2025
Lets avoid it for now. We run pre-commit directly as well and
the pre-commit.ci is needed to apply formatting, what reuse
does not do.

See fsfe/reuse-tool#1244
and pre-commit-ci/runner-image#310
@asottile

Copy link
Copy Markdown
Member

could you comment on the size this adds to the image? would make it easier to understand whether this is a good idea or not

I'm surprised python-magic doesn't ship a wheel with it bundled (as is typical for manylinux and friends)

@nijel

nijel commented Oct 16, 2025

Copy link
Copy Markdown
Contributor Author

The library itself is 200 kB, but it pulls the detection data which is 7 MB. That might me also the reason why it's not shipped in the wheel...

@carmenbianca

carmenbianca commented Oct 17, 2025

Copy link
Copy Markdown

There is an unmerged PR against python-magic which does just that: ahupp/python-magic#294

@ddelange

Copy link
Copy Markdown

The library itself is 200 kB, but it pulls the detection data which is 7 MB. That might me also the reason why it's not shipped in the wheel...

check out the compressed sizes (including the mime database and the libmagic binary) here. uncompressed, magic.mgc is 10.4MB and libmagic.so.1 (manylinux_x86_64) is 896kB.

@asottile

Copy link
Copy Markdown
Member

so should I merge this or should the other thing use python-magic-standalone instead?

@ddelange

ddelange commented Oct 25, 2025

Copy link
Copy Markdown

It looks like my PR wont get merged any time soon, which is why python-magic-standalone was created in the first place (see the end of the thread). That's ment to be a temporary solution until my PR gets merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants