Skip to content

Commit

Permalink
Fix cross build for various python packages (#369631)
Browse files Browse the repository at this point in the history
  • Loading branch information
mweinelt authored Jan 2, 2025
2 parents 042d318 + ff9865b commit 1660c7f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
4 changes: 2 additions & 2 deletions pkgs/development/python-modules/bcrypt/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
rustPlatform,
rustc,
setuptools,
setuptools-rust,
setuptoolsRustBuildHook,
fetchPypi,
pythonOlder,
pytestCheckHook,
Expand Down Expand Up @@ -41,7 +41,7 @@ buildPythonPackage rec {

nativeBuildInputs = [
setuptools
setuptools-rust
setuptoolsRustBuildHook
rustPlatform.cargoSetupHook
cargo
rustc
Expand Down
14 changes: 14 additions & 0 deletions pkgs/development/python-modules/contourpy/default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{
lib,
buildPackages,
buildPythonPackage,
fetchFromGitHub,
python,
pythonOlder,
python3,

# build
meson,
meson-python,
ninja,
nukeReferences,
pybind11,

# propagates
Expand All @@ -22,7 +25,9 @@
# tests
matplotlib,
pillow,
pytest-xdist,
pytestCheckHook,
wurlitzer,
}:

let
Expand All @@ -49,6 +54,7 @@ let
nativeBuildInputs = [
meson
ninja
nukeReferences
pybind11
];

Expand All @@ -70,6 +76,8 @@ let
matplotlib
pillow
pytestCheckHook
pytest-xdist
wurlitzer
];

passthru.tests = {
Expand All @@ -80,6 +88,12 @@ let

pythonImportsCheck = [ "contourpy" ];

# remove references to buildPackages.python3, which is not allowed for cross builds.
preFixup = ''
nuke-refs -e "${buildPackages.python3}" \
$out/${python3.sitePackages}/contourpy/util/{_build_config.py,__pycache__/_build_config.*}
'';

meta = with lib; {
changelog = "https://github.com/contourpy/contourpy/releases/tag/v${version}";
description = "Python library for calculating contours in 2D quadrilateral grids";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
parameterized,
pip-tools,
pkg-config,
pkgconfig,
prompt-toolkit,
protobuf,
psutil,
Expand Down Expand Up @@ -105,6 +106,7 @@ stdenv.mkDerivation rec {
zap-chip
# gdbus-codegen
glib
pkgconfig
python3
# dependencies of build scripts
click
Expand Down Expand Up @@ -193,6 +195,7 @@ stdenv.mkDerivation rec {
packaging
parameterized
pip-tools
pkgconfig
prompt-toolkit
protobuf
psutil
Expand Down Expand Up @@ -223,26 +226,18 @@ stdenv.mkDerivation rec {
wheel
yapf
];
depListToAttrs =
list:
builtins.listToAttrs (
map (dep: {
name = dep.name;
value = dep;
}) (lib.filter (x: x != null) list)
);
saturateDependencies =
deps:
let
before = deps;
new = lib.mergeAttrsList (
map (dep: depListToAttrs (dep.propagatedBuildInputs or [ ])) (lib.attrValues before)
);
after = before // new;
in
if lib.attrNames before != lib.attrNames after then saturateDependencies after else before;
saturateDependencyList = list: lib.attrValues (saturateDependencies (depListToAttrs list));
saturatedDependencyList = lib.filter (drv: drv ? dist) (saturateDependencyList dependencies);
filterNull = list: lib.filter (dep: dep != null) list;
toItem = dep: {
inherit dep;
key = dep.name;
};
saturatedDependencies = lib.genericClosure {
startSet = map toItem (filterNull dependencies);
operator = item: map toItem (filterNull ((item.dep).propagatedBuildInputs or [ ]));
};
saturatedDependencyList = lib.filter (dep: dep ? dist && dep != null) (
map (item: item.dep) saturatedDependencies
);
in
lib.concatMapStringsSep " " (dep: "file://${dep.dist}") saturatedDependencyList;

Expand Down

0 comments on commit 1660c7f

Please sign in to comment.