1{ 2 lib, 3 buildPythonPackage, 4 fetchPypi, 5 fetchpatch, 6 setuptools, 7 autobahn, 8 twisted, 9 python, 10 pytestCheckHook, 11}: 12 13buildPythonPackage rec { 14 pname = "magic-wormhole-transit-relay"; 15 version = "0.4.0"; 16 pyproject = true; 17 18 src = fetchPypi { 19 inherit pname version; 20 hash = "sha256-kS2DXaIbESZsdxEdybXlgAJj/AuY8KF5liJn30GBnow="; 21 }; 22 23 patches = [ 24 # TODO: drop when updating beyond version 0.4.0 25 (fetchpatch { 26 name = "stock-Twisted-testing-reactor-seems-to-work.patch"; 27 url = "https://github.com/magic-wormhole/magic-wormhole-transit-relay/commit/3abb80fd5e55bd0ba8ee66278ccf76be5f904622.patch"; 28 hash = "sha256-qMaJ58kPWvEfnSZiFzxO6GlkBiyVMsgGDEa1deITZco="; 29 }) 30 ]; 31 32 postPatch = '' 33 # Passing the environment to twistd is necessary to preserve Python's site path. 34 substituteInPlace src/wormhole_transit_relay/test/test_backpressure.py --replace-fail \ 35 'reactor.spawnProcess(proto, exe, args)' \ 36 'reactor.spawnProcess(proto, exe, args, None)' 37 ''; 38 39 build-system = [ setuptools ]; 40 41 dependencies = [ 42 autobahn 43 setuptools # pkg_resources is referenced at runtime 44 twisted 45 ]; 46 47 pythonImportsCheck = [ "wormhole_transit_relay" ]; 48 49 nativeCheckInputs = [ 50 pytestCheckHook 51 twisted 52 ]; 53 54 __darwinAllowLocalNetworking = true; 55 56 postCheck = '' 57 # Avoid collision with twisted's plugin cache (#164775). 58 rm "$out/${python.sitePackages}/twisted/plugins/dropin.cache" 59 ''; 60 61 meta = { 62 description = "Transit Relay server for Magic-Wormhole"; 63 homepage = "https://github.com/magic-wormhole/magic-wormhole-transit-relay"; 64 changelog = "https://github.com/magic-wormhole/magic-wormhole-transit-relay/blob/${version}/NEWS.md"; 65 license = lib.licenses.mit; 66 maintainers = [ lib.maintainers.mjoerg ]; 67 }; 68}