nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5 pythonAtLeast,
6 numpy,
7}:
8let
9 pname = "paddle-bfloat";
10 version = "0.1.7";
11in
12buildPythonPackage {
13 inherit pname version;
14 format = "setuptools";
15
16 src = fetchPypi {
17 pname = "paddle_bfloat";
18 inherit version;
19 hash = "sha256-mrjQCtLsXOvqeHHMjuMx65FvMfZ2+wTh1ao9ZJE+9xw=";
20 };
21
22 postPatch = ''
23 sed '1i#include <memory>' -i bfloat16.cc # gcc12
24 # replace deprecated function for python3.11
25 substituteInPlace bfloat16.cc \
26 --replace "Py_TYPE(&NPyBfloat16_Descr) = &PyArrayDescr_Type" "Py_SET_TYPE(&NPyBfloat16_Descr, &PyArrayDescr_Type)"
27 '';
28
29 disabled = pythonAtLeast "3.12";
30
31 propagatedBuildInputs = [ numpy ];
32
33 pythonImportsCheck = [ "paddle_bfloat" ];
34
35 # upstream has no tests
36 doCheck = false;
37
38 meta = {
39 description = "Paddle numpy bfloat16 package";
40 homepage = "https://pypi.org/project/paddle-bfloat";
41 license = lib.licenses.asl20;
42 maintainers = with lib.maintainers; [ happysalada ];
43 };
44}