libmagic
libmagic bindings
Decision gist · record as of 2026-08-14
No. The package is abandoned (last release 2012-03-02, no maintenance since), carries high install friction (requires compiled libmagic), and is licensed under GPL v3 copyleft. Modern alternatives like `python-magic` or `python-magic-bin` are maintained and provide the same functionality. Install this only if you are maintaining legacy code that already depends on it and cannot migrate.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- libmagic system library must be installed on the system; ctypes requires the compiled libmagic shared object to be available at runtime.
- High install friction due to a compiled system dependency (libmagic-1.0.tar.gz).
- The package is abandoned—last release was 2012-03-02 with no commits or maintenance activity since.
License · maintenance · safety
GPL v3 (copyleft) — Licensed under GPL v3 (copyleft). Any code that imports this package must comply with GPL v3 terms, including potential source code disclosure obligations if distributed.
last release 2012-03-02 (5278 days)
0 known vulnerabilities (OSV.dev, 2026-08-14) · 127,815 downloads/mo, #11,729 on PyPI
Alternatives
Verify before relying
import libmagic
# Requires libmagic system library installed
magic_instance = libmagic.open()
file_type = magic_instance.file('/path/to/file')
magic_instance.close()- Whether libmagic system dependency is available on modern operating systems and package managers.
- Compatibility with Python versions beyond those available in 2012; requires_python is unspecified.
- Whether the ctypes binding handles edge cases or errors that modern file-type libraries address.
What it is and what it does
libmagic is a Python wrapper around the libmagic C library, providing file type and MIME type detection through ctypes. It allows you to query the type of a file by reading its magic bytes—the identifying patterns at the start of a file—rather than relying on file extensions. The package is a thin binding with no runtime Python dependencies, relying entirely on the system-installed libmagic library.
The package has been abandoned since its single release in 2012 and receives no maintenance. While it may still work on systems with libmagic installed, it carries significant risk: no bug fixes, no Python version support updates, and no response to security issues. The GPL v3 copyleft license also imposes source-code disclosure requirements on any project that uses it.
Use it for
- Detect file types by content rather than extension in legacy systems still using this binding.
- Identify MIME types for uploaded files in web applications that cannot upgrade dependencies.
- Analyze file format in security or forensics tools where libmagic integration is already established.
- Validate file integrity by checking magic bytes in batch processing scripts with minimal dependencies.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
No.
The package is abandoned (last release 2012-03-02, no maintenance since), carries high install friction (requires compiled libmagic), and is licensed under GPL v3 copyleft. Modern alternatives like `python-magic` or `python-magic-bin` are maintained and provide the same functionality. Install this only if you are maintaining legacy code that already depends on it and cannot migrate.
Install
libmagic on PyPI
Before you install
High install friction due to a compiled system dependency (libmagic-1.0.tar.gz). The package is abandoned—last release was 2012-03-02 with no commits or maintenance activity since. Use only if you have a specific reason to prefer this binding over maintained alternatives.
libmagic system library must be installed on the system; ctypes requires the compiled libmagic shared object to be available at runtime.
License in practice
Licensed under GPL v3 (copyleft). Any code that imports this package must comply with GPL v3 terms, including potential source code disclosure obligations if distributed.
Quickstart
import libmagic
# Requires libmagic system library installed
magic_instance = libmagic.open()
file_type = magic_instance.file('/path/to/file')
magic_instance.close()
Verify before relying
- Whether libmagic system dependency is available on modern operating systems and package managers.
- Compatibility with Python versions beyond those available in 2012; requires_python is unspecified.
- Whether the ctypes binding handles edge cases or errors that modern file-type libraries address.
Package facts
| License | GPL v3 copyleft |
| Python support | Not specified |
| Install friction | High. Source build required |
| Runtime dependencies | None |
| Maintenance | Abandoned 5,278 days since the last release |
| First released | |
| Downloads | 127,815 / month, #11,729 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaEnvironment :: ConsoleEnvironment :: Web EnvironmentIntended Audience :: DevelopersLicense :: OSI Approved :: GNU General Public License (GPL)Operating System :: OS IndependentProgramming Language :: PythonTopic :: SecurityTopic :: Software Development :: Libraries :: Python Modules |
Evidence: libmagic-1.0.tar.gz
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “libmagic bindings”
- libmagicProvides Python bindings to the libmagic library for file type…
- file-magicfile-magic provides a Python interface to libmagic, enabling…
- typecodeDetects file types and MIME types using libmagic and Pygments, with…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also file-magic · python-magic · python-magic-bin · typecode · polyfile-weave · cigam · puremagic · filetype · typecode-libmagic · magika