From 959e9244d9202f0bf24132646dd9c9b7457526fe Mon Sep 17 00:00:00 2001 From: Robert Scott Date: Sun, 29 Mar 2020 22:05:50 +0100 Subject: [PATCH] nghttp2: add python bindings as pythonPackages.nghttp2 it's tricky to enable in nghttp2's default build, however, because it needs to be usable by curl, a very core nix package, and we get cyclical dependencies if we add python to its requirements. having it available as a separate build is better than nothing, though. --- .../development/libraries/nghttp2/default.nix | 28 +++++++++++++++---- pkgs/top-level/python-packages.nix | 6 ++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/pkgs/development/libraries/nghttp2/default.nix b/pkgs/development/libraries/nghttp2/default.nix index 57ed58912751..eae4563cf80e 100644 --- a/pkgs/development/libraries/nghttp2/default.nix +++ b/pkgs/development/libraries/nghttp2/default.nix @@ -9,14 +9,16 @@ , enableGetAssets ? false, libxml2 ? null , enableJemalloc ? false, jemalloc ? null , enableApp ? !stdenv.hostPlatform.isWindows +, enablePython ? false, python ? null, cython ? null, ncurses ? null, setuptools ? null }: assert enableHpack -> jansson != null; assert enableAsioLib -> boost != null; assert enableGetAssets -> libxml2 != null; assert enableJemalloc -> jemalloc != null; +assert enablePython -> python != null && cython != null && ncurses != null && setuptools != null; -let inherit (stdenv.lib) optional; in +let inherit (stdenv.lib) optional optionals optionalString; in stdenv.mkDerivation rec { pname = "nghttp2"; @@ -27,7 +29,8 @@ stdenv.mkDerivation rec { sha256 = "0kyrgd4s2pq51ps5z385kw1hn62m8qp7c4h6im0g4ibrf89qwxc2"; }; - outputs = [ "bin" "out" "dev" "lib" ]; + outputs = [ "bin" "out" "dev" "lib" ] + ++ optional enablePython "python"; nativeBuildInputs = [ pkgconfig ]; buildInputs = [ openssl ] @@ -37,16 +40,31 @@ stdenv.mkDerivation rec { ++ optional enableHpack jansson ++ optional enableAsioLib boost ++ optional enableGetAssets libxml2 - ++ optional enableJemalloc jemalloc; + ++ optional enableJemalloc jemalloc + ++ optionals enablePython [ python ncurses setuptools ]; enableParallelBuilding = true; configureFlags = [ "--with-spdylay=no" "--disable-examples" - "--disable-python-bindings" (stdenv.lib.enableFeature enableApp "app") - ] ++ optional enableAsioLib "--enable-asio-lib --with-boost-libdir=${boost}/lib"; + ] ++ optional enableAsioLib "--enable-asio-lib --with-boost-libdir=${boost}/lib" + ++ (if enablePython then [ + "--with-cython=${cython}/bin/cython" + ] else [ + "--disable-python-bindings" + ]); + + preInstall = optionalString enablePython '' + mkdir -p $out/${python.sitePackages} + # convince installer it's ok to install here + export PYTHONPATH="$PYTHONPATH:$out/${python.sitePackages}" + ''; + postInstall = optionalString enablePython '' + mkdir -p $python/${python.sitePackages} + mv $out/${python.sitePackages}/* $python/${python.sitePackages} + ''; #doCheck = true; # requires CUnit ; currently failing at test_util_localtime_date in util_test.cc diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 8bfd0ccbc5de..77e179afc1ad 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -4533,6 +4533,12 @@ in { nevow = callPackage ../development/python-modules/nevow { }; + nghttp2 = (toPythonModule (pkgs.nghttp2.override { + inherit (self) python cython setuptools; + inherit (pkgs) ncurses; + enablePython = true; + })).python; + nibabel = callPackage ../development/python-modules/nibabel {}; nidaqmx = callPackage ../development/python-modules/nidaqmx { };