Gentoo Archives: gentoo-commits

From: Jason Zaman <perfinion@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sci-libs/tensorflow/
Date: Sun, 01 Aug 2021 13:19:49
Message-Id: 1627823952.82a04476b0dd7ea1628495350b035908e72c1d94.perfinion@gentoo
1 commit: 82a04476b0dd7ea1628495350b035908e72c1d94
2 Author: Jason Zaman <perfinion <AT> gentoo <DOT> org>
3 AuthorDate: Sun Aug 1 13:13:54 2021 +0000
4 Commit: Jason Zaman <perfinion <AT> gentoo <DOT> org>
5 CommitDate: Sun Aug 1 13:19:12 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=82a04476
7
8 sci-libs/tensorflow: Add python3_9 and build against proto-3.16
9
10 Protobuf 3.16 changed the status API in
11 https://github.com/protocolbuffers/protobuf/commit/59ea5c8f19de47dc15cbce2e2e97d9de01d50fb9
12 so must be patched. All deps now support python3_9 as well so enable
13 support in TF
14
15 Closes: https://bugs.gentoo.org/800824
16 Closes: https://bugs.gentoo.org/802732
17 Package-Manager: Portage-3.0.20, Repoman-3.0.2
18 Signed-off-by: Jason Zaman <perfinion <AT> gentoo.org>
19
20 sci-libs/tensorflow/Manifest | 1 +
21 sci-libs/tensorflow/tensorflow-2.5.0-r1.ebuild | 410 +++++++++++++++++++++++++
22 2 files changed, 411 insertions(+)
23
24 diff --git a/sci-libs/tensorflow/Manifest b/sci-libs/tensorflow/Manifest
25 index 1c0d69e84ec..263bf06e475 100644
26 --- a/sci-libs/tensorflow/Manifest
27 +++ b/sci-libs/tensorflow/Manifest
28 @@ -40,5 +40,6 @@ DIST tensorflow-1.15.0-python-license.rst.txt 45132 BLAKE2B 8a8ace4b64fd9eda1932
29 DIST tensorflow-2.4.0.tar.gz 53257138 BLAKE2B 21973f67a7a4cb91baccbd3a4d9c8bce4c7f488ed44e834122b0fa0fc47b22d48276ecd9b580fa839c32a3dacac73bc010f91a27e5568df4dd9986b14b7eeb4f SHA512 4860c148fd931c4dc7c558128e545e2b6384e590a3fbc266a5bfe842a8307f23f1f7e0103bda3a383e7c77edad2bb76dec02da8be400a40956072df19c5d4dbd
30 DIST tensorflow-2.5.0.tar.gz 55999506 BLAKE2B 0f1f29ed9ff6e5fd3fc0c98419bca636f48085810f934290885b3469c45817b2ce17e9dbd3d93d70b09ec7975088edd0973f147449f527a8f2e23b388e2592ce SHA512 637c63b1bed1c0eb7bb018f1ff7f29f7f0d78e75dac384df4ecb5dfb92bbcb28209e3d3d2204145abddf88e3247d8c31bbb4cea032a73b7122b2ef3eb0d2b947
31 DIST tensorflow-patches-2.4.0.tar.bz2 1842 BLAKE2B ac35a02e3494b0cb6cfcc9212557d5b5480aea41b09d74b918471e688b489bafd2dbc609320abde609a461db1c8d0043fce4053ad9a223bc93fb883176417199 SHA512 39b3ebe710eb3bb5c4575dbbad66ae1bd2a81b803fb9007709154320eaf31cbac213ea5dc6c2e674e685db1cea5ff524f723f3893dfe5f31af32be7756882b28
32 +DIST tensorflow-patches-2.5.0-r1.tar.bz2 5180 BLAKE2B aafebb5cc4616ad93982e0fd8299f91c22063b96841b920a98a4cb54bcdc0cad51011f943ca62055239a0c21ed69d1f5b985710dcf0c28346b7ba12114583842 SHA512 38acd53136f3f1e061b71624cc5a1cefbdcb1d897b7728bc93462e8f52e998c3d72453ca9c94fa53dd28279cae5c591b7cbe9f61684784ff94c451a641524f31
33 DIST tensorflow-patches-2.5.0.tar.bz2 4834 BLAKE2B 3e7331bb290db529e32fe6ba0a9fa2f5729fc510b925bc74532eb1bb15f8ecdaa2655cb16229a696e9716d006057badf26392e8fca2695146dc9a491050cb7c2 SHA512 699d16296c4f04e4de540b2eb91122a245cc02233a2b76021646a57d3228688b44a691308b4f1e9d9dc16929e6d2d692540cdeb3f42d2cad2c101d3008c22a33
34 DIST tensorflow-toolchains-v1.1.10.tar.gz 137512 BLAKE2B 774b22a599070564c0f77ed0da79f6a96359b196dd3007370be885b796c236b9a29c01597507a3049f82cf489824c8016740b778cacb2b8cd859500f9ecb1887 SHA512 1daf4684f5b364a89b3cc475cf2d13d0d0622fc14d2b32d7ad8518932538e716782d755cfcedc98d129a3986bc7c38bfc7854c8ad596891e397510b75ae2f93e
35
36 diff --git a/sci-libs/tensorflow/tensorflow-2.5.0-r1.ebuild b/sci-libs/tensorflow/tensorflow-2.5.0-r1.ebuild
37 new file mode 100644
38 index 00000000000..1a9cf3d0793
39 --- /dev/null
40 +++ b/sci-libs/tensorflow/tensorflow-2.5.0-r1.ebuild
41 @@ -0,0 +1,410 @@
42 +# Copyright 1999-2021 Gentoo Authors
43 +# Distributed under the terms of the GNU General Public License v2
44 +
45 +EAPI=7
46 +
47 +DISTUTILS_OPTIONAL=1
48 +PYTHON_COMPAT=( python3_{7,8,9} )
49 +DISTUTILS_USE_SETUPTOOLS=rdepend
50 +MY_PV=${PV/_rc/-rc}
51 +MY_P=${PN}-${MY_PV}
52 +
53 +inherit bazel check-reqs cuda distutils-r1 flag-o-matic prefix toolchain-funcs
54 +
55 +DESCRIPTION="Computation framework using data flow graphs for scalable machine learning"
56 +HOMEPAGE="https://www.tensorflow.org/"
57 +
58 +LICENSE="Apache-2.0"
59 +SLOT="0"
60 +KEYWORDS="~amd64"
61 +IUSE="cuda mpi +python xla"
62 +CPU_USE_FLAGS_X86="sse sse2 sse3 sse4_1 sse4_2 avx avx2 fma3 fma4"
63 +for i in $CPU_USE_FLAGS_X86; do
64 + IUSE+=" cpu_flags_x86_${i}"
65 +done
66 +
67 +# distfiles that bazel uses for the workspace, will be copied to basel-distdir
68 +bazel_external_uris="
69 + https://github.com/abseil/abseil-cpp/archive/6f9d96a1f41439ac172ee2ef7ccd8edf0e5d068c.tar.gz -> abseil-cpp-6f9d96a1f41439ac172ee2ef7ccd8edf0e5d068c.tar.gz
70 + https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz
71 + https://github.com/bazelbuild/bazel-toolchains/archive/92dd8a7a518a2fb7ba992d47c8b38299fe0be825.tar.gz -> bazel-toolchains-92dd8a7a518a2fb7ba992d47c8b38299fe0be825.tar.gz
72 + https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip -> bazelbuild-rules_android-v0.1.1.zip
73 + https://github.com/bazelbuild/rules_cc/archive/01d4a48911d5e7591ecb1c06d3b8af47fe872371.zip -> bazelbuild-rules_cc-01d4a48911d5e7591ecb1c06d3b8af47fe872371.zip
74 + https://github.com/bazelbuild/rules_closure/archive/308b05b2419edb5c8ee0471b67a40403df940149.tar.gz -> bazelbuild-rules_closure-308b05b2419edb5c8ee0471b67a40403df940149.tar.gz
75 + https://github.com/bazelbuild/rules_docker/releases/download/v0.10.0/rules_docker-v0.10.0.tar.gz -> bazelbuild-rules_docker-v0.10.0.tar.gz
76 + https://github.com/bazelbuild/rules_java/archive/7cf3cefd652008d0a64a419c34c13bdca6c8f178.zip -> bazelbuild-rules_java-7cf3cefd652008d0a64a419c34c13bdca6c8f178.zip
77 + https://github.com/bazelbuild/rules_proto/archive/97d8af4dc474595af3900dd85cb3a29ad28cc313.tar.gz -> bazelbuild-rules_proto-97d8af4dc474595af3900dd85cb3a29ad28cc313.tar.gz
78 + https://github.com/bazelbuild/rules_python/releases/download/0.0.1/rules_python-0.0.1.tar.gz -> bazelbuild-rules_python-0.0.1.tar.gz
79 + https://github.com/bazelbuild/rules_swift/archive/3eeeb53cebda55b349d64c9fc144e18c5f7c0eb8.tar.gz -> bazelbuild-rules_swift-3eeeb53cebda55b349d64c9fc144e18c5f7c0eb8.tar.gz
80 + https://github.com/dmlc/dlpack/archive/3efc489b55385936531a06ff83425b719387ec63.tar.gz -> dlpack-3efc489b55385936531a06ff83425b719387ec63.tar.gz
81 + https://github.com/google/farmhash/archive/816a4ae622e964763ca0862d9dbd19324a1eaf45.tar.gz -> farmhash-816a4ae622e964763ca0862d9dbd19324a1eaf45.tar.gz
82 + https://github.com/google/gemmlowp/archive/fda83bdc38b118cc6b56753bd540caa49e570745.zip -> gemmlowp-fda83bdc38b118cc6b56753bd540caa49e570745.zip
83 + https://github.com/google/highwayhash/archive/fd3d9af80465e4383162e4a7c5e2f406e82dd968.tar.gz -> highwayhash-fd3d9af80465e4383162e4a7c5e2f406e82dd968.tar.gz
84 + https://github.com/google/re2/archive/506cfa4bffd060c06ec338ce50ea3468daa6c814.tar.gz -> re2-506cfa4bffd060c06ec338ce50ea3468daa6c814.tar.gz
85 + https://github.com/google/ruy/archive/54774a7a2cf85963777289193629d4bd42de4a59.zip -> ruy-54774a7a2cf85963777289193629d4bd42de4a59.zip
86 + https://github.com/joe-kuo/sobol_data/archive/835a7d7b1ee3bc83e575e302a985c66ec4b65249.tar.gz -> sobol_data-835a7d7b1ee3bc83e575e302a985c66ec4b65249.tar.gz
87 + https://github.com/llvm/llvm-project/archive/1f6a57c1a0fad922e04a2b1f414b092d4b0cd8b0.tar.gz -> llvm-1f6a57c1a0fad922e04a2b1f414b092d4b0cd8b0.tar.gz
88 + https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/openmp-10.0.1.src.tar.xz -> llvmorg-10.0.1-openmp-10.0.1.src.tar.xz
89 + https://github.com/mborgerding/kissfft/archive/36dbc057604f00aacfc0288ddad57e3b21cfc1b8.tar.gz -> kissfft-36dbc057604f00aacfc0288ddad57e3b21cfc1b8.tar.gz
90 + https://github.com/oneapi-src/oneDNN/archive/v2.2.tar.gz -> oneDNN-v2.2.tar.gz
91 + https://github.com/petewarden/OouraFFT/archive/v1.0.tar.gz -> OouraFFT-v1.0.tar.gz
92 + https://github.com/pytorch/cpuinfo/archive/5916273f79a21551890fd3d56fc5375a78d1598d.zip -> pytorch-cpuinfo-5916273f79a21551890fd3d56fc5375a78d1598d.zip
93 + https://github.com/pytorch/cpuinfo/archive/d5e37adf1406cf899d7d9ec1d317c47506ccb970.tar.gz -> pytorch-cpuinfo-d5e37adf1406cf899d7d9ec1d317c47506ccb970.tar.gz
94 + https://github.com/tensorflow/toolchains/archive/v1.1.10.tar.gz -> tensorflow-toolchains-v1.1.10.tar.gz
95 + https://gitlab.com/libeigen/eigen/-/archive/f612df273689a19d25b45ca4f8269463207c4fee/eigen-f612df273689a19d25b45ca4f8269463207c4fee.tar.gz
96 + cuda? (
97 + https://github.com/NVIDIA/cudnn-frontend/archive/360d6e7164dfb7c802493fd1c0464f0d815b852a.zip -> cudnn-frontend-360d6e7164dfb7c802493fd1c0464f0d815b852a.zip
98 + https://github.com/NVlabs/cub/archive/1.9.9.zip -> cub-1.9.9.zip
99 + https://github.com/nvidia/nccl/archive/v2.8.3-1.tar.gz -> nvidia-nccl-v2.8.3-1.tar.gz
100 + )
101 + python? (
102 + https://github.com/intel/ARM_NEON_2_x86_SSE/archive/1200fe90bb174a6224a525ee60148671a786a71f.tar.gz -> ARM_NEON_2_x86_SSE-1200fe90bb174a6224a525ee60148671a786a71f.tar.gz
103 + https://storage.googleapis.com/mirror.tensorflow.org/docs.python.org/2.7/_sources/license.rst.txt -> tensorflow-1.15.0-python-license.rst.txt
104 + https://pypi.python.org/packages/bc/cc/3cdb0a02e7e96f6c70bd971bc8a90b8463fda83e264fa9c5c1c98ceabd81/backports.weakref-1.0rc1.tar.gz
105 + )"
106 +
107 +SRC_URI="https://github.com/${PN}/${PN}/archive/v${MY_PV}.tar.gz -> ${P}.tar.gz
108 + https://dev.gentoo.org/~perfinion/patches/tensorflow-patches-${PVR}.tar.bz2
109 + ${bazel_external_uris}"
110 +
111 +RDEPEND="
112 + app-arch/snappy
113 + dev-db/lmdb
114 + dev-db/sqlite
115 + dev-libs/double-conversion
116 + dev-libs/icu:=
117 + >=dev-libs/jsoncpp-1.9.2
118 + dev-libs/libpcre
119 + dev-libs/nsync
120 + dev-libs/openssl:0=
121 + >=dev-libs/protobuf-3.13.0:=
122 + >=dev-libs/re2-0.2019.06.01:=
123 + media-libs/giflib
124 + media-libs/libjpeg-turbo
125 + media-libs/libpng:0
126 + >=net-libs/grpc-1.28:=
127 + net-misc/curl
128 + sys-libs/zlib
129 + >=sys-apps/hwloc-2
130 + cuda? (
131 + || (
132 + ( =dev-util/nvidia-cuda-toolkit-11.1*[profiler] =dev-libs/cudnn-8* )
133 + ( =dev-util/nvidia-cuda-toolkit-11.2*[profiler] =dev-libs/cudnn-8* )
134 + )
135 + )
136 + mpi? ( virtual/mpi )
137 + python? (
138 + ${PYTHON_DEPS}
139 + >=dev-libs/flatbuffers-1.12.0:=
140 + dev-python/absl-py[${PYTHON_USEDEP}]
141 + >=dev-python/astor-0.7.1[${PYTHON_USEDEP}]
142 + dev-python/astunparse[${PYTHON_USEDEP}]
143 + dev-python/dill[${PYTHON_USEDEP}]
144 + dev-python/flatbuffers[${PYTHON_USEDEP}]
145 + >=dev-python/gast-0.3.3[${PYTHON_USEDEP}]
146 + dev-python/h5py[${PYTHON_USEDEP}]
147 + >=dev-python/numpy-1.19[${PYTHON_USEDEP}]
148 + >=dev-python/google-pasta-0.1.8[${PYTHON_USEDEP}]
149 + >=dev-python/opt-einsum-3.3.0[${PYTHON_USEDEP}]
150 + >=dev-python/protobuf-python-3.13.0[${PYTHON_USEDEP}]
151 + dev-python/pybind11[${PYTHON_USEDEP}]
152 + dev-python/six[${PYTHON_USEDEP}]
153 + dev-python/tblib[${PYTHON_USEDEP}]
154 + dev-python/termcolor[${PYTHON_USEDEP}]
155 + dev-python/typing-extensions[${PYTHON_USEDEP}]
156 + >=dev-python/grpcio-1.28[${PYTHON_USEDEP}]
157 + >=dev-python/wrapt-1.11.1[${PYTHON_USEDEP}]
158 + >=net-libs/google-cloud-cpp-0.10.0
159 + >=sci-libs/keras-applications-1.0.8[${PYTHON_USEDEP}]
160 + >=sci-libs/keras-preprocessing-1.1.2[${PYTHON_USEDEP}]
161 + >=sci-visualization/tensorboard-2.5.0[${PYTHON_USEDEP}]
162 + )"
163 +DEPEND="${RDEPEND}
164 + python? (
165 + dev-python/mock
166 + dev-python/setuptools
167 + )"
168 +PDEPEND="python? (
169 + >=sci-libs/tensorflow-estimator-2.5.0[${PYTHON_USEDEP}]
170 + )"
171 +BDEPEND="
172 + app-arch/unzip
173 + >=dev-libs/protobuf-3.8.0
174 + dev-java/java-config
175 + >=dev-util/bazel-3.7.2
176 + cuda? (
177 + >=dev-util/nvidia-cuda-toolkit-9.1[profiler]
178 + )
179 + !python? ( dev-lang/python )
180 + python? (
181 + dev-python/cython
182 + dev-python/mock
183 + >=dev-python/grpcio-tools-1.28
184 + )"
185 +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
186 +
187 +S="${WORKDIR}/${MY_P}"
188 +
189 +DOCS=( AUTHORS CONTRIBUTING.md ISSUE_TEMPLATE.md README.md RELEASE.md )
190 +CHECKREQS_MEMORY="5G"
191 +CHECKREQS_DISK_BUILD="10G"
192 +
193 +get-cpu-flags() {
194 + local i f=()
195 + # Keep this list in sync with tensorflow/core/platform/cpu_feature_guard.cc.
196 + for i in sse sse2 sse3 sse4_1 sse4_2 avx avx2 fma4; do
197 + use cpu_flags_x86_${i} && f+=( -m${i/_/.} )
198 + done
199 + use cpu_flags_x86_fma3 && f+=( -mfma )
200 + echo "${f[*]}"
201 +}
202 +
203 +pkg_setup() {
204 + ewarn "TensorFlow 2.0 is a major release that contains some incompatibilities"
205 + ewarn "with TensorFlow 1.x. For more information about migrating to TF2.0 see:"
206 + ewarn "https://www.tensorflow.org/guide/migrate"
207 +
208 + local num_pythons_enabled
209 + num_pythons_enabled=0
210 + count_impls() {
211 + num_pythons_enabled=$((${num_pythons_enabled} + 1))
212 + }
213 + use python && python_foreach_impl count_impls
214 +
215 + # 10G to build C/C++ libs, 5G per python impl
216 + CHECKREQS_DISK_BUILD="$((10 + 6 * ${num_pythons_enabled}))G"
217 + check-reqs_pkg_setup
218 +}
219 +
220 +src_unpack() {
221 + # Only unpack the main distfile
222 + unpack "${P}.tar.gz"
223 + unpack tensorflow-patches-${PVR}.tar.bz2
224 + bazel_load_distfiles "${bazel_external_uris}"
225 +}
226 +
227 +src_prepare() {
228 + export JAVA_HOME=$(java-config --jre-home) # so keepwork works
229 +
230 + append-flags $(get-cpu-flags)
231 + bazel_setup_bazelrc
232 +
233 + eapply "${WORKDIR}"/patches/*.patch
234 +
235 + # Relax version checks in setup.py
236 + sed -i "/^ '/s/==/>=/g" tensorflow/tools/pip_package/setup.py || die
237 + sed -i "/config_googleapis/d" tensorflow/workspace0.bzl || die
238 +
239 + # Prefixify hard-coded command locations
240 + hprefixify -w /host_compiler_prefix/ third_party/gpus/cuda_configure.bzl
241 +
242 + default
243 + use python && python_copy_sources
244 +
245 + use cuda && cuda_add_sandbox
246 +}
247 +
248 +src_configure() {
249 + export JAVA_HOME=$(java-config --jre-home) # so keepwork works
250 + export KERAS_HOME="${T}/.keras" # otherwise sandbox violation writing ~/.keras
251 +
252 + do_configure() {
253 + export CC_OPT_FLAGS=" "
254 + export TF_ENABLE_XLA=$(usex xla 1 0)
255 + export TF_NEED_OPENCL_SYCL=0
256 + export TF_NEED_OPENCL=0
257 + export TF_NEED_COMPUTECPP=0
258 + export TF_NEED_ROCM=0
259 + export TF_NEED_MPI=$(usex mpi 1 0)
260 + export TF_SET_ANDROID_WORKSPACE=0
261 +
262 + if use python; then
263 + export PYTHON_BIN_PATH="${PYTHON}"
264 + export PYTHON_LIB_PATH="$(python_get_sitedir)"
265 + else
266 + export PYTHON_BIN_PATH="$(which python)"
267 + export PYTHON_LIB_PATH="$(python -c 'from distutils.sysconfig import *; print(get_python_lib())')"
268 + fi
269 +
270 + export TF_NEED_CUDA=$(usex cuda 1 0)
271 + export TF_DOWNLOAD_CLANG=0
272 + export TF_CUDA_CLANG=0
273 + export TF_NEED_TENSORRT=0
274 + if use cuda; then
275 + export TF_CUDA_PATHS="${EPREFIX}/opt/cuda"
276 + export GCC_HOST_COMPILER_PATH="$(cuda_gccdir)/$(tc-getCC)"
277 + export TF_CUDA_VERSION="$(cuda_toolkit_version)"
278 + export TF_CUDNN_VERSION="$(cuda_cudnn_version)"
279 + einfo "Setting CUDA version: $TF_CUDA_VERSION"
280 + einfo "Setting CUDNN version: $TF_CUDNN_VERSION"
281 +
282 + if [[ $(cuda-config -s) != *$(gcc-version)* ]]; then
283 + ewarn "TensorFlow is being built with Nvidia CUDA support. Your default compiler"
284 + ewarn "version is not supported by the currently installed CUDA. TensorFlow will"
285 + ewarn "instead be compiled using: ${GCC_HOST_COMPILER_PATH}."
286 + ewarn "If the build fails with linker errors try rebuilding the relevant"
287 + ewarn "dependencies using the same compiler version."
288 + fi
289 +
290 + if [[ -z "$TF_CUDA_COMPUTE_CAPABILITIES" ]]; then
291 + ewarn "WARNING: TensorFlow is being built with its default CUDA compute capabilities: 3.5 and 7.0."
292 + ewarn "These may not be optimal for your GPU."
293 + ewarn ""
294 + ewarn "To configure TensorFlow with the CUDA compute capability that is optimal for your GPU,"
295 + ewarn "set TF_CUDA_COMPUTE_CAPABILITIES in your make.conf, and re-emerge tensorflow."
296 + ewarn "For example, to use CUDA capability 7.5 & 3.5, add: TF_CUDA_COMPUTE_CAPABILITIES=7.5,3.5"
297 + ewarn ""
298 + ewarn "You can look up your GPU's CUDA compute capability at https://developer.nvidia.com/cuda-gpus"
299 + ewarn "or by running /opt/cuda/extras/demo_suite/deviceQuery | grep 'CUDA Capability'"
300 + fi
301 + fi
302 +
303 + # com_googlesource_code_re2 weird branch using absl, doesnt work with released re2
304 + #com_github_googleapis_googleapis
305 + local SYSLIBS=(
306 + absl_py
307 + astor_archive
308 + astunparse_archive
309 + boringssl
310 + com_github_googlecloudplatform_google_cloud_cpp
311 + com_github_grpc_grpc
312 + com_google_protobuf
313 + curl
314 + cython
315 + dill_archive
316 + double_conversion
317 + enum34_archive
318 + flatbuffers
319 + functools32_archive
320 + gast_archive
321 + gif
322 + hwloc
323 + icu
324 + jsoncpp_git
325 + libjpeg_turbo
326 + lmdb
327 + nasm
328 + nsync
329 + opt_einsum_archive
330 + org_sqlite
331 + pasta
332 + pcre
333 + png
334 + pybind11
335 + six_archive
336 + snappy
337 + tblib_archive
338 + termcolor_archive
339 + typing_extensions_archive
340 + wrapt
341 + zlib
342 + )
343 +
344 + export TF_SYSTEM_LIBS="${SYSLIBS[@]}"
345 + export TF_IGNORE_MAX_BAZEL_VERSION=1
346 +
347 + # This is not autoconf
348 + ./configure || die
349 +
350 + echo 'build --config=noaws --config=nohdfs' >> .bazelrc || die
351 + echo 'build --define tensorflow_mkldnn_contraction_kernel=0' >> .bazelrc || die
352 + echo "build --action_env=KERAS_HOME=\"${T}/.keras\"" >> .bazelrc || die
353 + echo "build --host_action_env=KERAS_HOME=\"${T}/.keras\"" >> .bazelrc || die
354 +
355 + for cflag in $($(tc-getPKG_CONFIG) jsoncpp --cflags)
356 + do
357 + echo "build --copt=\"${cflag}\"" >> .bazelrc || die
358 + echo "build --host_copt=\"${cflag}\"" >> .bazelrc || die
359 + done
360 + }
361 + if use python; then
362 + python_foreach_impl run_in_build_dir do_configure
363 + else
364 + do_configure
365 + fi
366 +}
367 +
368 +src_compile() {
369 + export JAVA_HOME=$(java-config --jre-home) # so keepwork works
370 + export KERAS_HOME="${T}/.keras" # otherwise sandbox violation writing ~/.keras
371 +
372 + if use python; then
373 + python_setup
374 + BUILD_DIR="${S}-${EPYTHON/./_}"
375 + cd "${BUILD_DIR}"
376 + fi
377 +
378 + # fail early if any deps are missing
379 + ebazel build -k --nobuild \
380 + //tensorflow:libtensorflow_framework.so \
381 + //tensorflow:libtensorflow.so \
382 + //tensorflow:libtensorflow_cc.so \
383 + $(usex python '//tensorflow/tools/pip_package:build_pip_package' '')
384 +
385 + ebazel build \
386 + //tensorflow:libtensorflow_framework.so \
387 + //tensorflow:libtensorflow.so
388 + ebazel build //tensorflow:libtensorflow_cc.so
389 +
390 + do_compile() {
391 + ebazel build //tensorflow/tools/pip_package:build_pip_package
392 + }
393 + BUILD_DIR="${S}"
394 + cd "${BUILD_DIR}"
395 + use python && python_foreach_impl run_in_build_dir do_compile
396 + ebazel shutdown
397 +}
398 +
399 +src_install() {
400 + local i j
401 + export JAVA_HOME=$(java-config --jre-home) # so keepwork works
402 + export KERAS_HOME="${T}/.keras" # otherwise sandbox violation writing ~/.keras
403 +
404 + do_install() {
405 + einfo "Installing ${EPYTHON} files"
406 + local srcdir="${T}/src-${MULTIBUILD_VARIANT}"
407 + mkdir -p "${srcdir}" || die
408 + bazel-bin/tensorflow/tools/pip_package/build_pip_package --src "${srcdir}" || die
409 + cd "${srcdir}" || die
410 + esetup.py install
411 +
412 + # libtensorflow_framework.so is in /usr/lib already
413 + rm -f "${D}/$(python_get_sitedir)"/${PN}/lib${PN}_framework.so* || die
414 + rm -f "${D}/$(python_get_sitedir)"/${PN}_core/lib${PN}_framework.so* || die
415 + python_optimize
416 + }
417 +
418 + if use python; then
419 + python_foreach_impl run_in_build_dir do_install
420 +
421 + # Symlink to python-exec scripts
422 + for i in "${ED}"/usr/lib/python-exec/*/*; do
423 + n="${i##*/}"
424 + [[ -e "${ED}/usr/bin/${n}" ]] || dosym ../lib/python-exec/python-exec2 "/usr/bin/${n}"
425 + done
426 +
427 + python_setup
428 + local BUILD_DIR="${S}-${EPYTHON/./_}"
429 + cd "${BUILD_DIR}" || die
430 + fi
431 +
432 + einfo "Installing headers"
433 + ebazel build //tensorflow:install_headers
434 + ebazel shutdown
435 + insinto /usr/include/${PN}/
436 + doins -r bazel-bin/tensorflow/include/*
437 +
438 + einfo "Installing libs"
439 + # Generate $(tc-getPKG_CONFIG) file
440 + ${PN}/c/generate-pc.sh --prefix="${EPREFIX}"/usr --libdir=$(get_libdir) --version=${MY_PV} || die
441 + insinto /usr/$(get_libdir)/pkgconfig
442 + doins ${PN}.pc ${PN}_cc.pc
443 +
444 + for l in libtensorflow{,_framework,_cc}.so; do
445 + dolib.so bazel-bin/tensorflow/${l}
446 + dolib.so bazel-bin/tensorflow/${l}.$(ver_cut 1)
447 + dolib.so bazel-bin/tensorflow/${l}.$(ver_cut 1-3)
448 + done
449 +
450 + einstalldocs
451 +}