Skip to content

Commit 5f4aeb1

Browse files
committed
python: tasks, sch-core-python
1 parent 55784e0 commit 5f4aeb1

6 files changed

Lines changed: 99 additions & 8 deletions

File tree

module.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ in
7373
spacevecalg
7474
rbdyn
7575
sch-core
76+
sch-core-python
7677
tasks
7778
tasks-qld
7879
tvm

overlay.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
eigen-qld = prev.callPackage ./pkgs/eigen-qld { };
5353
eigen-quadprog = prev.callPackage ./pkgs/eigen-quadprog { };
5454
sch-core = prev.callPackage ./pkgs/sch-core { };
55+
sch-core-python = prev.callPackage ./pkgs/sch-core-python { };
5556
#sch-visualization = prev.callPackage ./pkgs/sch-visualization {};
5657
sch-visualization = prev.callPackage ./pkgs/sch-visualization { };
5758
tasks-qld = prev.callPackage ./pkgs/tasks { };

pkgs/sch-core-python/default.nix

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
lib,
3+
stdenv,
4+
cmake,
5+
sch-core,
6+
spacevecalg,
7+
python3Packages,
8+
fetchFromGitHub,
9+
}:
10+
11+
stdenv.mkDerivation rec {
12+
pname = "sch-core-python";
13+
version = "1.0.5";
14+
15+
src = fetchFromGitHub {
16+
owner = "jrl-umi3218";
17+
repo = "sch-core-python";
18+
rev = "9b4a7d8189de30dc49edc7ccb0e1283e85686e62";
19+
hash = "sha256-Ml0fATe61R7tJ5m20Y7hjDwCa/WwIIG3f+qwV1zSz8k=";
20+
};
21+
22+
nativeBuildInputs = [
23+
cmake
24+
python3Packages.cython
25+
python3Packages.python
26+
python3Packages.distutils
27+
python3Packages.pytest
28+
];
29+
propagatedBuildInputs = [
30+
sch-core
31+
spacevecalg
32+
python3Packages.spacevecalg
33+
];
34+
35+
cmakeFlags = [
36+
"-DINSTALL_DOCUMENTATION=OFF"
37+
];
38+
39+
# Override the default CMake install step
40+
installPhase = ''
41+
runHook preInstall
42+
43+
# 1. Define the destination directory inside the Nix store output
44+
# Using python.sitePackages handles the "lib/python3.13/site-packages" string automatically
45+
local targetDir="$out/${python3Packages.python.sitePackages}/sch"
46+
mkdir -p "$targetDir"
47+
48+
ls -lR
49+
50+
# 2. Copy your built files from the build tree to the target store path
51+
# (Adjust 'build/python/Release/eigen/' path if your build folder structure differs slightly)
52+
cp -r python/Release/sch/* "$targetDir"
53+
54+
runHook postInstall
55+
'';
56+
57+
doCheck = false;
58+
59+
meta = with lib; {
60+
description = "sch-core: python bindings for sch-core - effective proximity queries";
61+
homepage = "https://github.com/jrl-umi3218/sch-core-python";
62+
license = licenses.bsd2;
63+
platforms = platforms.all;
64+
};
65+
}

pkgs/tasks/default.nix

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
rbdyn,
66
sch-core,
77
eigen-qld,
8+
python3Packages,
89
with-lssol ? false,
910
eigen-lssol ? null,
1011
}:
@@ -18,25 +19,30 @@ stdenv.mkDerivation rec {
1819
sha256 = "0if144c0jjpxk97fn2qszybdlx8b66qsa1kdkvwzfipvf8fh364q";
1920
};
2021

21-
nativeBuildInputs = [ cmake ];
22+
nativeBuildInputs = [
23+
cmake
24+
python3Packages.distutils
25+
python3Packages.pytest
26+
python3Packages.cython
27+
python3Packages.python
28+
];
2229
propagatedBuildInputs = [
2330
rbdyn
2431
sch-core
2532
eigen-qld
33+
python3Packages.rbdyn
34+
python3Packages.sch-core-python
2635
]
2736
++ lib.optional (with-lssol && eigen-lssol != null) eigen-lssol;
2837

2938
cmakeFlags = [
30-
"-DPYTHON_BINDING=OFF"
3139
"-DINSTALL_DOCUMENTATION=OFF"
3240
];
3341

34-
postPatch = ''
35-
# Remove the include from the main CMakeLists.txt
36-
sed -i '/include(cmake\/cython\/cython.cmake)/d' CMakeLists.txt
37-
38-
# Add the include to the top of the python binding CMakeLists.txt
39-
sed -i '1i include(cmake/cython/cython.cmake)' binding/python/CMakeLists.txt
42+
# XXX: Without this fixupPhase fails due to RPATHS references to /build/
43+
preFixup = ''
44+
patchelf --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" $out/${python3Packages.python.sitePackages}/tasks/tasks.so
45+
patchelf --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" $out/${python3Packages.python.sitePackages}/tasks/qp/qp.so
4046
'';
4147

4248
doCheck = true;

py-pkgs/sch-core-python.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
toPythonModule,
3+
pkgs,
4+
}:
5+
toPythonModule (
6+
pkgs.sch-core-python.override {
7+
inherit (pkgs) python3Packages;
8+
}
9+
)

py-pkgs/tasks.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
toPythonModule,
3+
pkgs,
4+
}:
5+
toPythonModule (
6+
pkgs.tasks.override {
7+
inherit (pkgs) python3Packages;
8+
}
9+
)

0 commit comments

Comments
 (0)