diff options
Diffstat (limited to 'pkgs/development/libraries/opencv')
-rw-r--r-- | pkgs/development/libraries/opencv/4.x.nix | 22 | ||||
-rw-r--r-- | pkgs/development/libraries/opencv/default.nix | 6 |
2 files changed, 24 insertions, 4 deletions
diff --git a/pkgs/development/libraries/opencv/4.x.nix b/pkgs/development/libraries/opencv/4.x.nix index 10459d959b299..0c6f9fb90c0c4 100644 --- a/pkgs/development/libraries/opencv/4.x.nix +++ b/pkgs/development/libraries/opencv/4.x.nix @@ -275,7 +275,12 @@ stdenv.mkDerivation { propagatedBuildInputs = lib.optional enablePython pythonPackages.numpy ++ lib.optionals enableCuda [ cudatoolkit nvidia-optical-flow-sdk ]; - nativeBuildInputs = [ cmake pkg-config unzip ]; + nativeBuildInputs = [ cmake pkg-config unzip ] + ++ lib.optionals enablePython [ + pythonPackages.pip + pythonPackages.wheel + pythonPackages.setuptools + ]; NIX_CFLAGS_COMPILE = lib.optionalString enableEXR "-I${ilmbase.dev}/include/OpenEXR"; @@ -333,6 +338,21 @@ stdenv.mkDerivation { postInstall = '' sed -i "s|{exec_prefix}/$out|{exec_prefix}|;s|{prefix}/$out|{prefix}|" \ "$out/lib/pkgconfig/opencv4.pc" + '' + # install python distribution information, so other packages can `import opencv` + + lib.optionalString enablePython '' + pushd $NIX_BUILD_TOP/$sourceRoot/modules/python/package + python -m pip wheel --verbose --no-index --no-deps --no-clean --no-build-isolation --wheel-dir dist . + + pushd dist + python -m pip install ./*.whl --no-index --no-warn-script-location --prefix="$out" --no-cache + + # the cv2/__init__.py just tries to check provide "nice user feedback" if the installation is bad + # however, this also causes infinite recursion when used by other packages + rm -r $out/${pythonPackages.python.sitePackages}/cv2 + + popd + popd ''; passthru = lib.optionalAttrs enablePython { pythonPath = [ ]; }; diff --git a/pkgs/development/libraries/opencv/default.nix b/pkgs/development/libraries/opencv/default.nix index ed2f700dc82ea..34dcd240838ef 100644 --- a/pkgs/development/libraries/opencv/default.nix +++ b/pkgs/development/libraries/opencv/default.nix @@ -1,6 +1,6 @@ { lib, stdenv, fetchFromGitHub, cmake, pkg-config, unzip , zlib -, enablePython ? false, pythonPackages +, enablePython ? false, python2Packages , enableGtk2 ? false, gtk2 , enableJPEG ? true, libjpeg , enablePNG ? true, libpng @@ -44,7 +44,7 @@ stdenv.mkDerivation rec { buildInputs = [ zlib ] - ++ lib.optional enablePython pythonPackages.python + ++ lib.optional enablePython python2Packages.python ++ lib.optional enableGtk2 gtk2 ++ lib.optional enableJPEG libjpeg ++ lib.optional enablePNG libpng @@ -56,7 +56,7 @@ stdenv.mkDerivation rec { ++ lib.optionals stdenv.isDarwin [ Cocoa QTKit ] ; - propagatedBuildInputs = lib.optional enablePython pythonPackages.numpy; + propagatedBuildInputs = lib.optional enablePython python2Packages.numpy; nativeBuildInputs = [ cmake pkg-config unzip ]; |