Skip to content

Commit

Permalink
Merge pull request #324462 from Pandapip1/init-brainflow
Browse files Browse the repository at this point in the history
brainflow: init at 5.12.1
  • Loading branch information
JohnRTitor authored Jul 17, 2024
2 parents 3f7fcbb + 7893672 commit 3dfa73e
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 0 deletions.
86 changes: 86 additions & 0 deletions pkgs/by-name/br/brainflow/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
bluez,
cmake,
dbus,
libftdi1,
nix-update-script,
pkg-config,
useLibFTDI ? true,
useOpenMP ? true,
buildBluetooth ? true,
buildBluetoothLowEnergy ? true,
buildONNX ? true,
}:

stdenv.mkDerivation (finalAttrs: {
pname = "brainflow";
version = "5.12.1";

src = fetchFromGitHub {
owner = "brainflow-dev";
repo = "brainflow";
rev = "refs/tags/${finalAttrs.version}";
hash = "sha256-haQO03nkvLoXtFVe+C+yi+MwM0CFh6rLcLvU8fQ4k/w=";
};

patches = [
# All of these are PRs that were merged into the upstream repository and will be included in the next release
# These should be removed once the next version is released
(fetchpatch {
# Fixes a major issue that prevented the build from working at all (why was this not backported???)
url = "https://github.com/brainflow-dev/brainflow/commit/883b0cd08acb99d7b6e241e92fba2e9a363d17b1.patch";
hash = "sha256-QQd+BI3I65gfaNS/SKLjCoqbCwPCiTh+nh0tJAZM6hQ=";
})
(fetchpatch {
# Bumps the version of a python dependency that had a backwards-incompatible change
url = "https://github.com/brainflow-dev/brainflow/commit/ea23a6f0483ce4d6fdd7a82bace865356ee78d7f.patch";
hash = "sha256-dvMpxxRrnJQ9ADGagB1JhuoB9SNwn755wbHzW/3ECeo=";
})
(fetchpatch {
# Fixes an incorrect use of an environment variable during the build
url = "https://github.com/brainflow-dev/brainflow/commit/053b8c1253b686cbec49ab4adb47c9ee02d3f99a.patch";
hash = "sha256-Pfhe1ZvMagfVAGZqeWn1uHXgwlTtkOm+gyWuvC5/Sro=";
})
];

cmakeFlags = with lib; [
(cmakeBool "USE_LIBFTDI" useLibFTDI)
(cmakeBool "USE_OPENMP" useOpenMP)
(cmakeBool "BUILD_OYMOTION_SDK" false) # Needs a "GFORCE_SDK"
(cmakeBool "BUILD_BLUETOOTH" buildBluetooth)
(cmakeBool "BUILD_BLE" buildBluetoothLowEnergy)
(cmakeBool "BUILD_ONNX" buildONNX)
];

buildInputs =
[ dbus ]
++ lib.optional (buildBluetooth || buildBluetoothLowEnergy) bluez
++ lib.optional useLibFTDI libftdi1;

nativeBuildInputs = [
cmake
pkg-config
];

postPatch = ''
find . -type f -name 'build.cmake' -exec \
sed -i 's/DESTINATION inc/DESTINATION include/g' {} \;
'';

passthru.updateScript = nix-update-script { };

meta = {
description = "A library to obtain, parse and analyze data (EEG, EMG, ECG) from biosensors";
homepage = "https://brainflow.org/";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [
pandapip1
ziguana
];
platforms = lib.platforms.all;
};
})
39 changes: 39 additions & 0 deletions pkgs/development/python-modules/brainflow/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
buildPythonPackage,
brainflow,
nptyping,
numpy,
python,
setuptools,
}:

buildPythonPackage {
inherit (brainflow)
pname
version
src
patches
meta
;

pyproject = true;
build-system = [ setuptools ];

dependencies = [
numpy
nptyping
];

buildInputs = [ brainflow ];

postPatch = ''
cd python_package
'';

postInstall = ''
mkdir -p "$out/${python.sitePackages}/brainflow/lib/"
cp -Tr "${brainflow}/lib" "$out/${python.sitePackages}/brainflow/lib/"
'';

pythonImportsCheck = [ "brainflow" ];
}
4 changes: 4 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1773,6 +1773,10 @@ self: super: with self; {

bracex = callPackage ../development/python-modules/bracex { };

brainflow = callPackage ../development/python-modules/brainflow {
inherit (pkgs) brainflow;
};

braintree = callPackage ../development/python-modules/braintree { };

branca = callPackage ../development/python-modules/branca { };
Expand Down

0 comments on commit 3dfa73e

Please sign in to comment.