pythonPackages.python_magic: fix build and run tests
This commit is contained in:
parent
d80850806d
commit
6c3b5c1942
@ -1,25 +1,37 @@
|
|||||||
{ buildPythonPackage, lib, fetchPypi, file, stdenv }:
|
{ lib
|
||||||
|
, stdenv
|
||||||
|
, python
|
||||||
|
, buildPythonPackage
|
||||||
|
, fetchFromGitHub
|
||||||
|
, substituteAll
|
||||||
|
, file
|
||||||
|
, glibcLocales
|
||||||
|
}:
|
||||||
|
|
||||||
buildPythonPackage rec {
|
buildPythonPackage rec {
|
||||||
pname = "python-magic";
|
pname = "python-magic";
|
||||||
version = "0.4.22";
|
version = "0.4.22";
|
||||||
|
|
||||||
src = fetchPypi {
|
src = fetchFromGitHub {
|
||||||
inherit pname version;
|
owner = "ahupp";
|
||||||
sha256 = "ca884349f2c92ce830e3f498c5b7c7051fe2942c3ee4332f65213b8ebff15a62";
|
repo = "python-magic";
|
||||||
|
rev = version;
|
||||||
|
sha256 = "0zbdjr5shijs0jayz7gycpx0kn6v2bh83dpanyajk2vmy47jvbd6";
|
||||||
};
|
};
|
||||||
|
|
||||||
postPatch = ''
|
patches = [
|
||||||
substituteInPlace magic.py --replace "ctypes.util.find_library('magic')" "'${file}/lib/libmagic${stdenv.hostPlatform.extensions.sharedLibrary}'"
|
(substituteAll {
|
||||||
|
src = ./libmagic-path.patch;
|
||||||
|
libmagic = "${file}/lib/libmagic${stdenv.hostPlatform.extensions.sharedLibrary}";
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
checkInputs = [ glibcLocales ];
|
||||||
|
|
||||||
|
checkPhase = ''
|
||||||
|
LC_ALL="en_US.UTF-8" ${python.interpreter} test/test.py
|
||||||
'';
|
'';
|
||||||
|
|
||||||
doCheck = false;
|
|
||||||
|
|
||||||
# TODO: tests are failing
|
|
||||||
#checkPhase = ''
|
|
||||||
# ${python}/bin/${python.executable} ./test.py
|
|
||||||
#'';
|
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
description = "A python interface to the libmagic file type identification library";
|
description = "A python interface to the libmagic file type identification library";
|
||||||
homepage = "https://github.com/ahupp/python-magic";
|
homepage = "https://github.com/ahupp/python-magic";
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
diff --git a/magic/loader.py b/magic/loader.py
|
||||||
|
index 6b2bfcb..69778af 100644
|
||||||
|
--- a/magic/loader.py
|
||||||
|
+++ b/magic/loader.py
|
||||||
|
@@ -5,11 +5,7 @@ import glob
|
||||||
|
def load_lib():
|
||||||
|
libmagic = None
|
||||||
|
# Let's try to find magic or magic1
|
||||||
|
- dll = ctypes.util.find_library('magic') \
|
||||||
|
- or ctypes.util.find_library('magic1') \
|
||||||
|
- or ctypes.util.find_library('cygmagic-1') \
|
||||||
|
- or ctypes.util.find_library('libmagic-1') \
|
||||||
|
- or ctypes.util.find_library('msys-magic-1') # for MSYS2
|
||||||
|
+ dll = '@libmagic@'
|
||||||
|
|
||||||
|
# necessary because find_library returns None if it doesn't find the library
|
||||||
|
if dll:
|
Loading…
Reference in New Issue
Block a user