mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-21 04:49:01 +02:00
librealsense,python3Packages.pyrealsense2: refactor to add cudaSupport and python bindings
This commit is contained in:
parent
d22cd376e5
commit
ff8e1825ab
|
@ -1,4 +1,9 @@
|
|||
{ stdenv, fetchFromGitHub, cmake, libusb1, ninja, pkgconfig }:
|
||||
{ stdenv, config, lib, fetchFromGitHub, cmake, libusb1, ninja, pkgconfig, gcc
|
||||
, cudaSupport ? config.cudaSupport or false, cudatoolkit
|
||||
, enablePython ? false, pythonPackages ? null }:
|
||||
|
||||
assert cudaSupport -> cudatoolkit != null;
|
||||
assert enablePython -> pythonPackages != null;
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "librealsense";
|
||||
|
@ -15,6 +20,12 @@ stdenv.mkDerivation rec {
|
|||
|
||||
buildInputs = [
|
||||
libusb1
|
||||
gcc.cc.lib
|
||||
] ++ lib.optional cudaSupport cudatoolkit
|
||||
++ lib.optional enablePython pythonPackages.python;
|
||||
|
||||
patches = lib.optionals enablePython [
|
||||
./py_sitepackage_dir.patch
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
|
@ -23,7 +34,22 @@ stdenv.mkDerivation rec {
|
|||
pkgconfig
|
||||
];
|
||||
|
||||
cmakeFlags = [ "-DBUILD_EXAMPLES=false" ];
|
||||
cmakeFlags = [
|
||||
"-DBUILD_EXAMPLES=ON"
|
||||
"-DBUILD_GRAPHICAL_EXAMPLES=OFF"
|
||||
"-DBUILD_GLSL_EXTENSIONS=OFF"
|
||||
] ++ lib.optionals enablePython [
|
||||
"-DBUILD_PYTHON_BINDINGS:bool=true"
|
||||
"-DXXNIX_PYTHON_SITEPACKAGES=${placeholder "out"}/${pythonPackages.python.sitePackages}"
|
||||
] ++ lib.optional cudaSupport "-DBUILD_WITH_CUDA:bool=true";
|
||||
|
||||
# ensure python package contains its __init__.py. for some reason the install
|
||||
# script does not do this, and it's questionable if intel knows it should be
|
||||
# done
|
||||
# ( https://github.com/IntelRealSense/meta-intel-realsense/issues/20 )
|
||||
postInstall = lib.optionalString enablePython ''
|
||||
cp ../wrappers/python/pyrealsense2/__init__.py $out/${pythonPackages.python.sitePackages}/pyrealsense2
|
||||
'';
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
description = "A cross-platform library for Intel® RealSense™ depth cameras (D400 series and the SR300)";
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
--- a/wrappers/python/CMakeLists.txt
|
||||
+++ b/wrappers/python/CMakeLists.txt
|
||||
@@ -10,11 +10,11 @@
|
||||
if (CMAKE_VERSION VERSION_LESS 3.12)
|
||||
find_package(PythonInterp REQUIRED)
|
||||
find_package(PythonLibs REQUIRED)
|
||||
- set(PYTHON_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/pyrealsense2" CACHE PATH "Installation directory for Python bindings")
|
||||
+ set(PYTHON_INSTALL_DIR "${XXNIX_PYTHON_SITEPACKAGES}/pyrealsense2" CACHE PATH "Installation directory for Python bindings")
|
||||
set(CMAKECONFIG_PY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/pyrealsense2")
|
||||
else()
|
||||
find_package(Python REQUIRED COMPONENTS Interpreter Development)
|
||||
- set(PYTHON_INSTALL_DIR "${Python_SITEARCH}/pyrealsense2" CACHE PATH "Installation directory for Python bindings")
|
||||
+ set(PYTHON_INSTALL_DIR "${XXNIX_PYTHON_SITEPACKAGES}/pyrealsense2" CACHE PATH "Installation directory for Python bindings")
|
||||
set(CMAKECONFIG_PY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/pyrealsense2")
|
||||
endif()
|
|
@ -17710,6 +17710,14 @@ in
|
|||
|
||||
librealsense = callPackage ../development/libraries/librealsense { };
|
||||
|
||||
librealsenseWithCuda = callPackage ../development/libraries/librealsense {
|
||||
cudaSupport = true;
|
||||
};
|
||||
|
||||
librealsenseWithoutCuda = callPackage ../development/libraries/librealsense {
|
||||
cudaSupport = false;
|
||||
};
|
||||
|
||||
libsass = callPackage ../development/libraries/libsass { };
|
||||
|
||||
libsepol = callPackage ../os-specific/linux/libsepol { };
|
||||
|
|
|
@ -2618,6 +2618,21 @@ in {
|
|||
|
||||
pyhs100 = callPackage ../development/python-modules/pyhs100 { };
|
||||
|
||||
pyrealsense2 = toPythonModule (pkgs.librealsense.override {
|
||||
enablePython = true;
|
||||
pythonPackages = self;
|
||||
});
|
||||
|
||||
pyrealsense2WithCuda = toPythonModule (pkgs.librealsenseWithCuda.override {
|
||||
enablePython = true;
|
||||
pythonPackages = self;
|
||||
});
|
||||
|
||||
pyrealsense2WithoutCuda = toPythonModule (pkgs.librealsenseWithoutCuda.override {
|
||||
enablePython = true;
|
||||
pythonPackages = self;
|
||||
});
|
||||
|
||||
pytest = if isPy3k then self.pytest_5 else self.pytest_4;
|
||||
|
||||
pytest_5 = callPackage ../development/python-modules/pytest {
|
||||
|
|
Loading…
Reference in a new issue