1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchPypi, 6 setuptools, 7 pkgs, 8 pytestCheckHook, 9}: 10 11let 12 libsecp256k1_name = 13 if stdenv.hostPlatform.isLinux then 14 "libsecp256k1.so.{v}" 15 else if stdenv.hostPlatform.isDarwin then 16 "libsecp256k1.{v}.dylib" 17 else 18 "libsecp256k1${stdenv.hostPlatform.extensions.sharedLibrary}"; 19in 20buildPythonPackage rec { 21 pname = "electrum-ecc"; 22 version = "0.0.5"; 23 pyproject = true; 24 build-system = [ setuptools ]; 25 26 src = fetchPypi { 27 pname = "electrum_ecc"; 28 inherit version; 29 hash = "sha256-9zO4WWoPeyXINx0Ir2Hvece4cdW0DwWluV0tBesvt9I="; 30 }; 31 32 env = { 33 # Prevent compilation of the C extension as we use the system library instead. 34 ELECTRUM_ECC_DONT_COMPILE = "1"; 35 }; 36 37 postPatch = '' 38 # remove bundled libsecp256k1 39 rm -rf libsecp256k1/ 40 # use the system library instead 41 substituteInPlace ./src/electrum_ecc/ecc_fast.py \ 42 --replace-fail ${libsecp256k1_name} ${pkgs.secp256k1}/lib/libsecp256k1${stdenv.hostPlatform.extensions.sharedLibrary} 43 ''; 44 45 nativeCheckInputs = [ pytestCheckHook ]; 46 47 pythonImportsCheck = [ "electrum_ecc" ]; 48 49 meta = with lib; { 50 description = "Pure python ctypes wrapper for libsecp256k1"; 51 homepage = "https://github.com/spesmilo/electrum-ecc"; 52 license = licenses.mit; 53 maintainers = [ ]; 54 }; 55}