diff options
| author | Ricardo Wurmus <rekado@elephly.net> | 2023-10-26 18:36:42 +0200 |
|---|---|---|
| committer | Ricardo Wurmus <rekado@elephly.net> | 2023-10-30 11:37:16 +0100 |
| commit | c3b4cc447821b657303b24acb337262ab8bb6e05 (patch) | |
| tree | 4475728eba13b5dbf05c677ac2c72247fdcb7a38 | |
| parent | d757b16de48632c0b4df0c99bef9bbd1bc4234f0 (diff) | |
python: Add python-tensorflow-probability.
* guix-science/packages/python.scm (python-tensorflow-probability): New variable.
| -rw-r--r-- | guix-science/packages/python.scm | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/guix-science/packages/python.scm b/guix-science/packages/python.scm index f4ff6f4..192e364 100644 --- a/guix-science/packages/python.scm +++ b/guix-science/packages/python.scm | |||
| @@ -1754,3 +1754,137 @@ subclassing API with an imperative style for advanced research.") | |||
| 1754 | (list eigen-for-python-ml-dtypes | 1754 | (list eigen-for-python-ml-dtypes |
| 1755 | patchelf | 1755 | patchelf |
| 1756 | `(,tensorflow "python"))))) | 1756 | `(,tensorflow "python"))))) |
| 1757 | |||
| 1758 | (define-public python-tensorflow-probability | ||
| 1759 | (package | ||
| 1760 | (name "python-tensorflow-probability") | ||
| 1761 | (version "0.22.1") | ||
| 1762 | (source (origin | ||
| 1763 | (method git-fetch) | ||
| 1764 | (uri (git-reference | ||
| 1765 | (url "https://github.com/tensorflow/probability") | ||
| 1766 | (commit (string-append "v" version)))) | ||
| 1767 | (file-name (git-file-name name version)) | ||
| 1768 | (sha256 | ||
| 1769 | (base32 | ||
| 1770 | "04qva7cwplh0vj9k15nl7lr1m0jfa49j2cl6z2iaz8rnsm2kfz3k")))) | ||
| 1771 | (build-system pyproject-build-system) | ||
| 1772 | (arguments | ||
| 1773 | (list | ||
| 1774 | #:modules | ||
| 1775 | '((guix build pyproject-build-system) | ||
| 1776 | (guix build utils) | ||
| 1777 | (srfi srfi-1) | ||
| 1778 | (ice-9 string-fun)) | ||
| 1779 | #:tests? #false ;there are none | ||
| 1780 | #:phases | ||
| 1781 | #~(modify-phases %standard-phases | ||
| 1782 | (add-after 'unpack 'prepare-bazel-inputs | ||
| 1783 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 1784 | (define bazel-out | ||
| 1785 | (string-append (getenv "NIX_BUILD_TOP") "/output")) | ||
| 1786 | (mkdir-p bazel-out) | ||
| 1787 | (with-directory-excursion bazel-out | ||
| 1788 | (invoke "tar" "xf" #$(bazel-vendored-inputs | ||
| 1789 | #:source (package-source this-package) | ||
| 1790 | #:name "tensorflow-probability" | ||
| 1791 | #:version version | ||
| 1792 | #:inputs | ||
| 1793 | (append (standard-packages) | ||
| 1794 | (package-inputs this-package) | ||
| 1795 | (package-propagated-inputs this-package) | ||
| 1796 | (package-native-inputs this-package)) | ||
| 1797 | #:search-paths | ||
| 1798 | (map search-path-specification->sexp | ||
| 1799 | (package-transitive-native-search-paths | ||
| 1800 | this-package)) | ||
| 1801 | #:bazel-targets | ||
| 1802 | (list "//tensorflow_probability") | ||
| 1803 | #:bazel-arguments | ||
| 1804 | '(list) | ||
| 1805 | #:hash | ||
| 1806 | "104m99n0ah9nxa296m3ryrfyqm40ay8ck4nsggfdmci935jigvwa"))) | ||
| 1807 | |||
| 1808 | ;; Rewrite dangling links to current build directory | ||
| 1809 | (for-each (lambda (file) | ||
| 1810 | (let ((new-target | ||
| 1811 | (string-replace-substring | ||
| 1812 | (readlink file) | ||
| 1813 | "GUIX_BUILD_TOP" (getenv "NIX_BUILD_TOP")))) | ||
| 1814 | (delete-file file) | ||
| 1815 | (symlink new-target file))) | ||
| 1816 | (find-files bazel-out | ||
| 1817 | (lambda (file-name stat) | ||
| 1818 | (and (eq? (stat:type stat) 'symlink) | ||
| 1819 | (string-contains (readlink file-name) | ||
| 1820 | "GUIX_BUILD_TOP"))) | ||
| 1821 | #:stat lstat)) | ||
| 1822 | (setenv "HOME" (getenv "NIX_BUILD_TOP")))) | ||
| 1823 | (replace 'build | ||
| 1824 | (lambda _ | ||
| 1825 | (define %build-directory (getenv "NIX_BUILD_TOP")) | ||
| 1826 | (define %bazel-out | ||
| 1827 | (string-append %build-directory "/output")) | ||
| 1828 | (define %bazel-user-root | ||
| 1829 | (string-append %build-directory "/tmp")) | ||
| 1830 | (setenv "BAZEL_USE_CPP_ONLY_TOOLCHAIN" "1") | ||
| 1831 | (setenv "USER" "homeless-shelter") | ||
| 1832 | (apply invoke "bazel" | ||
| 1833 | "--batch" | ||
| 1834 | (string-append "--output_base=" %bazel-out) | ||
| 1835 | (string-append "--output_user_root=" %bazel-user-root) | ||
| 1836 | "build" | ||
| 1837 | "--nofetch" | ||
| 1838 | "--distinct_host_configuration=false" | ||
| 1839 | "--curses=no" | ||
| 1840 | "--verbose_failures" | ||
| 1841 | "--subcommands" | ||
| 1842 | "--strategy=Genrule=local" | ||
| 1843 | "--toolchain_resolution_debug=\".*\"" | ||
| 1844 | "--local_ram_resources=HOST_RAM*.5" | ||
| 1845 | "--local_cpu_resources=HOST_CPUS*.75" | ||
| 1846 | "--action_env=PATH" | ||
| 1847 | "--action_env=GUIX_PYTHONPATH" | ||
| 1848 | "--action_env=PYTHONPATH" | ||
| 1849 | "--action_env=GUIX_LOCPATH" | ||
| 1850 | "--host_action_env=PATH" | ||
| 1851 | "--host_action_env=GUIX_PYTHONPATH" | ||
| 1852 | "--host_action_env=PYTHONPATH" | ||
| 1853 | "--host_action_env=GUIX_LOCPATH" | ||
| 1854 | (list "//tensorflow_probability/python" | ||
| 1855 | "//tensorflow_probability/python/internal/backend/jax:rewrite" | ||
| 1856 | "//tensorflow_probability/substrates" | ||
| 1857 | "//tensorflow_probability/substrates:jax" | ||
| 1858 | "//tensorflow_probability/substrates:numpy" | ||
| 1859 | ":pip_pkg")) | ||
| 1860 | (substitute* "bazel-bin/pip_pkg" | ||
| 1861 | (("\\$\\(date --utc \\+%Y%m%d\\)") "redacted")) | ||
| 1862 | (invoke "bazel-bin/pip_pkg" "dist" "--release")))))) | ||
| 1863 | (propagated-inputs | ||
| 1864 | (list python-absl-py | ||
| 1865 | python-cloudpickle | ||
| 1866 | python-decorator | ||
| 1867 | python-dm-tree | ||
| 1868 | python-jax | ||
| 1869 | python-jaxlib | ||
| 1870 | python-gast | ||
| 1871 | python-numpy | ||
| 1872 | python-six | ||
| 1873 | python-typing-extensions | ||
| 1874 | python-tensorflow | ||
| 1875 | ;;python-tensorflow-datasets ;TODO | ||
| 1876 | )) | ||
| 1877 | (native-inputs | ||
| 1878 | (list bazel-6 | ||
| 1879 | `(,openjdk11 "jdk") ;for bazel | ||
| 1880 | which)) | ||
| 1881 | (home-page "https://github.com/pyro-ppl/numpyro") | ||
| 1882 | (synopsis "Probabilistic reasoning and statistical analysis in TensorFlow") | ||
| 1883 | (description "TensorFlow Probability is a library for | ||
| 1884 | probabilistic reasoning and statistical analysis in TensorFlow. As | ||
| 1885 | part of the TensorFlow ecosystem, TensorFlow Probability provides | ||
| 1886 | integration of probabilistic methods with deep networks, | ||
| 1887 | gradient-based inference via automatic differentiation, and | ||
| 1888 | scalability to large datasets and models via hardware | ||
| 1889 | acceleration (e.g., GPUs) and distributed computation.") | ||
| 1890 | (license license:asl2.0))) | ||
