[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
07/07: gnu: tensorflow: Adjust for Python 3.10 compatibility.
From: |
guix-commits |
Subject: |
07/07: gnu: tensorflow: Adjust for Python 3.10 compatibility. |
Date: |
Fri, 21 Apr 2023 07:11:33 -0400 (EDT) |
rekado pushed a commit to branch core-updates
in repository guix.
commit 4065d9dfd592255a4ae61e72f9315ba7fcb9c90b
Author: Ricardo Wurmus <rekado@elephly.net>
AuthorDate: Fri Apr 21 13:02:41 2023 +0200
gnu: tensorflow: Adjust for Python 3.10 compatibility.
* gnu/packages/machine-learning.scm (tensorflow)[arguments]: Replace build
phase 'python3.9-compatibility with 'python3.10-compatibility; patch for
move
from "collections" to "collections.abc"; add well-meaning but potentially
reckless patch to remove overwrite error for __or__ and __ror__ methods;
adjust farmhash sources to build with GCC 11; do not use
distutils.sysconfig.
---
gnu/packages/machine-learning.scm | 43 +++++++++++++++++++++++++++++++++++++--
1 file changed, 41 insertions(+), 2 deletions(-)
diff --git a/gnu/packages/machine-learning.scm
b/gnu/packages/machine-learning.scm
index 90a3e153ce..1a08b3c0a2 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -2176,7 +2176,7 @@ Python.")
;; SOURCE_DATE_EPOCH is respected, which we set to some time in
;; 1980.
(lambda _ (setenv "SOURCE_DATE_EPOCH" "315532800") #t))
- (add-after 'unpack 'python3.9-compatibility
+ (add-after 'unpack 'python3.10-compatibility
(lambda _
;; See
https://github.com/tensorflow/tensorflow/issues/20517#issuecomment-406373913
(substitute* '("tensorflow/python/eager/pywrap_tfe_src.cc"
@@ -2198,6 +2198,33 @@ Python.")
(("(nullptr,)(\\ +/. tp_print)" _ _ tp_print)
(string-append "NULL, " tp_print)))
+ ;; Many collections classes have been moved to collections.abc
+ (substitute* '("tensorflow/python/framework/ops.py"
+ "tensorflow/python/ops/clip_ops.py"
+ "tensorflow/python/ops/data_flow_ops.py"
+ "tensorflow/python/ops/gradients_impl.py"
+ "tensorflow/python/training/input.py"
+
"tensorflow/python/training/checkpointable/data_structures.py"
+ "tensorflow/python/util/nest.py"
+ "tensorflow/python/util/protobuf/compare.py")
+ (("collections.Mapping") "collections.abc.Mapping")
+ (("collections.Sequence") "collections.abc.Sequence"))
+ (substitute* "tensorflow/python/feature_column/feature_column.py"
+ (("collections.Iterator") "collections.abc.Iterator"))
+ (substitute* "tensorflow/python/ops/sparse_ops.py"
+ (("collections.Iterable") "collections.abc.Iterable"))
+ (substitute* "tensorflow/python/keras/callbacks.py"
+ (("from collections import Iterable")
+ "from collections.abc import Iterable"))
+
+ ;; XXX: it is not clear if this is a good idea, but the build
+ ;; system tries to overwrite the __or__ and __ror__ methods of
+ ;; the Tensor class.
+ (substitute* "tensorflow/python/framework/ops.py"
+ (("if not isinstance\\(existing, type\\(object.__lt__\\)\\)" m)
+ (string-append m
+ " and not isinstance(existing,
type(object.__or__))")))
+
;; Fix the build with numpy >= 1.19.
;; Suggested in
https://github.com/tensorflow/tensorflow/issues/41086#issuecomment-656833081
(substitute* "tensorflow/python/lib/core/bfloat16.cc"
@@ -2205,7 +2232,7 @@ Python.")
"void BinaryUFunc(char** args, npy_intp const* dimensions,
npy_intp const* steps,")
(("void CompareUFunc\\(char\\*\\* args, npy_intp\\* dimensions,
npy_intp\\* steps,")
"void CompareUFunc(char** args, npy_intp const* dimensions,
npy_intp const* steps,"))))
- (add-after 'python3.9-compatibility 'chdir
+ (add-after 'python3.10-compatibility 'chdir
(lambda _ (chdir "tensorflow/contrib/cmake")))
(add-after 'chdir 'disable-downloads
(lambda* (#:key inputs #:allow-other-keys)
@@ -2336,6 +2363,12 @@ set(eigen_INCLUDE_DIRS
${CMAKE_CURRENT_BINARY_DIR}/external/eigen_archive "
"nsync"
"re2"))
+ ;; https://github.com/google/farmhash/issues/24
+ (substitute* "../build/farmhash/src/farmhash/src/farmhash.cc"
+ (("using namespace std;") "")
+ (("make_pair") "std::make_pair")
+ (("pair<") "std::pair<"))
+
(rename-file "../build/cub/src/cub/cub-1.8.0/"
"../build/cub/src/cub/cub/")
@@ -2350,6 +2383,12 @@ set(eigen_INCLUDE_DIRS
${CMAKE_CURRENT_BINARY_DIR}/external/eigen_archive "
(mkdir-p "eigen-src")
(copy-recursively (assoc-ref inputs "eigen:src") "eigen-src")
+ ;; distutils.sysconfig is deprecated and prints a deprecation
+ ;; warning that breaks the generated CXX_INCLUDES line.
+ (substitute* "tensorflow/contrib/cmake/tf_python.cmake"
+ (("import distutils.sysconfig;
print\\(distutils.sysconfig.get_python_inc\\(\\)\\)")
+ "import sysconfig; print(sysconfig.get_path('include'))"))
+
(substitute* "tensorflow/contrib/cmake/tf_python.cmake"
;; Take protobuf source files from our source package.
(("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/protobuf/src/protobuf/src/google")
- branch core-updates updated (fe4978d5b5 -> 4065d9dfd5), guix-commits, 2023/04/21
- 04/07: gnu: grpc-1.16.1: Correct input modifications., guix-commits, 2023/04/21
- 06/07: gnu: python-protobuf-3.6: Patch for Python 3.10., guix-commits, 2023/04/21
- 01/07: gnu: Add abseil-cpp-20211102.0., guix-commits, 2023/04/21
- 02/07: gnu: Add grpc-for-python-grpcio., guix-commits, 2023/04/21
- 03/07: gnu: python-grpcio: Rebuild Cythonized source files., guix-commits, 2023/04/21
- 05/07: gnu: python-setuptools-for-tensorflow: Patch for Python 3.10 compatibility., guix-commits, 2023/04/21
- 07/07: gnu: tensorflow: Adjust for Python 3.10 compatibility.,
guix-commits <=