aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/development/python-modules/protobuf
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2019-10-05 12:43:18 +0000
committerKatharina Fey <kookie@spacekookie.de>2019-10-05 12:44:52 +0000
commitcf85056ba64caf3267d43255ef4a1243e9c8ee3b (patch)
tree3051519e9c8275b870aac43f80af875715c9d124 /nixpkgs/pkgs/development/python-modules/protobuf
parent1148b1d122bc03e9a3665856c9b7bb96bd4e3994 (diff)
parent2436c27541b2f52deea3a4c1691216a02152e729 (diff)
Add 'nixpkgs/' from commit '2436c27541b2f52deea3a4c1691216a02152e729'
git-subtree-dir: nixpkgs git-subtree-mainline: 1148b1d122bc03e9a3665856c9b7bb96bd4e3994 git-subtree-split: 2436c27541b2f52deea3a4c1691216a02152e729
Diffstat (limited to 'nixpkgs/pkgs/development/python-modules/protobuf')
-rw-r--r--nixpkgs/pkgs/development/python-modules/protobuf/default.nix66
1 files changed, 66 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/python-modules/protobuf/default.nix b/nixpkgs/pkgs/development/python-modules/protobuf/default.nix
new file mode 100644
index 00000000000..d5ff4b04c59
--- /dev/null
+++ b/nixpkgs/pkgs/development/python-modules/protobuf/default.nix
@@ -0,0 +1,66 @@
+{ stdenv, fetchpatch, python, buildPythonPackage, isPy37
+, protobuf, google_apputils, pyext, libcxx
+, disabled, doCheck ? true }:
+
+with stdenv.lib;
+
+buildPythonPackage {
+ inherit (protobuf) name src version;
+ inherit disabled doCheck;
+
+ NIX_CFLAGS_COMPILE =
+ # work around python distutils compiling C++ with $CC
+ optional stdenv.isDarwin "-I${libcxx}/include/c++/v1"
+ ++ optional (versionOlder protobuf.version "2.7.0") "-std=c++98";
+
+ propagatedBuildInputs = [ google_apputils ];
+ propagatedNativeBuildInputs = [ protobuf ]; # For protoc.
+ nativeBuildInputs = [ google_apputils pyext ];
+ buildInputs = [ protobuf ];
+
+ patches = optional (isPy37 && (versionOlder protobuf.version "3.6.1.2"))
+ # Python 3.7 compatibility (not needed for protobuf >= 3.6.1.2)
+ (fetchpatch {
+ url = "https://github.com/protocolbuffers/protobuf/commit/0a59054c30e4f0ba10f10acfc1d7f3814c63e1a7.patch";
+ sha256 = "09hw22y3423v8bbmc9xm07znwdxfbya6rp78d4zqw6fisdvjkqf1";
+ stripLen = 1;
+ })
+ ;
+
+ prePatch = ''
+ while [ ! -d python ]; do
+ cd *
+ done
+ cd python
+ '';
+
+ preConfigure = optionalString (versionAtLeast protobuf.version "2.6.0") ''
+ export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
+ export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION=2
+ '';
+
+ preBuild = ''
+ # Workaround for https://github.com/google/protobuf/issues/2895
+ ${python.interpreter} setup.py build
+ '' + optionalString (versionAtLeast protobuf.version "2.6.0") ''
+ ${python.interpreter} setup.py build_ext --cpp_implementation
+ '';
+
+ installFlags = optional (versionAtLeast protobuf.version "2.6.0")
+ "--install-option='--cpp_implementation'";
+
+ # the _message.so isn't installed, so we'll do that manually.
+ # if someone can figure out a less hacky way to get the _message.so to
+ # install, please do replace this.
+ postInstall = optionalString (versionAtLeast protobuf.version "2.6.0") ''
+ cp -v $(find build -name "_message*") $out/${python.sitePackages}/google/protobuf/pyext
+ '';
+
+ meta = {
+ description = "Protocol Buffers are Google's data interchange format";
+ homepage = https://developers.google.com/protocol-buffers/;
+ license = licenses.bsd3;
+ };
+
+ passthru.protobuf = protobuf;
+}