From 715ec6e88575dcf3aeafda832627c00e83f3eadf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Danie=CC=88l=20de=20Kok?= <me@danieldk.eu>
Date: Wed, 27 Mar 2019 19:56:19 +0100
Subject: [PATCH] pythonPackages.grpcio: fix build on Darwin

Builds on Darwin have started to fail recently. This seems to be caused
by a check in Makefile that verifies whether the system is able to build
BoringSSL. This check attempts to compile test/build/boringssl.c, which
is absent in PyPI archives of grpcio.

This change builds the grpcio module directly from the grpc git
repository, so that all the files that are necessary for checks are
present.

Affects #56826 since darwin builds of this derivation on nixpkgs-19.03
fail.
---
 .../python-modules/grpcio/default.nix           | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/pkgs/development/python-modules/grpcio/default.nix b/pkgs/development/python-modules/grpcio/default.nix
index 3ecc0b3294fa..9d8814e65313 100644
--- a/pkgs/development/python-modules/grpcio/default.nix
+++ b/pkgs/development/python-modules/grpcio/default.nix
@@ -1,17 +1,22 @@
-{ stdenv, buildPythonPackage, fetchPypi, lib, darwin
-, six, protobuf, enum34, futures, isPy27, isPy34, pkgconfig }:
+{ stdenv, buildPythonPackage, fetchFromGitHub, lib, darwin
+, six, protobuf, enum34, futures, isPy27, isPy34, pkgconfig
+, cython}:
 
 with stdenv.lib;
 buildPythonPackage rec {
   pname = "grpcio";
   version = "1.18.0";
 
-  src = fetchPypi {
-    inherit pname version;
-    sha256 = "abe825aa49e6239d5edf4e222c44170d2c7f6f4b1fd5286b4756a62d8067e112";
+  src = fetchFromGitHub {
+    owner = "grpc";
+    repo = "grpc";
+    rev = "v${version}";
+    fetchSubmodules = true;
+    sha256 = "0cilbhk35gv46mk40jl5f3iqa94x14qyxbavpfq0kh0rld82nx4m";
   };
 
-  nativeBuildInputs = [ pkgconfig ] ++ optional stdenv.isDarwin darwin.cctools;
+  nativeBuildInputs = [ cython pkgconfig ]
+                    ++ optional stdenv.isDarwin darwin.cctools;
 
   propagatedBuildInputs = [ six protobuf ]
                         ++ lib.optionals (isPy27 || isPy34) [ enum34 ]