Merge pull request #261150 from Wulfsta/libfive

libfive: add python bindings
This commit is contained in:
Peder Bergebakken Sundt
2023-11-11 01:33:11 +02:00
committed by GitHub
3 changed files with 36 additions and 4 deletions
+29 -3
View File
@@ -10,6 +10,7 @@
, libpng
, boost
, guile
, python
, qtbase
, darwin
}:
@@ -25,8 +26,8 @@ stdenv.mkDerivation {
hash = "sha256-OITy3fJx+Z6856V3D/KpSQRJztvOdJdqUv1c65wNgCc=";
};
nativeBuildInputs = [ wrapQtAppsHook cmake ninja pkg-config ];
buildInputs = [ eigen zlib libpng boost guile qtbase ]
nativeBuildInputs = [ wrapQtAppsHook cmake ninja pkg-config python.pkgs.pythonImportsCheckHook ];
buildInputs = [ eigen zlib libpng boost guile python qtbase ]
++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk_11_0.frameworks.Cocoa ];
preConfigure = ''
@@ -42,6 +43,14 @@ stdenv.mkDerivation {
--replace "LIBFIVE_STDLIB_DIR=$<TARGET_FILE_DIR:libfive-stdlib>" \
"LIBFIVE_STDLIB_DIR=$out/lib"
substituteInPlace libfive/bind/python/CMakeLists.txt \
--replace ' ''${PYTHON_SITE_PACKAGES_DIR}' \
" $out/${python.sitePackages}" \
substituteInPlace libfive/bind/python/libfive/ffi.py \
--replace "os.path.join('libfive', folder)" \
"os.path.join('$out/${python.sitePackages}/libfive', folder)" \
export XDG_CACHE_HOME=$(mktemp -d)/.cache
'';
@@ -63,12 +72,29 @@ stdenv.mkDerivation {
'' + ''
# Link "Studio" binary to "libfive-studio" to be more obvious:
ln -s "$out/bin/Studio" "$out/bin/libfive-studio"
# Create links since libfive looks for the library in a specific path.
mkdir -p "$out/${python.sitePackages}/libfive/src"
ln -s "$out"/lib/libfive.* "$out/${python.sitePackages}/libfive/src/"
mkdir -p "$out/${python.sitePackages}/libfive/stdlib"
ln -s "$out"/lib/libfive-stdlib.* "$out/${python.sitePackages}/libfive/stdlib/"
# Create links so Studio can find the bindings.
mkdir -p "$out/libfive/bind"
ln -s "$out/${python.sitePackages}" "$out/libfive/bind/python"
'';
pythonImportsCheck = [
"libfive"
"libfive.runner"
"libfive.shape"
"libfive.stdlib"
];
meta = with lib; {
description = "Infrastructure for solid modeling with F-Reps in C, C++, and Guile";
homepage = "https://libfive.com/";
maintainers = with maintainers; [ hodapp kovirobi ];
maintainers = with maintainers; [ hodapp kovirobi wulfsta ];
license = with licenses; [ mpl20 gpl2Plus ];
platforms = with platforms; all;
};
+3 -1
View File
@@ -22873,7 +22873,9 @@ with pkgs;
libfabric = callPackage ../development/libraries/libfabric { };
libfive = qt6Packages.callPackage ../development/libraries/libfive { };
libfive = qt6Packages.callPackage ../development/libraries/libfive {
python = python3;
};
libfixposix = callPackage ../development/libraries/libfixposix { };
+4
View File
@@ -6150,6 +6150,10 @@ self: super: with self; {
pythonSupport = true;
});
libfive = toPythonModule (pkgs.libfive.override {
inherit python;
});
libgpiod = callPackage ../development/python-modules/libgpiod {
inherit (pkgs) libgpiod;
};