at 17.09-beta 1.6 kB view raw
1{ stdenv, python, buildPythonPackage 2, protobuf, google_apputils, pyext, libcxx 3, disabled, doCheck ? true }: 4 5with stdenv.lib; 6 7buildPythonPackage rec { 8 inherit (protobuf) name src; 9 inherit disabled doCheck; 10 11 # work around python distutils compiling C++ with $CC 12 NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1"; 13 14 propagatedBuildInputs = [ protobuf google_apputils ]; 15 buildInputs = [ google_apputils pyext ]; 16 17 prePatch = '' 18 while [ ! -d python ]; do 19 cd * 20 done 21 cd python 22 ''; 23 24 preConfigure = optionalString (versionAtLeast protobuf.version "2.6.0") '' 25 export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp 26 export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION=2 27 ''; 28 29 preBuild = optionalString (versionAtLeast protobuf.version "2.6.0") '' 30 ${python}/bin/${python.executable} setup.py build_ext --cpp_implementation 31 ''; 32 33 installFlags = optional (versionAtLeast protobuf.version "2.6.0") 34 "--install-option='--cpp_implementation'"; 35 36 # the _message.so isn't installed, so we'll do that manually. 37 # if someone can figure out a less hacky way to get the _message.so to 38 # install, please do replace this. 39 postInstall = optionalString (versionAtLeast protobuf.version "2.6.0") '' 40 cp -v $(find build -name "_message*") $out/${python.sitePackages}/google/protobuf/pyext 41 ''; 42 43 meta = { 44 description = "Protocol Buffers are Google's data interchange format"; 45 homepage = https://developers.google.com/protocol-buffers/; 46 }; 47 48 passthru.protobuf = protobuf; 49}