You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://travis-ci.org/ahupp/python-magic)[](https://gitter.im/ahupp/python-magic?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
4
5
-
python-magic is a Python interface to the libmagic file type
6
-
identification library. libmagic identifies file types by checking
5
+
[python-magic](https://github.com/ahupp/python-magic) is a Python interface to the libmagic file type
6
+
identification library. libmagic identifies file types by checking
7
7
their headers according to a predefined list of file types. This
8
8
functionality is exposed to the command line by the Unix command
9
-
`file`.
9
+
[`file`](https://www.darwinsys.com/file/).
10
10
11
11
## Usage
12
12
@@ -43,26 +43,25 @@ You can also combine the flag options:
43
43
44
44
## Installation
45
45
46
-
The current stable version of python-magic is available on PyPI and
47
-
can be installed by running `pip install python-magic`.
46
+
This module is a simple [CDLL](https://docs.python.org/3/library/ctypes.html) wrapper around the libmagic C library.
47
+
The current stable version of python-magic is available on [PyPI](http://pypi.python.org/pypi/python-magic/)
48
+
and can be installed by running `pip install python-magic`.
48
49
49
-
Other sources:
50
+
Compiled libmagic and the magic database come bundled in the wheels on PyPI.
51
+
You can use your own `magic.mgc` database by setting the `MAGIC`
52
+
environment variable, or by using `magic.Magic(magic_file='path/to/magic.mgc')`.
53
+
If you want to compile your own libmagic, circumvent the wheels
54
+
by installing from source: `pip install python-magic --no-binary python-magic`.
50
55
51
-
- PyPI: http://pypi.python.org/pypi/python-magic/
52
-
- GitHub: https://github.com/ahupp/python-magic
53
-
54
-
This module is a simple wrapper around the libmagic C library, and
55
-
comes bundled in the wheels on PyPI.
56
-
If you want to use your own (custom) libmagic installation,
57
-
circumvent the wheels by running `pip install python-magic --no-binary python-magic`.
58
-
For systems not supported by the wheels, libmagic
59
-
needs to be installed before installing python-magic:
56
+
For systems not supported by the wheels, pip installs from source,
57
+
requiring libmagic to be available before installing python-magic:
60
58
61
59
### Linux
62
60
63
61
The Linux wheels should run on most systems out of the box.
64
62
65
-
Depending on your system and CPU architecture, there might be no compatible wheel uploaded. However, precompiled libmagic might still be available for your system:
63
+
Depending on your system and CPU architecture, there might be no compatible wheel uploaded.
64
+
However, precompiled libmagic might still be available for your system:
66
65
67
66
```sh
68
67
# Debian/Ubuntu
@@ -75,13 +74,15 @@ yum install file-libs
75
74
76
75
### Windows
77
76
78
-
The DLLs that are bundled in the Windows wheels are compiled by @julian-r and hosted at https://github.com/julian-r/file-windows/releases.
77
+
The DLLs that are bundled in the Windows wheels are compiled by @julian-r
78
+
and are hosted at https://github.com/julian-r/file-windows/releases.
79
79
80
80
For ARM64 Windows, you'll need to compile libmagic from source.
81
81
82
82
### OSX
83
83
84
-
The Mac wheels are compiled on GitHub Actions using `macos-11` runners. For older Macs, you'll need to install libmagic from source:
84
+
The Mac wheels are compiled with maximum backward compatibility.
85
+
For older Macs, you'll need to install libmagic from source:
85
86
86
87
```sh
87
88
# homebrew
@@ -95,7 +96,7 @@ port install file
95
96
- 'MagicException: could not find any magic files!': some
96
97
installations of libmagic do not correctly point to their magic
97
98
database file. Try specifying the path to the file explicitly in the
0 commit comments