18 inherit (protobuf) pname src version;
20 doCheck = doCheck && !isPy27; # setuptools>=41.4 no longer collects correctly on python2
22 outputs = [ "out" "dev" ];
24 propagatedBuildInputs = [ six ] ++ lib.optionals isPy27 [ google-apputils ];
25 propagatedNativeBuildInputs = [ buildPackages.protobuf ]; # For protoc.
26 nativeBuildInputs = [ pyext ] ++ lib.optionals isPy27 [ google-apputils ];
27 buildInputs = [ protobuf ];
29 patches = lib.optional (isPy37 && (lib.versionOlder protobuf.version "3.6.1.2"))
30 # Python 3.7 compatibility (not needed for protobuf >= 3.6.1.2)
32 url = "https://github.com/protocolbuffers/protobuf/commit/0a59054c30e4f0ba10f10acfc1d7f3814c63e1a7.patch";
33 sha256 = "09hw22y3423v8bbmc9xm07znwdxfbya6rp78d4zqw6fisdvjkqf1";
39 while [ ! -d python ]; do
45 preConfigure = lib.optionalString (lib.versionAtLeast protobuf.version "2.6.0") ''
46 export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
47 export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION=2
51 # Workaround for https://github.com/google/protobuf/issues/2895
52 ${python.pythonForBuild.interpreter} setup.py build
53 '' + lib.optionalString (lib.versionAtLeast protobuf.version "2.6.0") ''
54 ${python.pythonForBuild.interpreter} setup.py build_ext --cpp_implementation
57 installFlags = lib.optional (lib.versionAtLeast protobuf.version "2.6.0")
58 "--install-option='--cpp_implementation'";
60 # the _message.so isn't installed, so we'll do that manually.
61 # if someone can figure out a less hacky way to get the _message.so to
62 # install, please do replace this.
63 postInstall = lib.optionalString (lib.versionAtLeast protobuf.version "2.6.0") ''
64 cp -v $(find build -name "_message*") $out/${python.sitePackages}/google/protobuf/pyext
68 description = "Protocol Buffers are Google's data interchange format";
69 homepage = "https://developers.google.com/protocol-buffers/";
70 license = licenses.bsd3;
73 passthru.protobuf = protobuf;