2024-12-11 20:46:20 -05:00
|
|
|
{ stdenv, lib, python3Packages, rosDistro, rosVersion }:
|
2019-09-05 22:43:33 -04:00
|
|
|
{ buildType ? "catkin"
|
2020-08-24 18:28:26 -04:00
|
|
|
# Too difficult to fix all the problems with the tests in each package
|
|
|
|
, doCheck ? false
|
2021-03-12 00:31:00 -05:00
|
|
|
# nixpkgs requires that either dontWrapQtApps is set or wrapQtAppsHook is added
|
|
|
|
# to nativeBuildInputs if a package depends on Qt5. This is difficult to achieve
|
|
|
|
# with auto-generated packages, so we just always disable wrapping except for
|
|
|
|
# packages that are overridden in distro-overlay.nix. This means some Qt5
|
|
|
|
# applications are broken, but allows all libraries that depend on Qt5 to build
|
|
|
|
# correctly.
|
|
|
|
, dontWrapQtApps ? true
|
2023-07-01 19:00:11 +10:00
|
|
|
, nativeBuildInputs ? [ ]
|
2020-08-24 18:28:26 -04:00
|
|
|
, CXXFLAGS ? ""
|
2023-07-30 11:28:13 +10:00
|
|
|
, postFixup ? ""
|
|
|
|
, passthru ? { }
|
2024-07-19 10:37:56 -04:00
|
|
|
, separateDebugInfo ? true
|
2019-03-21 00:23:14 -04:00
|
|
|
, ...
|
2019-09-05 22:43:33 -04:00
|
|
|
}@args:
|
|
|
|
|
2024-12-11 20:46:20 -05:00
|
|
|
(if buildType == "ament_python" then python3Packages.buildPythonPackage
|
2019-09-05 22:43:33 -04:00
|
|
|
else stdenv.mkDerivation) (args // {
|
2024-07-19 10:37:56 -04:00
|
|
|
inherit doCheck dontWrapQtApps separateDebugInfo;
|
2019-09-28 15:46:34 -04:00
|
|
|
|
2020-04-23 13:48:03 -04:00
|
|
|
# Disable warnings that cause "Log limit exceeded" errors on Hydra in lots of
|
|
|
|
# packages that use Eigen
|
2020-08-24 18:28:26 -04:00
|
|
|
CXXFLAGS = CXXFLAGS + "-Wno-deprecated-declarations -Wno-deprecated-copy";
|
2020-04-23 13:48:03 -04:00
|
|
|
|
2019-04-16 15:02:56 -04:00
|
|
|
passthru = passthru // {
|
|
|
|
rosPackage = true;
|
2022-11-11 14:30:39 -05:00
|
|
|
inherit rosDistro rosVersion;
|
2019-04-16 15:02:56 -04:00
|
|
|
};
|
2020-03-04 17:18:10 -05:00
|
|
|
} // lib.optionalAttrs (buildType == "ament_python") {
|
2019-09-28 15:46:34 -04:00
|
|
|
dontUseCmakeConfigure = true;
|
2023-07-01 19:00:11 +10:00
|
|
|
|
2023-09-07 18:53:50 -04:00
|
|
|
# Modeled after colcon.
|
2023-09-02 19:36:19 +10:00
|
|
|
# As of 0.12.1, colcon uses the legacy distutils install.py script, so we do
|
|
|
|
# the same. Using modern techniques, such as "pip install" with setuptools,
|
2023-09-07 18:53:50 -04:00
|
|
|
# causes issues due to differences in setup.cfg interpretation. In particular,
|
|
|
|
# it ignores the "install-scripts" directive, which is commonly used in ROS
|
|
|
|
# to install binaries to "$out/lib/<package name>".
|
2023-09-02 19:31:21 +10:00
|
|
|
# https://github.com/colcon/colcon-core/blob/0.12.1/colcon_core/task/python/build.py#L84
|
2023-07-01 19:00:11 +10:00
|
|
|
format = "other";
|
|
|
|
|
2024-12-11 20:46:20 -05:00
|
|
|
nativeBuildInputs = nativeBuildInputs ++ [ python3Packages.setuptools ];
|
2023-07-01 19:00:11 +10:00
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
python setup.py build
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
2024-12-11 20:46:20 -05:00
|
|
|
mkdir -p "$out/${python3Packages.python.sitePackages}"
|
|
|
|
export PYTHONPATH="$out/${python3Packages.python.sitePackages}:$PYTHONPATH"
|
2023-07-01 19:00:11 +10:00
|
|
|
python setup.py install --prefix="$out" --single-version-externally-managed --record /dev/null
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
2023-07-30 11:28:13 +10:00
|
|
|
|
|
|
|
postFixup = ''
|
|
|
|
${postFixup}
|
2024-12-11 20:46:20 -05:00
|
|
|
find "$out/lib" -mindepth 1 -maxdepth 1 -type d ! -name '${python3Packages.python.libPrefix}' -print0 | while read -d "" libpkgdir; do
|
2023-09-02 09:00:41 +00:00
|
|
|
wrapPythonProgramsIn "$libpkgdir" "$out $pythonPath"
|
2023-07-30 11:28:13 +10:00
|
|
|
done
|
|
|
|
'';
|
2020-03-04 17:18:10 -05:00
|
|
|
})
|