2020-04-24 23:36:52 +00:00
|
|
|
{ lib
|
2023-02-02 18:25:31 +00:00
|
|
|
, stdenv
|
2020-04-24 23:36:52 +00:00
|
|
|
, fetchFromGitHub
|
2023-02-02 18:25:31 +00:00
|
|
|
, bazel_6
|
2020-04-24 23:36:52 +00:00
|
|
|
, buildBazelPackage
|
|
|
|
, buildPythonPackage
|
2023-02-02 18:25:31 +00:00
|
|
|
, cctools
|
2020-04-24 23:36:52 +00:00
|
|
|
, python
|
|
|
|
, setuptools
|
|
|
|
, wheel
|
|
|
|
, absl-py
|
|
|
|
, tensorflow
|
|
|
|
, six
|
|
|
|
, numpy
|
2022-02-10 20:34:41 +00:00
|
|
|
, dm-tree
|
|
|
|
, keras
|
2020-04-24 23:36:52 +00:00
|
|
|
, decorator
|
|
|
|
, cloudpickle
|
|
|
|
, gast
|
|
|
|
, hypothesis
|
|
|
|
, scipy
|
2022-02-10 20:34:41 +00:00
|
|
|
, pandas
|
|
|
|
, mpmath
|
2020-04-24 23:36:52 +00:00
|
|
|
, matplotlib
|
|
|
|
, mock
|
|
|
|
, pytest
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2023-02-02 18:25:31 +00:00
|
|
|
version = "0.19.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "tensorflow_probability";
|
|
|
|
|
|
|
|
# first build all binaries and generate setup.py using bazel
|
|
|
|
bazel-wheel = buildBazelPackage {
|
|
|
|
name = "${pname}-${version}-py2.py3-none-any.whl";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "tensorflow";
|
|
|
|
repo = "probability";
|
2022-02-10 20:34:41 +00:00
|
|
|
rev = "v" + version;
|
2023-02-02 18:25:31 +00:00
|
|
|
hash = "sha256-ZkQ20Qt/RF/leVP6Kc38tGgPz+C6lEuHvoL+s97oksE=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
nativeBuildInputs = [
|
|
|
|
# needed to create the output wheel in installPhase
|
|
|
|
python
|
|
|
|
setuptools
|
|
|
|
wheel
|
|
|
|
absl-py
|
|
|
|
tensorflow
|
|
|
|
];
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
bazel = bazel_6;
|
|
|
|
|
2023-04-12 12:48:02 +00:00
|
|
|
bazelTargets = [ ":pip_pkg" ];
|
2023-02-02 18:25:31 +00:00
|
|
|
LIBTOOL = lib.optionalString stdenv.isDarwin "${cctools}/bin/libtool";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
fetchAttrs = {
|
2023-05-24 13:37:59 +00:00
|
|
|
sha256 = "sha256-tMiZsX5OyVw6VVImn4nWwEFdBw+TKKbE7oACibQC0oA=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
buildAttrs = {
|
|
|
|
preBuild = ''
|
|
|
|
patchShebangs .
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
# work around timestamp issues
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/270#issuecomment-467583872
|
|
|
|
export SOURCE_DATE_EPOCH=315532800
|
|
|
|
|
|
|
|
# First build, then move. Otherwise pip_pkg would create the dir $out
|
|
|
|
# and then put the wheel in that directory. However we want $out to
|
|
|
|
# point directly to the wheel file.
|
|
|
|
./bazel-bin/pip_pkg . --release
|
|
|
|
mv *.whl "$out"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in buildPythonPackage {
|
|
|
|
inherit version pname;
|
|
|
|
format = "wheel";
|
|
|
|
|
|
|
|
src = bazel-wheel;
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
tensorflow
|
|
|
|
six
|
|
|
|
numpy
|
|
|
|
decorator
|
|
|
|
cloudpickle
|
|
|
|
gast
|
2022-02-10 20:34:41 +00:00
|
|
|
dm-tree
|
|
|
|
keras
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# Listed here:
|
2022-02-10 20:34:41 +00:00
|
|
|
# https://github.com/tensorflow/probability/blob/f3777158691787d3658b5e80883fe1a933d48989/testing/dependency_install_lib.sh#L83
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2020-04-24 23:36:52 +00:00
|
|
|
hypothesis
|
|
|
|
pytest
|
|
|
|
scipy
|
2022-02-10 20:34:41 +00:00
|
|
|
pandas
|
|
|
|
mpmath
|
2020-04-24 23:36:52 +00:00
|
|
|
matplotlib
|
|
|
|
mock
|
|
|
|
];
|
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
# Ideally, we run unit tests with pytest, but in checkPhase, only the Bazel-build wheel is available.
|
|
|
|
# But it seems not guaranteed that running the tests with pytest will even work, see
|
|
|
|
# https://github.com/tensorflow/probability/blob/c2a10877feb2c4c06a4dc58281e69c37a11315b9/CONTRIBUTING.md?plain=1#L69
|
|
|
|
# Ideally, tests would be run using Bazel. For now, lets's do a...
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# sanity check
|
2022-02-10 20:34:41 +00:00
|
|
|
pythonImportsCheck = [ "tensorflow_probability" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Library for probabilistic reasoning and statistical analysis";
|
|
|
|
homepage = "https://www.tensorflow.org/probability/";
|
|
|
|
license = licenses.asl20;
|
2021-01-15 22:18:51 +00:00
|
|
|
maintainers = with maintainers; []; # This package is maintainerless.
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|