nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 125 lines 2.8 kB view raw
1{ 2 lib, 3 fetchFromGitHub, 4 python3Packages, 5 softhsm, 6 installShellFiles, 7}: 8 9python3Packages.buildPythonApplication rec { 10 pname = "esptool"; 11 version = "5.1.0"; 12 pyproject = true; 13 14 src = fetchFromGitHub { 15 owner = "espressif"; 16 repo = "esptool"; 17 tag = "v${version}"; 18 hash = "sha256-pdkL/QfrrTs/NdXlsr+2Yo+r8UTFLkxw4E6XGDAt1yE="; 19 }; 20 21 postPatch = '' 22 patchShebangs ci 23 24 substituteInPlace test/test_espsecure_hsm.py \ 25 --replace-fail "/usr/lib/softhsm" "${lib.getLib softhsm}/lib/softhsm" 26 ''; 27 28 build-system = with python3Packages; [ 29 setuptools 30 ]; 31 32 dependencies = with python3Packages; [ 33 bitstring 34 click 35 cryptography 36 intelhex 37 pyserial 38 pyyaml 39 reedsolo 40 rich-click 41 ]; 42 43 optional-dependencies = with python3Packages; { 44 hsm = [ python-pkcs11 ]; 45 }; 46 47 nativeBuildInputs = [ 48 installShellFiles 49 ]; 50 51 postInstall = '' 52 rm -v $out/bin/*.py 53 '' 54 + 55 lib.strings.concatMapStrings 56 ( 57 cmd: 58 # Unfortunately, espsecure and espefuse do not run in cross-compilation 59 lib.optionalString 60 ( 61 python3Packages.stdenv.buildPlatform.canExecute python3Packages.stdenv.hostPlatform 62 || cmd == "esptool" 63 ) 64 '' 65 installShellCompletion --cmd ${cmd} \ 66 --bash <(_${lib.toUpper cmd}_COMPLETE=bash_source $out/bin/${cmd}) \ 67 --zsh <(_${lib.toUpper cmd}_COMPLETE=zsh_source $out/bin/${cmd}) \ 68 --fish <(_${lib.toUpper cmd}_COMPLETE=fish_source $out/bin/${cmd}) 69 '' 70 ) 71 [ 72 "esptool" 73 "espsecure" 74 "espefuse" 75 ]; 76 77 nativeCheckInputs = 78 with python3Packages; 79 [ 80 pyelftools 81 pytestCheckHook 82 requests 83 softhsm 84 ] 85 ++ lib.concatAttrValues optional-dependencies; 86 87 preCheck = '' 88 export PATH="$out/bin:$PATH" 89 ''; 90 91 pytestFlags = [ 92 "-m" 93 "host_test" 94 ]; 95 96 disabledTests = [ 97 # remove the deprecated .py entrypoints, because our wrapper tries to 98 # import esptool and finds esptool.py in $out/bin, which breaks. 99 "test_esptool_py" 100 "test_espefuse_py" 101 "test_espsecure_py" 102 "test_esp_rfc2217_server_py" 103 ]; 104 105 postCheck = '' 106 export SOFTHSM2_CONF=$(mktemp) 107 echo "directories.tokendir = $(mktemp -d)" > "$SOFTHSM2_CONF" 108 ./ci/setup_softhsm2.sh 109 110 pytest test/test_espsecure_hsm.py 111 ''; 112 113 meta = { 114 changelog = "https://github.com/espressif/esptool/blob/${src.tag}/CHANGELOG.md"; 115 description = "ESP8266 and ESP32 serial bootloader utility"; 116 homepage = "https://github.com/espressif/esptool"; 117 license = lib.licenses.gpl2Plus; 118 maintainers = with lib.maintainers; [ 119 dezgeg 120 dotlambda 121 ]; 122 platforms = with lib.platforms; linux ++ darwin; 123 mainProgram = "esptool"; 124 }; 125}