mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-09-24 17:00:26 +00:00
Changelog: https://github.com/emmett-framework/granian/releases/tag/v2.7.4
Had to re-create the mimalloc patch, opted to reduce the context to avoid doing so again in the future
(cherry picked from commit e888dc4c3b)
117 lines
2.7 KiB
Nix
117 lines
2.7 KiB
Nix
{
|
|
lib,
|
|
fetchFromGitHub,
|
|
rustPlatform,
|
|
cacert,
|
|
buildPythonPackage,
|
|
uvloop,
|
|
click,
|
|
setproctitle,
|
|
watchfiles,
|
|
versionCheckHook,
|
|
pytestCheckHook,
|
|
pytest-asyncio,
|
|
python-dotenv,
|
|
websockets,
|
|
httpx,
|
|
sniffio,
|
|
nix-update-script,
|
|
}:
|
|
|
|
buildPythonPackage rec {
|
|
pname = "granian";
|
|
version = "2.7.4";
|
|
pyproject = true;
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "emmett-framework";
|
|
repo = "granian";
|
|
tag = "v${version}";
|
|
hash = "sha256-KId5e1ITRCkLNmvY5q/ZT18INzS8Uh9HFCzfKEablOY=";
|
|
};
|
|
|
|
# Granian forces a custom allocator for all the things it runs,
|
|
# which breaks some libraries in funny ways. Make it not do that,
|
|
# and allow the final application to make the allocator decision
|
|
# via LD_PRELOAD or similar.
|
|
patches = [
|
|
./no-alloc.patch # with --unified=1 context
|
|
];
|
|
|
|
cargoDeps = rustPlatform.fetchCargoVendor {
|
|
inherit pname version src;
|
|
hash = "sha256-rR65e05uWmag+21n1YA1TILYU6ArajW2+QVOfGn4zGo=";
|
|
};
|
|
|
|
nativeBuildInputs = with rustPlatform; [
|
|
cargoSetupHook
|
|
maturinBuildHook
|
|
];
|
|
|
|
dependencies = [
|
|
click
|
|
];
|
|
|
|
optional-dependencies = {
|
|
dotenv = [ python-dotenv ];
|
|
pname = [ setproctitle ];
|
|
reload = [ watchfiles ];
|
|
# rloop = [ rloop ]; # not packaged
|
|
uvloop = [ uvloop ];
|
|
};
|
|
|
|
nativeCheckInputs = [
|
|
versionCheckHook
|
|
pytestCheckHook
|
|
pytest-asyncio
|
|
websockets
|
|
httpx
|
|
sniffio
|
|
];
|
|
|
|
preCheck = ''
|
|
# collides with the one installed in $out
|
|
rm -rf granian/
|
|
'';
|
|
|
|
# needed for checks
|
|
env.SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
|
|
|
|
__darwinAllowLocalNetworking = true;
|
|
|
|
enabledTestPaths = [ "tests/" ];
|
|
|
|
disabledTests = [
|
|
# SSLCertVerificationError: certificate verify failed: certificate has expired
|
|
"test_asgi_ws_scope"
|
|
"test_rsgi_ws_scope"
|
|
];
|
|
|
|
# This is a measure of last resort. Granian tests fully lock up
|
|
# on shutdown in >90% of cases, which makes the whole thing
|
|
# impossible to build without restarting it double digits
|
|
# numbers of times. The issue has not been fully identified,
|
|
# and upstream claims it does not exist.
|
|
# FIXME: root cause and fix this.
|
|
doCheck = false;
|
|
|
|
pythonImportsCheck = [ "granian" ];
|
|
|
|
versionCheckProgramArg = "--version";
|
|
|
|
passthru.updateScript = nix-update-script { };
|
|
|
|
meta = {
|
|
description = "Rust HTTP server for Python ASGI/WSGI/RSGI applications";
|
|
homepage = "https://github.com/emmett-framework/granian";
|
|
changelog = "https://github.com/emmett-framework/granian/releases/tag/v${version}";
|
|
license = lib.licenses.bsd3;
|
|
mainProgram = "granian";
|
|
maintainers = with lib.maintainers; [
|
|
lucastso10
|
|
pbsds
|
|
];
|
|
platforms = lib.platforms.unix;
|
|
};
|
|
}
|