Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cross build for various python packages #369631

Merged
merged 4 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
DavHau marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
lib,
buildPackages,
buildPythonPackage,
fetchFromGitHub,
pythonOlder,
python3,

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

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

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

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

passthru.tests = {
Expand All @@ -73,6 +81,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
Loading