lol

Merge pull request #115260 from dotlambda/python-magic-fix

pythonPackages.python_magic: fix build and run tests

authored by

Martin Weinelt and committed by
GitHub
1941313b 8ae8348b

+41 -12
+24 -12
pkgs/development/python-modules/python-magic/default.nix
··· 1 - { buildPythonPackage, lib, fetchPypi, file, stdenv }: 1 + { lib 2 + , stdenv 3 + , python 4 + , buildPythonPackage 5 + , fetchFromGitHub 6 + , substituteAll 7 + , file 8 + , glibcLocales 9 + }: 2 10 3 11 buildPythonPackage rec { 4 12 pname = "python-magic"; 5 13 version = "0.4.22"; 6 14 7 - src = fetchPypi { 8 - inherit pname version; 9 - sha256 = "ca884349f2c92ce830e3f498c5b7c7051fe2942c3ee4332f65213b8ebff15a62"; 15 + src = fetchFromGitHub { 16 + owner = "ahupp"; 17 + repo = "python-magic"; 18 + rev = version; 19 + sha256 = "0zbdjr5shijs0jayz7gycpx0kn6v2bh83dpanyajk2vmy47jvbd6"; 10 20 }; 11 21 12 - postPatch = '' 13 - substituteInPlace magic.py --replace "ctypes.util.find_library('magic')" "'${file}/lib/libmagic${stdenv.hostPlatform.extensions.sharedLibrary}'" 14 - ''; 22 + patches = [ 23 + (substituteAll { 24 + src = ./libmagic-path.patch; 25 + libmagic = "${file}/lib/libmagic${stdenv.hostPlatform.extensions.sharedLibrary}"; 26 + }) 27 + ]; 15 28 16 - doCheck = false; 29 + checkInputs = [ glibcLocales ]; 17 30 18 - # TODO: tests are failing 19 - #checkPhase = '' 20 - # ${python}/bin/${python.executable} ./test.py 21 - #''; 31 + checkPhase = '' 32 + LC_ALL="en_US.UTF-8" ${python.interpreter} test/test.py 33 + ''; 22 34 23 35 meta = { 24 36 description = "A python interface to the libmagic file type identification library";
+17
pkgs/development/python-modules/python-magic/libmagic-path.patch
··· 1 + diff --git a/magic/loader.py b/magic/loader.py 2 + index 6b2bfcb..69778af 100644 3 + --- a/magic/loader.py 4 + +++ b/magic/loader.py 5 + @@ -5,11 +5,7 @@ import glob 6 + def load_lib(): 7 + libmagic = None 8 + # Let's try to find magic or magic1 9 + - dll = ctypes.util.find_library('magic') \ 10 + - or ctypes.util.find_library('magic1') \ 11 + - or ctypes.util.find_library('cygmagic-1') \ 12 + - or ctypes.util.find_library('libmagic-1') \ 13 + - or ctypes.util.find_library('msys-magic-1') # for MSYS2 14 + + dll = '@libmagic@' 15 + 16 + # necessary because find_library returns None if it doesn't find the library 17 + if dll: