summaryrefslogtreecommitdiff
path: root/gnu/packages
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2025-03-19 15:08:24 +0100
committerAndreas Enge <andreas@enge.fr>2025-04-16 11:46:18 +0200
commit71f392ca8d83df2bd4e415402b216bb274378dec (patch)
tree15c139bfaef38011b22da2ea1a72f3e4ffd19933 /gnu/packages
parenta330b7acff992ee80bce800f3248d3c6fe641a67 (diff)
gnu: tensorflow: Fix build.
* gnu/packages/machine-learning.scm (tensorflow)[arguments]: Rename phase 'python3.10-compatibility to 'python3.11-compatibility; update it to deal with removals in Python 3.11; add phase 'numpy-compatibility. Change-Id: I6c08b7b03cb01223fe9d62545f6687e9440b2011
Diffstat (limited to 'gnu/packages')
-rw-r--r--gnu/packages/machine-learning.scm35
1 files changed, 33 insertions, 2 deletions
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index dc1bb3cdf6..1d6799aea7 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -3362,8 +3362,14 @@ Python.")
;; SOURCE_DATE_EPOCH is respected, which we set to some time in
;; 1980.
(lambda _ (setenv "SOURCE_DATE_EPOCH" "315532800")))
- (add-after 'unpack 'python3.10-compatibility
+ (add-after 'unpack 'python3.11-compatibility
(lambda _
+ ;; Py_TYPE was changed to an inline static function in Python
+ ;; 3.11, so it cannot be used on the left-hand side.
+ (substitute* "tensorflow/python/lib/core/bfloat16.cc"
+ (("Py_TYPE\\(&NPyBfloat16_Descr\\) = &PyArrayDescr_Type;")
+ "Py_SET_TYPE(&NPyBfloat16_Descr, &PyArrayDescr_Type);"))
+
;; See https://github.com/tensorflow/tensorflow/issues/20517#issuecomment-406373913
(substitute* '("tensorflow/python/eager/pywrap_tfe_src.cc"
"tensorflow/python/lib/core/ndarray_tensor.cc"
@@ -3413,6 +3419,16 @@ Python.")
(string-append m
" and not isinstance(existing, type(object.__or__))")))
+ ;; ArgSpec has been replaced with FullArgSpec.
+ (substitute* "tensorflow/python/util/tf_inspect.py"
+ (("ArgSpec = _inspect.ArgSpec") "\
+ArgSpec = namedtuple('ArgSpec', [ 'args', 'varargs', 'keywords', 'defaults' ])
+def makeargspec(s):
+ return ArgSpec(args=s.args, varargs=s.varargs, keywords=s.varkw, defaults=s.defaults)
+")
+ (("_inspect.getargspec\\((.*)\\)" m target)
+ (string-append "makeargspec(_inspect.getfullargspec(" target "))")))
+
;; 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"
@@ -3433,7 +3449,22 @@ Python.")
(substitute* '("tensorflow/python/framework/fast_tensor_util.pyx"
"tensorflow/python/estimator/canned/linear_testing_utils.py")
(("np.asscalar") "np.ndarray.item"))))
- (add-after 'python3.10-compatibility 'chdir
+ (add-after 'python3.11-compatibility 'numpy-compatibility
+ (lambda _
+ (substitute* (cons* "tensorflow/compiler/xla/python/xla_client.py"
+ "tensorflow/contrib/layers/python/ops/sparse_ops_test.py"
+ (find-files "tensorflow/python/" "\\.py$"))
+ (("np.object") "object"))
+ (substitute* (append
+ '("tensorflow/compiler/tests/unary_ops_test.py"
+ "tensorflow/compiler/xla/python/xla_client.py"
+ "tensorflow/compiler/xla/python/xla_client_test.py")
+ (find-files "tensorflow/python/" "\\.py$")
+ (find-files "tensorflow/contrib/" "\\.py$"))
+ (("np.bool,") "bool,")
+ (("np.bool\\)") "bool)")
+ (("np.bool:") "bool:"))))
+ (add-after 'numpy-compatibility 'chdir
(lambda _ (chdir "tensorflow/contrib/cmake")))
(add-after 'chdir 'disable-downloads
(lambda* (#:key inputs #:allow-other-keys)