From 1e3b8412c0f73aa96b16f793d33e1a409849c802 Mon Sep 17 00:00:00 2001 From: Bradley Walters Date: Tue, 12 Oct 2021 16:35:17 -0600 Subject: [PATCH 1/2] python3Packages.kivy: make gstreamer optional --- pkgs/development/python-modules/kivy/default.nix | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pkgs/development/python-modules/kivy/default.nix b/pkgs/development/python-modules/kivy/default.nix index d4fa39c0c363..e40a9465d1a2 100644 --- a/pkgs/development/python-modules/kivy/default.nix +++ b/pkgs/development/python-modules/kivy/default.nix @@ -2,7 +2,9 @@ , buildPythonPackage, fetchPypi , pkg-config, cython, docutils , kivy-garden -, mesa, mtdev, SDL2, SDL2_image, SDL2_ttf, SDL2_mixer, gst_all_1 +, mesa, mtdev, SDL2, SDL2_image, SDL2_ttf, SDL2_mixer +, withGstreamer ? true +, gst_all_1 , pillow, requests, pygments }: @@ -28,13 +30,13 @@ buildPythonPackage rec { SDL2_image SDL2_ttf SDL2_mixer - + ] ++ lib.optionals withGstreamer (with gst_all_1; [ # NOTE: The degree to which gstreamer actually works is unclear - gst_all_1.gstreamer - gst_all_1.gst-plugins-base - gst_all_1.gst-plugins-good - gst_all_1.gst-plugins-bad - ]; + gstreamer + gst-plugins-base + gst-plugins-good + gst-plugins-bad + ]); propagatedBuildInputs = [ kivy-garden From 5b6d500300ba282f966d2da530eda0b4b96262b9 Mon Sep 17 00:00:00 2001 From: Bradley Walters Date: Tue, 12 Oct 2021 18:49:04 -0600 Subject: [PATCH 2/2] python3Packages.kivy: add darwin support --- .../python-modules/kivy/default.nix | 36 ++++++++++++++----- pkgs/top-level/python-packages.nix | 1 + 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/pkgs/development/python-modules/kivy/default.nix b/pkgs/development/python-modules/kivy/default.nix index e40a9465d1a2..0e8b81ed19cd 100644 --- a/pkgs/development/python-modules/kivy/default.nix +++ b/pkgs/development/python-modules/kivy/default.nix @@ -1,8 +1,9 @@ -{ lib -, buildPythonPackage, fetchPypi +{ lib, stdenv +, buildPythonPackage, fetchFromGitHub, fetchpatch , pkg-config, cython, docutils , kivy-garden , mesa, mtdev, SDL2, SDL2_image, SDL2_ttf, SDL2_mixer +, ApplicationServices, AVFoundation, libcxx , withGstreamer ? true , gst_all_1 , pillow, requests, pygments @@ -12,11 +13,21 @@ buildPythonPackage rec { pname = "Kivy"; version = "2.0.0"; - src = fetchPypi { - inherit pname version; - sha256 = "1n0j9046vgjncy50v06r3wcg3q2l37jp8n0cznr64dz48kml8pnj"; + # use github since pypi line endings are CRLF and patches do not apply + src = fetchFromGitHub { + owner = "kivy"; + repo = "kivy"; + rev = version; + sha256 = "sha256-/7GSVQUkYSBEnLVBizMnZAZZxvXVN4r4lskyOgLEcew="; }; + patches = [ + (fetchpatch { + url = "https://github.com/kivy/kivy/commit/1c0656c4472817677cf3b08be504de9ca6b1713f.patch"; + sha256 = "sha256-phAjMaC3LQuvufwiD0qXzie5B+kezCf8FpKeQMhy/ms="; + }) + ]; + nativeBuildInputs = [ pkg-config cython @@ -24,12 +35,17 @@ buildPythonPackage rec { ]; buildInputs = [ - mesa - mtdev SDL2 SDL2_image SDL2_ttf SDL2_mixer + ] ++ lib.optionals stdenv.isLinux [ + mesa + mtdev + ] ++ lib.optionals stdenv.isDarwin [ + ApplicationServices + AVFoundation + libcxx ] ++ lib.optionals withGstreamer (with gst_all_1; [ # NOTE: The degree to which gstreamer actually works is unclear gstreamer @@ -48,8 +64,12 @@ buildPythonPackage rec { KIVY_NO_CONFIG = 1; KIVY_NO_ARGS = 1; KIVY_NO_FILELOG = 1; + # prefer pkg-config over hardcoded framework paths + USE_OSX_FRAMEWORKS = 0; + # work around python distutils compiling C++ with $CC (see issue #26709) + NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-I${lib.getDev libcxx}/include/c++/v1"; - postPatch = '' + postPatch = lib.optionalString stdenv.isLinux '' substituteInPlace kivy/lib/mtdev.py \ --replace "LoadLibrary('libmtdev.so.1')" "LoadLibrary('${mtdev}/lib/libmtdev.so.1')" ''; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 10f2bbca0928..209372db3763 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -4075,6 +4075,7 @@ in { kivy = callPackage ../development/python-modules/kivy { inherit (pkgs) mesa; + inherit (pkgs.darwin.apple_sdk.frameworks) ApplicationServices AVFoundation; }; kivy-garden = callPackage ../development/python-modules/kivy-garden { };