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-estimator/files/, sci-libs/tensorflow-estimator/
Date: Mon, 18 Feb 2019 13:55:01
Message-Id: 1550494329.b7bb43b59e0a499ac97a8717631165d9ff756f06.perfinion@gentoo
1 commit: b7bb43b59e0a499ac97a8717631165d9ff756f06
2 Author: Jason Zaman <perfinion <AT> gentoo <DOT> org>
3 AuthorDate: Sun Feb 17 13:59:38 2019 +0000
4 Commit: Jason Zaman <perfinion <AT> gentoo <DOT> org>
5 CommitDate: Mon Feb 18 12:52:09 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b7bb43b5
7
8 sci-libs/tensorflow-estimator: new package
9
10 Signed-off-by: Jason Zaman <perfinion <AT> gentoo.org>
11 Package-Manager: Portage-2.3.51, Repoman-2.3.11
12
13 sci-libs/tensorflow-estimator/Manifest | 1 +
14 ...-modularize-build-script-to-allow-distros.patch | 153 +++++++++++++++++++++
15 sci-libs/tensorflow-estimator/metadata.xml | 16 +++
16 .../tensorflow-estimator-1.13.0_rc0.ebuild | 61 ++++++++
17 4 files changed, 231 insertions(+)
18
19 diff --git a/sci-libs/tensorflow-estimator/Manifest b/sci-libs/tensorflow-estimator/Manifest
20 new file mode 100644
21 index 00000000000..410ce339186
22 --- /dev/null
23 +++ b/sci-libs/tensorflow-estimator/Manifest
24 @@ -0,0 +1 @@
25 +DIST tensorflow-estimator-1.13.0_rc0.tar.gz 531012 BLAKE2B 1398fdec5b81a7bab7ccfb2d37b8094c4ef4b96562e2c6b8b4e565cad3c234245b5d8dfb30a79b73302fc0764b1d3503d4ee2d4363a9d2e635b36fb8e2b726b4 SHA512 c8ad78d0df294c7471f1577880905be08edcc038878e9d197b975f33f91192e9c413d13fa70e8fa1ff760ad6bf6141f199322bf2076568690e75fa38bd5a4cf4
26
27 diff --git a/sci-libs/tensorflow-estimator/files/0001-pip_package-modularize-build-script-to-allow-distros.patch b/sci-libs/tensorflow-estimator/files/0001-pip_package-modularize-build-script-to-allow-distros.patch
28 new file mode 100644
29 index 00000000000..140e23c84bb
30 --- /dev/null
31 +++ b/sci-libs/tensorflow-estimator/files/0001-pip_package-modularize-build-script-to-allow-distros.patch
32 @@ -0,0 +1,153 @@
33 +From 897b25418ae0f77bcee7fdd7070d5c22677dc218 Mon Sep 17 00:00:00 2001
34 +From: Jason Zaman <jason@×××××××××.com>
35 +Date: Sat, 2 Feb 2019 15:19:44 +0800
36 +Subject: [PATCH] pip_package: modularize build script to allow distros to
37 + install more flexibly
38 +
39 +Gentoo Linux handles python modules slightly differently and packaging
40 +wheels is complicated. We prefer to run setup.py directly ourselves
41 +rather than build a wheel and then install from there.
42 +
43 +This modularizes build_pip_package.sh to allow running parts separately.
44 +using --src srcdir will prepare the package in a known dir so the distro
45 +package can take it from there. If only dstdir is given (either with
46 +--dst or as the only argument to preserve backwards compat) then
47 +behaviour is the same as before, the sources are prepared and the wheel
48 +is built and placed in dstdir.
49 +
50 +Signed-off-by: Jason Zaman <jason@×××××××××.com>
51 +---
52 + .../tools/pip_package/build_pip_package.sh | 73 +++++++++++++++++--
53 + 1 file changed, 66 insertions(+), 7 deletions(-)
54 +
55 +diff --git a/tensorflow_estimator/tools/pip_package/build_pip_package.sh b/tensorflow_estimator/tools/pip_package/build_pip_package.sh
56 +index 5d06dd6..1667169 100755
57 +--- a/tensorflow_estimator/tools/pip_package/build_pip_package.sh
58 ++++ b/tensorflow_estimator/tools/pip_package/build_pip_package.sh
59 +@@ -23,10 +23,8 @@ function real_path() {
60 + is_absolute "$1" && echo "$1" || echo "$PWD/${1#./}"
61 + }
62 +
63 +-function build_wheel() {
64 ++function prepare_src() {
65 + TMPDIR="$1"
66 +- DEST="$2"
67 +- PROJECT_NAME="$3"
68 +
69 + mkdir -p "$TMPDIR"
70 + echo $(date) : "=== Preparing sources in dir: ${TMPDIR}"
71 +@@ -67,6 +65,17 @@ function build_wheel() {
72 + touch "${TMPDIR}/tensorflow_estimator/contrib/estimator/python/__init__.py"
73 + touch "${TMPDIR}/tensorflow_estimator/contrib/estimator/python/estimator/__init__.py"
74 + fi
75 ++}
76 ++
77 ++function build_wheel() {
78 ++ if [ $# -lt 2 ] ; then
79 ++ echo "No src and dest dir provided"
80 ++ exit 1
81 ++ fi
82 ++
83 ++ TMPDIR="$1"
84 ++ DEST="$2"
85 ++ PROJECT_NAME="$3"
86 +
87 + pushd ${TMPDIR} > /dev/null
88 + echo $(date) : "=== Building wheel"
89 +@@ -75,15 +84,39 @@ function build_wheel() {
90 + cp dist/* ${DEST}
91 + popd > /dev/null
92 + echo $(date) : "=== Output wheel file is in: ${DEST}"
93 +- rm -rf "${TMPDIR}"
94 ++}
95 ++
96 ++function usage() {
97 ++ echo "Usage:"
98 ++ echo "$0 [--src srcdir] [--dst dstdir] [options]"
99 ++ echo "$0 dstdir [options]"
100 ++ echo ""
101 ++ echo " --src prepare sources in srcdir"
102 ++ echo " will use temporary dir if not specified"
103 ++ echo ""
104 ++ echo " --dst build wheel in dstdir"
105 ++ echo " if dstdir is not set do not build, only prepare sources"
106 ++ echo ""
107 ++ echo " Options:"
108 ++ echo " --project_name <name> set project name to name"
109 ++ echo " --nightly build tensorflow_estimator nightly"
110 ++ echo ""
111 ++ exit 1
112 + }
113 +
114 + function main() {
115 + NIGHTLY_BUILD=0
116 ++ PROJECT_NAME=""
117 ++ SRCDIR=""
118 ++ DSTDIR=""
119 ++ CLEANSRC=1
120 +
121 + while true; do
122 + if [[ -z "$1" ]]; then
123 + break
124 ++ elif [[ "$1" == "--help" ]]; then
125 ++ usage
126 ++ exit 1
127 + elif [[ "$1" == "--nightly" ]]; then
128 + NIGHTLY_BUILD=1
129 + elif [[ "$1" == "--project_name" ]]; then
130 +@@ -92,6 +125,19 @@ function main() {
131 + break
132 + fi
133 + PROJECT_NAME="$1"
134 ++ elif [[ "$1" == "--src" ]]; then
135 ++ shift
136 ++ if [[ -z "$1" ]]; then
137 ++ break
138 ++ fi
139 ++ SRCDIR="$(real_path $1)"
140 ++ CLEANSRC=0
141 ++ elif [[ "$1" == "--dst" ]]; then
142 ++ shift
143 ++ if [[ -z "$1" ]]; then
144 ++ break
145 ++ fi
146 ++ DSTDIR="$(real_path $1)"
147 + else
148 + DSTDIR="$(real_path $1)"
149 + fi
150 +@@ -105,16 +151,29 @@ function main() {
151 + fi
152 + fi
153 +
154 +- SRCDIR="$(mktemp -d -t tmp.XXXXXXXXXX)"
155 +-
156 +- if [[ -z "$DSTDIR" ]]; then
157 ++ if [[ -z "$DSTDIR" ]] && [[ -z "$SRCDIR" ]]; then
158 + echo "No destination dir provided"
159 ++ usage
160 + exit 1
161 + fi
162 +
163 ++ if [[ -z "$SRCDIR" ]]; then
164 ++ # make temp srcdir if none set
165 ++ SRCDIR="$(mktemp -d -t tmp.XXXXXXXXXX)"
166 ++ fi
167 +
168 ++ prepare_src "$SRCDIR"
169 ++
170 ++ if [[ -z "$DSTDIR" ]]; then
171 ++ # only want to prepare sources
172 ++ exit
173 ++ fi
174 +
175 + build_wheel "$SRCDIR" "$DSTDIR" "$PROJECT_NAME"
176 ++
177 ++ if [[ $CLEANSRC -ne 0 ]]; then
178 ++ rm -rf "${TMPDIR}"
179 ++ fi
180 + }
181 +
182 + main "$@"
183 +--
184 +2.19.2
185 +
186
187 diff --git a/sci-libs/tensorflow-estimator/metadata.xml b/sci-libs/tensorflow-estimator/metadata.xml
188 new file mode 100644
189 index 00000000000..2d40af6762c
190 --- /dev/null
191 +++ b/sci-libs/tensorflow-estimator/metadata.xml
192 @@ -0,0 +1,16 @@
193 +<?xml version="1.0" encoding="UTF-8"?>
194 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
195 +<pkgmetadata>
196 + <maintainer type="person">
197 + <email>perfinion@g.o</email>
198 + <name>Jason Zaman</name>
199 + </maintainer>
200 + <longdescription lang="en">
201 + TensorFlow Estimator is a high-level TensorFlow API that greatly
202 + simplifies machine learning programming. Estimators encapsulate
203 + training, evaluation, prediction, and exporting for your model.
204 + </longdescription>
205 + <upstream>
206 + <remote-id type="github">tensorflow/estimator</remote-id>
207 + </upstream>
208 +</pkgmetadata>
209
210 diff --git a/sci-libs/tensorflow-estimator/tensorflow-estimator-1.13.0_rc0.ebuild b/sci-libs/tensorflow-estimator/tensorflow-estimator-1.13.0_rc0.ebuild
211 new file mode 100644
212 index 00000000000..766a3206621
213 --- /dev/null
214 +++ b/sci-libs/tensorflow-estimator/tensorflow-estimator-1.13.0_rc0.ebuild
215 @@ -0,0 +1,61 @@
216 +# Copyright 1999-2019 Jason Zaman
217 +# Distributed under the terms of the GNU General Public License v2
218 +
219 +EAPI=7
220 +
221 +PYTHON_COMPAT=( python2_7 python{3_5,3_6} )
222 +MY_PN="estimator"
223 +MY_PV=${PV/_rc/-rc}
224 +MY_P=${MY_PN}-${MY_PV}
225 +
226 +inherit bazel distutils-r1 flag-o-matic toolchain-funcs
227 +
228 +DESCRIPTION="A high-level TensorFlow API that greatly simplifies machine learning programming"
229 +HOMEPAGE="https://www.tensorflow.org/"
230 +
231 +LICENSE="Apache-2.0"
232 +SLOT="0"
233 +KEYWORDS="~amd64"
234 +IUSE=""
235 +
236 +SRC_URI="https://github.com/tensorflow/${MY_PN}/archive/v${MY_PV}.tar.gz -> ${P}.tar.gz"
237 +
238 +RDEPEND="sci-libs/tensorflow[python,${PYTHON_USEDEP}]"
239 +DEPEND="${RDEPEND}"
240 +BDEPEND="
241 + dev-java/java-config"
242 +
243 +S="${WORKDIR}/${MY_P}"
244 +
245 +PATCHES=(
246 + "${FILESDIR}/0001-pip_package-modularize-build-script-to-allow-distros.patch"
247 +)
248 +DOCS=( CONTRIBUTING.md README.md )
249 +
250 +src_prepare() {
251 + bazel_setup_bazelrc
252 + default
253 +}
254 +
255 +src_compile() {
256 + export JAVA_HOME=$(java-config --jre-home)
257 +
258 + ebazel build //tensorflow_estimator/tools/pip_package:build_pip_package
259 + ebazel shutdown
260 +
261 + local srcdir="${T}/src"
262 + mkdir -p "${srcdir}" || die
263 + bazel-bin/tensorflow_estimator/tools/pip_package/build_pip_package --src "${srcdir}" || die
264 +}
265 +
266 +src_install() {
267 + do_install() {
268 + cd "${T}/src" || die
269 + esetup.py install
270 + python_optimize
271 + }
272 + python_foreach_impl do_install
273 +
274 + cd "${S}" || die
275 + einstalldocs
276 +}