Registry / serialization / file-magic

file-magic

JSON →
library0.4.1pypypi✓ verified 35d ago

Python front end for libmagic(3) — uses ctypes to wrap libmagic for file type detection. Current version 0.4.1, last released 2016; requires libmagic (system library). Unmaintained; prefer `python-magic` for active development.

serialization
Install & Compatibility
Where this runs
tested against v0.4.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Top-level import; no submodule needed.

import magic

Basic usage: create a magic cookie, load magic database, detect file type.

import magic m = magic.open(magic.MAGIC_NONE) m.load() type_ = m.file('/path/to/file') # e.g., 'ASCII text' print(type_)
Debug
Known footguns
gotcha`file-magic` is unmaintained (last release 2016). Prefer `pip install python-magic` instead, which has a similar API and is actively maintained.
gotchaRequires system libmagic installed. If missing, get an OSError or ImportError.
gotchaOn Windows, libmagic is not preinstalled; need to bundle DLL or use alternative.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
15 hits · last 30 days
gptbot
4
amazonbot
4
ahrefsbot
3
claudebot
3
script
1
Resources