Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 cffi, 6 dos2unix, 7 fetchPypi, 8 matplotlib, 9 networkx, 10 numpy, 11 pytestCheckHook, 12 pythonOlder, 13 setuptools, 14 setuptools-scm, 15 wheel, 16 gurobi, 17 gurobipy, 18 # Enable support for the commercial Gurobi solver (requires a license) 19 gurobiSupport ? false, 20 # If Gurobi has already been installed outside of the Nix store, specify its 21 # installation directory here 22 gurobiHome ? null, 23}: 24 25buildPythonPackage rec { 26 pname = "mip"; 27 version = "1.15.0"; 28 format = "pyproject"; 29 30 disabled = pythonOlder "3.7"; 31 32 src = fetchPypi { 33 inherit pname version; 34 hash = "sha256-f28Dgc/ixSwbhkAgPaLLVpdLJuI5UN37GnazfZFvGX4="; 35 }; 36 37 nativeCheckInputs = [ 38 matplotlib 39 networkx 40 numpy 41 pytestCheckHook 42 ]; 43 44 nativeBuildInputs = [ 45 dos2unix 46 setuptools 47 setuptools-scm 48 wheel 49 ]; 50 51 propagatedBuildInputs = [ 52 cffi 53 ] ++ lib.optionals gurobiSupport ([ gurobipy ] ++ lib.optional (gurobiHome == null) gurobi); 54 55 # Source files have CRLF terminators, which make patch error out when supplied 56 # with diffs made on *nix machines 57 prePatch = '' 58 find . -type f -exec ${dos2unix}/bin/dos2unix {} \; 59 ''; 60 61 patches = [ 62 # Some tests try to be smart and dynamically construct a path to their test 63 # inputs. Unfortunately, since the test phase is run after installation, 64 # those paths point to the Nix store, which no longer contains the test 65 # data. This patch hardcodes the data path to point to the source directory. 66 ./test-data-path.patch 67 ]; 68 69 postPatch = '' 70 # Allow newer cffi versions to be used 71 substituteInPlace pyproject.toml --replace "cffi==1.15.*" "cffi>=1.15" 72 ''; 73 74 # Make MIP use the Gurobi solver, if configured to do so 75 makeWrapperArgs = lib.optional gurobiSupport "--set GUROBI_HOME ${ 76 if gurobiHome == null then gurobi.outPath else gurobiHome 77 }"; 78 79 # Tests that rely on Gurobi are activated only when Gurobi support is enabled 80 disabledTests = lib.optional (!gurobiSupport) "gurobi"; 81 82 passthru.optional-dependencies = { 83 inherit gurobipy numpy; 84 }; 85 86 meta = with lib; { 87 homepage = "https://python-mip.com/"; 88 description = "Collection of Python tools for the modeling and solution of Mixed-Integer Linear programs (MIPs)"; 89 downloadPage = "https://github.com/coin-or/python-mip/releases"; 90 changelog = "https://github.com/coin-or/python-mip/releases/tag/${version}"; 91 license = licenses.epl20; 92 broken = stdenv.isAarch64; 93 maintainers = with maintainers; [ nessdoor ]; 94 }; 95}