1{ stdenv, lib, buildPythonPackage, fetchFromGitHub, file
2, isPy3k, mock, unittest2 }:
3
4buildPythonPackage {
5 pname = "filemagic";
6 version = "1.6";
7
8 # Don't use the PyPI source because it's missing files required for testing
9 src = fetchFromGitHub {
10 owner = "aliles";
11 repo = "filemagic";
12 rev = "138649062f769fb10c256e454a3e94ecfbf3017b";
13 sha256 = "1jxf928jjl2v6zv8kdnfqvywdwql1zqkm1v5xn1d5w0qjcg38d4n";
14 };
15
16 postPatch = ''
17 substituteInPlace magic/api.py --replace "ctypes.util.find_library('magic')" \
18 "'${file}/lib/libmagic${stdenv.hostPlatform.extensions.sharedLibrary}'"
19 '';
20
21 checkInputs = [ (if isPy3k then mock else unittest2) ];
22
23 meta = with lib; {
24 description = "File type identification using libmagic";
25 homepage = https://github.com/aliles/filemagic;
26 license = licenses.asl20;
27 maintainers = with maintainers; [ earvstedt ];
28 };
29}