about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorMartin Weinelt <hexa@darmstadt.ccc.de>2022-04-07 00:09:19 +0200
committerMartin Weinelt <hexa@darmstadt.ccc.de>2022-04-07 02:45:44 +0200
commite12a1433cc46e0163f2a3d6cb2d2ab3f2af6a208 (patch)
tree07d0e4a16fb25670cb4dc468b865a9a3aa8632cb /pkgs
parentdd986a65f6a214f949dc278dd4e1d1266cfc5793 (diff)
python3Packages.gattlib: init at unstable-2021-06-16
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/python-modules/gattlib/default.nix68
-rw-r--r--pkgs/development/python-modules/gattlib/setup.patch18
-rw-r--r--pkgs/top-level/python-packages.nix4
3 files changed, 90 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/gattlib/default.nix b/pkgs/development/python-modules/gattlib/default.nix
new file mode 100644
index 0000000000000..c7450d6b6b5b8
--- /dev/null
+++ b/pkgs/development/python-modules/gattlib/default.nix
@@ -0,0 +1,68 @@
+{ lib
+, buildPythonPackage
+, fetchFromGitHub
+, substituteAll
+
+# build
+, pkg-config
+, glibc
+, python
+
+# runtime
+, bluez
+, boost
+, glib
+
+}:
+
+let
+  pname = "gattlib";
+  version = "unstable-2021-06-16";
+in
+buildPythonPackage {
+  inherit pname version;
+  format = "setuptools";
+
+
+  src = fetchFromGitHub {
+    owner = "oscaracena";
+    repo = "pygattlib";
+    rev = "7bdb229124fe7d9f4a2cc090277b0fdef82e2a56";
+    hash = "sha256-PS5DIH1JuH2HweyebLLM+UNFGY/XsjKIrsD9x7g7yMI=";
+  };
+
+  patches = [
+    (substituteAll {
+      src = ./setup.patch;
+      boost_version = let
+        pythonVersion = with lib.versions; "${major python.version}${minor python.version}";
+      in
+        "boost_python${pythonVersion}";
+    })
+  ];
+
+  nativeBuildInputs = [
+    pkg-config
+    glibc
+  ];
+
+  buildInputs = [
+    bluez
+    boost
+    glib
+  ];
+
+  # has no tests
+  doCheck = false;
+
+  pythonImportsCheck = [
+    "gattlib"
+  ];
+
+  meta = with lib; {
+    description = "Python library to use the GATT Protocol for Bluetooth LE devices";
+    homepage = "https://github.com/oscaracena/pygattlib";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ hexa ];
+  };
+}
diff --git a/pkgs/development/python-modules/gattlib/setup.patch b/pkgs/development/python-modules/gattlib/setup.patch
new file mode 100644
index 0000000000000..32c3b1be496d1
--- /dev/null
+++ b/pkgs/development/python-modules/gattlib/setup.patch
@@ -0,0 +1,18 @@
+diff --git a/setup.py b/setup.py
+index 0825241..389a59e 100755
+--- a/setup.py
++++ b/setup.py
+@@ -11,12 +11,7 @@ extension_modules = []
+ 
+ 
+ def get_boost_version(out=None):
+-    if out is None:
+-        out = subprocess.check_output(
+-            r"ldconfig -p | grep -E 'libboost_python.*\.so '", shell=True)
+-
+-    ver = os.path.splitext(out.split()[0][3:])[0].decode()
+-    return ver
++    return "@boost_version@"
+ 
+ def tests():
+     # case: python3-py3x.so
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 6ab71fd1e11d8..cd444fceff129 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -3205,6 +3205,10 @@ in {
 
   garages-amsterdam = callPackage ../development/python-modules/garages-amsterdam { };
 
+  gattlib = callPackage ../development/python-modules/gattlib {
+    inherit (pkgs) bluez glib pkg-config;
+  };
+
   gbinder-python = callPackage ../development/python-modules/gbinder-python { };
 
   gcovr = callPackage ../development/python-modules/gcovr { };