libiio: disable Python for static builds
libiio's Python bindings use ctypes to load the shared library, which obviously can't work with a static build. This has recently started causing eval errors because the package uses stdenv.hostPlatform.extensions.sharedLibrary, which isn't available when building a static library. This patch adds a flag to disable the Python bindings, and automatically disables them for static builds. Note that even with this patch, static libiio doesn't build successfully by default. You have to disable avahi and manually disable libxml2 with custom CMake flags.
This commit is contained in:
parent
f0451844bb
commit
d16b0690f8
|
@ -4,7 +4,7 @@
|
||||||
, flex
|
, flex
|
||||||
, bison
|
, bison
|
||||||
, libxml2
|
, libxml2
|
||||||
, python
|
, pythonSupport ? stdenv.hostPlatform.hasSharedLibraries, python
|
||||||
, libusb1
|
, libusb1
|
||||||
, avahiSupport ? true, avahi
|
, avahiSupport ? true, avahi
|
||||||
, libaio
|
, libaio
|
||||||
|
@ -19,7 +19,8 @@ stdenv.mkDerivation rec {
|
||||||
pname = "libiio";
|
pname = "libiio";
|
||||||
version = "0.24";
|
version = "0.24";
|
||||||
|
|
||||||
outputs = [ "out" "lib" "dev" "python" ];
|
outputs = [ "out" "lib" "dev" ]
|
||||||
|
++ lib.optional pythonSupport "python";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "analogdevicesinc";
|
owner = "analogdevicesinc";
|
||||||
|
@ -37,8 +38,9 @@ stdenv.mkDerivation rec {
|
||||||
flex
|
flex
|
||||||
bison
|
bison
|
||||||
pkg-config
|
pkg-config
|
||||||
|
] ++ lib.optionals pythonSupport ([
|
||||||
python
|
python
|
||||||
] ++ lib.optional python.isPy3k python.pkgs.setuptools;
|
] ++ lib.optional python.isPy3k python.pkgs.setuptools);
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
libxml2
|
libxml2
|
||||||
|
@ -49,25 +51,26 @@ stdenv.mkDerivation rec {
|
||||||
|
|
||||||
cmakeFlags = [
|
cmakeFlags = [
|
||||||
"-DUDEV_RULES_INSTALL_DIR=${placeholder "out"}/lib/udev/rules.d"
|
"-DUDEV_RULES_INSTALL_DIR=${placeholder "out"}/lib/udev/rules.d"
|
||||||
"-DPython_EXECUTABLE=${python.pythonForBuild.interpreter}"
|
|
||||||
"-DPYTHON_BINDINGS=on"
|
|
||||||
# osx framework is disabled,
|
# osx framework is disabled,
|
||||||
# the linux-like directory structure is used for proper output splitting
|
# the linux-like directory structure is used for proper output splitting
|
||||||
"-DOSX_PACKAGE=off"
|
"-DOSX_PACKAGE=off"
|
||||||
"-DOSX_FRAMEWORK=off"
|
"-DOSX_FRAMEWORK=off"
|
||||||
|
] ++ lib.optionals pythonSupport [
|
||||||
|
"-DPython_EXECUTABLE=${python.pythonForBuild.interpreter}"
|
||||||
|
"-DPYTHON_BINDINGS=on"
|
||||||
] ++ lib.optionals (!avahiSupport) [
|
] ++ lib.optionals (!avahiSupport) [
|
||||||
"-DHAVE_DNS_SD=OFF"
|
"-DHAVE_DNS_SD=OFF"
|
||||||
];
|
];
|
||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
# Hardcode path to the shared library into the bindings.
|
|
||||||
sed "s#@libiio@#$lib/lib/libiio${stdenv.hostPlatform.extensions.sharedLibrary}#g" ${./hardcode-library-path.patch} | patch -p1
|
|
||||||
|
|
||||||
substituteInPlace libiio.rules.cmakein \
|
substituteInPlace libiio.rules.cmakein \
|
||||||
--replace /bin/sh ${runtimeShell}
|
--replace /bin/sh ${runtimeShell}
|
||||||
|
'' + lib.optionalString pythonSupport ''
|
||||||
|
# Hardcode path to the shared library into the bindings.
|
||||||
|
sed "s#@libiio@#$lib/lib/libiio${stdenv.hostPlatform.extensions.sharedLibrary}#g" ${./hardcode-library-path.patch} | patch -p1
|
||||||
'';
|
'';
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = lib.optionalString pythonSupport ''
|
||||||
# Move Python bindings into a separate output.
|
# Move Python bindings into a separate output.
|
||||||
moveToOutput ${python.sitePackages} "$python"
|
moveToOutput ${python.sitePackages} "$python"
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -5882,7 +5882,10 @@ self: super: with self; {
|
||||||
inherit (pkgs.config) cudaSupport;
|
inherit (pkgs.config) cudaSupport;
|
||||||
};
|
};
|
||||||
|
|
||||||
libiio = (toPythonModule (pkgs.libiio.override { inherit python; })).python;
|
libiio = (toPythonModule (pkgs.libiio.override {
|
||||||
|
pythonSupport = true;
|
||||||
|
inherit python;
|
||||||
|
})).python;
|
||||||
|
|
||||||
libkeepass = callPackage ../development/python-modules/libkeepass { };
|
libkeepass = callPackage ../development/python-modules/libkeepass { };
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue