mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-10-30 16:10:36 +00:00
Fails as follows: https://nixpkgs-update-logs.nixos.org/python3Packages.mlx-bin/2026-10-06.log error: mlx-bin: unsupported Python version or system: 3.14-x86_64-linux Even if we were to fix the update script to work under linux, the bot won't post an update anyway because it only posts for changes that produce at least one linux derivation change.
99 lines
2.6 KiB
Nix
99 lines
2.6 KiB
Nix
{
|
|
buildPythonPackage,
|
|
callPackage,
|
|
fetchFromGitHub,
|
|
fetchPypi,
|
|
lib,
|
|
mlx-metal,
|
|
python,
|
|
stdenv,
|
|
}:
|
|
|
|
let
|
|
wheelSources = import ./wheel-sources.nix;
|
|
inherit (wheelSources) version;
|
|
inherit (python) pythonVersion;
|
|
sourceKey = "${pythonVersion}-${stdenv.hostPlatform.system}";
|
|
|
|
getSrcFromPypi =
|
|
{
|
|
platform,
|
|
dist,
|
|
hash,
|
|
}:
|
|
fetchPypi {
|
|
pname = "mlx";
|
|
inherit
|
|
version
|
|
platform
|
|
dist
|
|
hash
|
|
;
|
|
format = "wheel";
|
|
python = dist;
|
|
abi = dist;
|
|
};
|
|
|
|
srcs = lib.mapAttrs (_: source: getSrcFromPypi source) wheelSources.mlx;
|
|
in
|
|
buildPythonPackage (finalAttrs: {
|
|
pname = "mlx";
|
|
inherit version;
|
|
format = "wheel";
|
|
__structuredAttrs = true;
|
|
|
|
disabled = !(srcs ? ${sourceKey});
|
|
|
|
src = srcs.${sourceKey} or (throw "mlx-bin: unsupported Python version or system: ${sourceKey}");
|
|
|
|
# Upstream pins the Metal runtime to the same release as the Python wheel.
|
|
dependencies =
|
|
assert lib.assertMsg (mlx-metal.version == finalAttrs.version)
|
|
"mlx-bin ${finalAttrs.version} requires mlx-metal ${finalAttrs.version}, but got ${mlx-metal.version}";
|
|
[ mlx-metal ];
|
|
|
|
postInstall = ''
|
|
# Nix installs the wheels separately, but MLX expects their files in the same package directory.
|
|
ln -s ${mlx-metal}/${python.sitePackages}/mlx/lib $out/${python.sitePackages}/mlx/lib
|
|
ln -s ${mlx-metal}/${python.sitePackages}/mlx/include $out/${python.sitePackages}/mlx/include
|
|
ln -s ${mlx-metal}/${python.sitePackages}/mlx/share $out/${python.sitePackages}/mlx/share
|
|
'';
|
|
|
|
pythonImportsCheck = [ "mlx" ];
|
|
|
|
# The bot requires a Linux build, but these wheels only support Darwin.
|
|
# nixpkgs-update: no auto update
|
|
passthru.updateScript = callPackage ./update-wheels.nix { };
|
|
|
|
passthru.srcs = {
|
|
mlx = srcs;
|
|
mlx-metal = mlx-metal.srcs;
|
|
testSource = fetchFromGitHub {
|
|
owner = "ml-explore";
|
|
repo = "mlx";
|
|
tag = "v${finalAttrs.version}";
|
|
hash = wheelSources.testSourceHash;
|
|
};
|
|
};
|
|
|
|
passthru.tests.mlxTest =
|
|
(callPackage ./tests.nix {
|
|
mlx = finalAttrs.finalPackage;
|
|
metalSupport = true;
|
|
src = finalAttrs.passthru.srcs.testSource;
|
|
}).mlxTest;
|
|
|
|
meta = {
|
|
description = "Prebuilt MLX wheel for Apple silicon with Metal runtime";
|
|
homepage = "https://github.com/ml-explore/mlx";
|
|
changelog = "https://github.com/ml-explore/mlx/releases/tag/v${version}";
|
|
license = lib.licenses.mit;
|
|
maintainers = with lib.maintainers; [
|
|
booxter
|
|
kinnrai
|
|
];
|
|
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
|
platforms = [ "aarch64-darwin" ];
|
|
};
|
|
})
|