{"id":47026264,"url":"https://github.com/ohcnetwork/python-magic-bin","last_synced_at":"2026-03-11T23:18:55.657Z","repository":{"id":282106754,"uuid":"947448076","full_name":"ohcnetwork/python-magic-bin","owner":"ohcnetwork","description":null,"archived":false,"fork":false,"pushed_at":"2025-11-01T23:16:06.000Z","size":866,"stargazers_count":0,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-12-10T06:22:24.331Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ohcnetwork.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-12T17:46:38.000Z","updated_at":"2025-04-13T21:47:58.000Z","dependencies_parsed_at":"2025-04-16T13:24:15.010Z","dependency_job_id":"49b0caee-842b-4a5b-b80d-06dccdade09a","html_url":"https://github.com/ohcnetwork/python-magic-bin","commit_stats":null,"previous_names":["ohcnetwork/python-magic-bin"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ohcnetwork/python-magic-bin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohcnetwork%2Fpython-magic-bin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohcnetwork%2Fpython-magic-bin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohcnetwork%2Fpython-magic-bin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohcnetwork%2Fpython-magic-bin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ohcnetwork","download_url":"https://codeload.github.com/ohcnetwork/python-magic-bin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohcnetwork%2Fpython-magic-bin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30406531,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T22:36:59.286Z","status":"ssl_error","status_checked_at":"2026-03-11T22:36:57.544Z","response_time":84,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-03-11T23:18:55.013Z","updated_at":"2026-03-11T23:18:55.651Z","avatar_url":"https://github.com/ohcnetwork.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# python-magic\n[![PyPI version](https://badge.fury.io/py/python-magic.svg)](https://badge.fury.io/py/python-magic)\n[![ci](https://github.com/ahupp/python-magic/actions/workflows/ci.yml/badge.svg)](https://github.com/ahupp/python-magic/actions/workflows/ci.yml)\n[![Join the chat at https://gitter.im/ahupp/python-magic](https://badges.gitter.im/ahupp/python-magic.svg)](https://gitter.im/ahupp/python-magic?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n[python-magic](https://github.com/ahupp/python-magic) is a Python interface to the libmagic file type\nidentification library. libmagic identifies file types by checking\ntheir headers according to a predefined list of file types. This\nfunctionality is exposed to the command line by the Unix command\n[`file`](https://www.darwinsys.com/file/).\n\n## Usage\n\n```python\n\u003e\u003e\u003e import magic\n\u003e\u003e\u003e magic.from_file(\"testdata/test.pdf\")\n'PDF document, version 1.2'\n# recommend using at least the first 2048 bytes, as less can produce incorrect identification\n\u003e\u003e\u003e magic.from_buffer(open(\"testdata/test.pdf\", \"rb\").read(2048))\n'PDF document, version 1.2'\n\u003e\u003e\u003e magic.from_file(\"testdata/test.pdf\", mime=True)\n'application/pdf'\n```\n\nThere is also a `Magic` class that provides more direct control,\nincluding overriding the magic database file and turning on character\nencoding detection.  This is not recommended for general use.  In\nparticular, it's not safe for sharing across multiple threads and\nwill fail throw if this is attempted.\n\n```python\n\u003e\u003e\u003e f = magic.Magic(uncompress=True)\n\u003e\u003e\u003e f.from_file('testdata/test.gz')\n'ASCII text (gzip compressed data, was \"test\", last modified: Sat Jun 28 21:32:52 2008, from Unix)'\n```\n\nYou can also combine the flag options:\n\n```python\n\u003e\u003e\u003e f = magic.Magic(mime=True, uncompress=True)\n\u003e\u003e\u003e f.from_file('testdata/test.gz')\n'text/plain'\n```\n\n## Installation\n\nThis module is a simple [CDLL](https://docs.python.org/3/library/ctypes.html) wrapper around the libmagic C library.\nThe current stable version of python-magic is available on [PyPI](http://pypi.python.org/pypi/python-magic/)\nand can be installed by running `pip install python-magic`.\n\nCompiled libmagic and the magic database come bundled in the wheels on PyPI.\nYou can use your own `magic.mgc` database by setting the `MAGIC`\nenvironment variable, or by using `magic.Magic(magic_file='path/to/magic.mgc')`.\nIf you want to compile your own libmagic, circumvent the wheels\nby installing from source: `pip install python-magic --no-binary python-magic`.\n\nFor systems not supported by the wheels, pip installs from source,\nrequiring libmagic to be available before installing python-magic:\n\n### Linux\n\nThe Linux wheels should run on most systems out of the box.\n\nDepending on your system and CPU architecture, there might be no compatible wheel uploaded.\nHowever, precompiled libmagic might still be available for your system:\n\n```sh\n# Debian/Ubuntu\napt-get update \u0026\u0026 apt-get install -y libmagic1\n# Alpine\napk add --update libmagic\n# RHEL\ndnf install file-libs\n```\n \n### Windows\n\nThe DLLs that are bundled in the Windows wheels are compiled by @julian-r\nand are hosted at https://github.com/julian-r/file-windows/releases.\n\nFor ARM64 Windows, you'll need to compile libmagic from source.\n\n### OSX\n\nThe Mac wheels are compiled with maximum backward compatibility.\nFor older Macs, you'll need to install libmagic from source:\n\n```sh\n# homebrew\nbrew install libmagic\n# macports\nport install file\n```\n\nIf python-magic fails to load the library it may be in a non-standard location, in which case you can set the environment variable `DYLD_LIBRARY_PATH` to point to it.\n\n### SmartOS:\n- Install libmagic for source https://github.com/threatstack/libmagic/\n- Depending on your ./configure --prefix settings set your LD_LIBRARY_PATH to \u003cprefix\u003e/lib\n\n### Troubleshooting\n\n- 'MagicException: could not find any magic files!': some\n  installations of libmagic do not correctly point to their magic\n  database file.  Try specifying the path to the file explicitly in the\n  constructor: `magic.Magic(magic_file='path/to/magic.mgc')`.\n\n- 'WindowsError: [Error 193] %1 is not a valid Win32 application':\n  Attempting to run the 32-bit libmagic DLL in a 64-bit build of\n  python will fail with this error.  Here are 64-bit builds of libmagic for windows: https://github.com/pidydx/libmagicwin64.\n  Newer version can be found here: https://github.com/nscaife/file-windows.\n\n- 'WindowsError: exception: access violation writing 0x00000000 ' This may indicate you are mixing\n  Windows Python and Cygwin Python. Make sure your libmagic and python builds are consistent.\n\n## Bug Reports\n\npython-magic is a thin layer over the libmagic C library.\nHistorically, most bugs that have been reported against python-magic\nare actually bugs in libmagic; libmagic bugs can be reported on their\ntracker here: https://bugs.astron.com/my_view_page.php.  If you're not\nsure where the bug lies feel free to file an issue on GitHub and I can\ntriage it.\n\n## Running the tests\n\nWe use the `tox` test runner which can be installed with `python -m pip install tox`.\n\nTo run tests locally across all available python versions:\n\n```\npython -m tox\n```\n\nOr to run just against a single version:\n\n```\npython -m tox py\n```\nTo run the tests across a variety of linux distributions (depends on Docker):\n\n```\n./test/run_all_docker_test.sh\n```\n\n## libmagic python API compatibility\n\nThe python bindings shipped with libmagic use a module name that conflicts with this package.  To work around this, python-magic includes a compatibility layer for the libmagic API.  See [COMPAT.md](COMPAT.md) for a guide to libmagic / python-magic compatibility.\n\n## Versioning\n\nMinor version bumps should be backwards compatible.  Major bumps are not.\n\n## Author\n\nWritten by Adam Hupp in 2001 for a project that never got off the\nground.  It originally used SWIG for the C library bindings, but\nswitched to ctypes once that was part of the python standard library.\n\nYou can contact me via my [website](http://hupp.org/adam) or\n[GitHub](http://github.com/ahupp).\n\n## License\n\npython-magic is distributed under the MIT license.  See the included\nLICENSE file for details.\n\nI am providing code in the repository to you under an open source license. Because this is my personal repository, the license you receive to my code is from me and not my employer (Facebook).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohcnetwork%2Fpython-magic-bin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fohcnetwork%2Fpython-magic-bin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohcnetwork%2Fpython-magic-bin/lists"}