Skip to main content

Python wrapper for libmagic

Project description

Coveralls Github Actions Latest Version https://img.shields.io/pypi/wheel/cmagic.svg https://img.shields.io/pypi/pyversions/cmagic.svg https://img.shields.io/pypi/l/cmagic.svg

Python wrapper for libmagic.

Usage

# MacOS
$ export MAGIC=/usr/local/Cellar/libmagic/5.39/share/misc/magic.mgc

# Ubuntu
$ export MAGIC=/usr/lib/file/magic.mgc
import cmagic

m = cmagic.Magic()

if m.check(cmagic.MAGIC_DB):
   print("Database is ok")

m.load()

m.guess_file("/bin/sh")
# 'ASCII text'

Installation

Ubuntu/Debian

apt-get install -y libmagic1 libmagic-mgc   # when using manilinux wheel
apt-get install -y libmagic-dev             # for building from sources
python3 -m pip install cmagic

Centos

yum install -y file-libs            # when using manilinux wheel
yum install -y file-devel           # for building from sources
python3 -m pip install cmagic

MacOS

brew install libmagic
python3 -m pip install cmagic

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmagic-0.3.0.tar.gz (7.5 kB view hashes)

Uploaded Source

Built Distributions

cmagic-0.3.0-cp38-cp38-manylinux2014_x86_64.whl (137.0 kB view hashes)

Uploaded CPython 3.8

cmagic-0.3.0-cp38-cp38-macosx_10_9_x86_64.whl (362.1 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

cmagic-0.3.0-cp37-cp37m-manylinux2014_x86_64.whl (138.7 kB view hashes)

Uploaded CPython 3.7m

cmagic-0.3.0-cp37-cp37m-macosx_10_9_x86_64.whl (362.0 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

cmagic-0.3.0-cp36-cp36m-manylinux2014_x86_64.whl (137.7 kB view hashes)

Uploaded CPython 3.6m

cmagic-0.3.0-cp36-cp36m-macosx_10_9_x86_64.whl (362.0 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

cmagic-0.3.0-cp35-cp35m-manylinux2014_x86_64.whl (137.4 kB view hashes)

Uploaded CPython 3.5m

cmagic-0.3.0-cp35-cp35m-macosx_10_6_intel.whl (364.8 kB view hashes)

Uploaded CPython 3.5m macOS 10.6+ intel

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page