1{ lib
2, stdenv
3, python
4, buildPythonPackage
5, fetchFromGitHub
6, fetchpatch
7, substituteAll
8, file
9, glibcLocales
10}:
11
12buildPythonPackage rec {
13 pname = "python-magic";
14 version = "0.4.24";
15
16 src = fetchFromGitHub {
17 owner = "ahupp";
18 repo = "python-magic";
19 rev = version;
20 sha256 = "17jalhjbfd600lzfz296m0nvgp6c7vx1mgz82jbzn8hgdzknf4w0";
21 };
22
23 patches = [
24 # pull upstream patch to support file-5.41
25 (fetchpatch {
26 name = "file-5.41-compat.patch";
27 url = "https://github.com/ahupp/python-magic/commit/0ae7e7ceac0e80e03adc75c858bb378c0427331a.patch";
28 sha256 = "0vclaamb56nza1mcy88wjbkh81hnish2gzvl8visa2cknhgdmk50";
29 })
30
31 (substituteAll {
32 src = ./libmagic-path.patch;
33 libmagic = "${file}/lib/libmagic${stdenv.hostPlatform.extensions.sharedLibrary}";
34 })
35 ];
36
37 checkInputs = [ glibcLocales ];
38
39 checkPhase = ''
40 LC_ALL="en_US.UTF-8" ${python.interpreter} test/test.py
41 '';
42
43 meta = with lib; {
44 description = "A python interface to the libmagic file type identification library";
45 homepage = "https://github.com/ahupp/python-magic";
46 license = licenses.mit;
47 maintainers = with maintainers; [ ];
48 };
49}