Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at gcc-offload 96 lines 2.3 kB view raw
1{ 2 lib, 3 stdenv, 4 substituteAll, 5 buildPythonPackage, 6 fetchPypi, 7 pythonOlder, 8 asn1crypto, 9 cffi, 10 cryptography, 11 pkgconfig, # see nativeBuildInputs 12 pkg-config, # see nativeBuildInputs 13 pytestCheckHook, 14 pyyaml, 15 setuptools-scm, 16 tpm2-tss, 17 tpm2-tools, 18 swtpm, 19}: 20 21let 22 isCross = (stdenv.buildPlatform != stdenv.hostPlatform); 23in 24buildPythonPackage rec { 25 pname = "tpm2-pytss"; 26 version = "2.3.0"; 27 format = "setuptools"; 28 29 disabled = pythonOlder "3.7"; 30 31 src = fetchPypi { 32 inherit pname version; 33 hash = "sha256-IAcRKTeWVvXzw7wW02RhJnKxR9gRkftOufn/n77khBA="; 34 }; 35 36 patches = 37 [ 38 # Fix hardcoded `fapi-config.json` configuration path 39 ./fapi-config.patch 40 ] 41 ++ lib.optionals isCross [ 42 # pytss will regenerate files from headers of tpm2-tss. 43 # Those headers are fed through a compiler via pycparser. pycparser expects `cpp` 44 # to be in the path. 45 # This is put in the path via stdenv when not cross-compiling, but this is absent 46 # when cross-compiling is turned on. 47 # This patch changes the call to pycparser.preprocess_file to provide the name 48 # of the cross-compiling cpp 49 (substituteAll { 50 src = ./cross.patch; 51 crossPrefix = stdenv.hostPlatform.config; 52 }) 53 ]; 54 55 postPatch = '' 56 sed -i "s#@TPM2_TSS@#${tpm2-tss.out}#" src/tpm2_pytss/FAPI.py 57 ''; 58 59 # Hardening has to be disabled 60 # due to pycparsing handling it poorly. 61 # See https://github.com/NixOS/nixpkgs/issues/252023 62 # for more details. 63 hardeningDisable = [ "fortify" ]; 64 65 nativeBuildInputs = [ 66 cffi 67 pkgconfig # this is the Python module 68 pkg-config # this is the actual pkg-config tool 69 setuptools-scm 70 ]; 71 72 buildInputs = [ tpm2-tss ]; 73 74 propagatedBuildInputs = [ 75 cffi 76 asn1crypto 77 cryptography 78 pyyaml 79 ]; 80 81 nativeCheckInputs = [ 82 pytestCheckHook 83 tpm2-tools 84 swtpm 85 ]; 86 87 pythonImportsCheck = [ "tpm2_pytss" ]; 88 89 meta = with lib; { 90 homepage = "https://github.com/tpm2-software/tpm2-pytss"; 91 changelog = "https://github.com/tpm2-software/tpm2-pytss/blob/${version}/CHANGELOG.md"; 92 description = "TPM2 TSS Python bindings for Enhanced System API (ESYS)"; 93 license = licenses.bsd2; 94 maintainers = with maintainers; [ baloo ]; 95 }; 96}