mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-10-30 16:10:36 +00:00
buildPythonPackage and buildPythonApplication now default to
__structuredAttrs = true, so makeWrapperArgs reaches wrapPythonPrograms
as a real bash array. Elements are no longer word-split or
shell-expanded, which breaks three common patterns:
- several arguments packed into one string, such as
"--prefix PATH : ${...}", which makeWrapper rejects with
"makeWrapper doesn't understand the arg ..."
- "\${gappsWrapperArgs[@]}" or "\${qtWrapperArgs[@]}" as list
elements, which also fail the build
- build-time shell variables ($out, $PYTHONPATH, $GI_TYPELIB_PATH, ...)
and shell quoting inside elements. These build fine but end up as
literal strings in the wrapper, e.g. beets got
export GI_TYPELIB_PATH='$GI_TYPELIB_PATH', and gam's --run lines
became single-quoted commands that abort the wrapper.
Split packed strings into one element per argument, append the
gapps/qt wrapper args in preFixup, use placeholder "out" instead of
$out, move other build-time variables into preFixup, and drop the
now-literal quotes.
Also fix the makeWrapperArgs example in the python propagated-inputs
warning.
Assisted-by: Claude Code (Claude Opus 5.5)
96 lines
2.5 KiB
Nix
96 lines
2.5 KiB
Nix
{
|
|
lib,
|
|
stdenv,
|
|
buildPythonPackage,
|
|
cffi,
|
|
dos2unix,
|
|
fetchPypi,
|
|
matplotlib,
|
|
networkx,
|
|
numpy,
|
|
pytestCheckHook,
|
|
setuptools,
|
|
setuptools-scm,
|
|
wheel,
|
|
gurobi,
|
|
gurobipy,
|
|
# Enable support for the commercial Gurobi solver (requires a license)
|
|
gurobiSupport ? false,
|
|
# If Gurobi has already been installed outside of the Nix store, specify its
|
|
# installation directory here
|
|
gurobiHome ? null,
|
|
}:
|
|
|
|
buildPythonPackage rec {
|
|
pname = "mip";
|
|
version = "1.17.6";
|
|
pyproject = true;
|
|
|
|
src = fetchPypi {
|
|
inherit pname version;
|
|
hash = "sha256-nagHS4C9PveIUT1aIU74MpFtgqpmSH2hGknH2p+J0nA=";
|
|
};
|
|
|
|
nativeCheckInputs = [
|
|
matplotlib
|
|
networkx
|
|
numpy
|
|
pytestCheckHook
|
|
];
|
|
|
|
nativeBuildInputs = [
|
|
dos2unix
|
|
setuptools
|
|
setuptools-scm
|
|
wheel
|
|
];
|
|
|
|
propagatedBuildInputs = [
|
|
cffi
|
|
]
|
|
++ lib.optionals gurobiSupport ([ gurobipy ] ++ lib.optional (gurobiHome == null) gurobi);
|
|
|
|
# Source files have CRLF terminators, which make patch error out when supplied
|
|
# with diffs made on *nix machines
|
|
prePatch = ''
|
|
find . -type f -exec ${dos2unix}/bin/dos2unix {} \;
|
|
'';
|
|
|
|
patches = [
|
|
# Some tests try to be smart and dynamically construct a path to their test
|
|
# inputs. Unfortunately, since the test phase is run after installation,
|
|
# those paths point to the Nix store, which no longer contains the test
|
|
# data. This patch hardcodes the data path to point to the source directory.
|
|
./test-data-path.patch
|
|
];
|
|
|
|
postPatch = ''
|
|
# Allow newer cffi versions to be used
|
|
substituteInPlace pyproject.toml --replace "cffi==1.15.*" "cffi>=1.15"
|
|
'';
|
|
|
|
# Make MIP use the Gurobi solver, if configured to do so
|
|
makeWrapperArgs = lib.optionals gurobiSupport [
|
|
"--set"
|
|
"GUROBI_HOME"
|
|
(if gurobiHome == null then gurobi.outPath else gurobiHome)
|
|
];
|
|
|
|
# Tests that rely on Gurobi are activated only when Gurobi support is enabled
|
|
disabledTests = lib.optional (!gurobiSupport) "gurobi";
|
|
|
|
optional-dependencies = {
|
|
inherit gurobipy numpy;
|
|
};
|
|
|
|
meta = {
|
|
homepage = "https://python-mip.com/";
|
|
description = "Collection of Python tools for the modeling and solution of Mixed-Integer Linear programs (MIPs)";
|
|
downloadPage = "https://github.com/coin-or/python-mip/releases";
|
|
changelog = "https://github.com/coin-or/python-mip/releases/tag/${version}";
|
|
license = lib.licenses.epl20;
|
|
broken = stdenv.hostPlatform.isAarch64;
|
|
maintainers = with lib.maintainers; [ nessdoor ];
|
|
};
|
|
}
|