blob: 55791760d60f9171cc35188bcd18befec7fc7f58 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
PORTNAME= keras
DISTVERSION= 2.9.0
PORTREVISION= 1
CATEGORIES= math # machine-learning
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
MAINTAINER= yuri@FreeBSD.org
COMMENT= Deep learning library for Python
WWW= https://keras.io/
LICENSE= MIT
LICENSE_FILE= ${WRKSRC}/LICENSE
RUN_DEPENDS= ${PYNUMPY} \
${PYTHON_PKGNAMEPREFIX}absl-py>=1.0.0:devel/py-absl-py \
${PYTHON_PKGNAMEPREFIX}h5py>=0:science/py-h5py@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}pandas>=1.3.5:math/py-pandas@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}pillow>=9.2.0:graphics/py-pillow@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}keras-preprocessing>=1.1.0:math/py-keras-preprocessing@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}scipy>=0.14:science/py-scipy@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}six>=1.9.0:devel/py-six@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}protobuf>=3.13.0:devel/py-protobuf@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}keras-applications>=1.0.8:math/py-keras-applications@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}keras-preprocessing>=1.1.1:math/py-keras-preprocessing@${PY_FLAVOR}
BUILD_DEPENDS= ${RUN_DEPENDS} \
${PYTHON_PKGNAMEPREFIX}tensorflow>=2.9.0:science/py-tensorflow@${PY_FLAVOR} \
bazel:devel/bazel5 \
bash:shells/bash
USES= python
USE_GITHUB= yes
GH_ACCOUNT= keras-team
GH_PROJECT= ${PORTNAME}
GH_TAGNAME= r2.9
.include "Makefile.MASTER_SITES"
post-patch:
# don't cache stuff to $HOME/.cache/
@${MKDIR} ${WRKDIR}/bazel-cache
@${MKDIR} ${WRKDIR}/bazel-dist
.for file in ${DISTFILES:C/\:(.*)//}
@${ECHO} "Moving ${file} to ${WRKDIR}/bazel-dist"
@${CP} ${DISTDIR}/${DIST_SUBDIR}/${file} ${WRKDIR}/bazel-dist
.endfor
# place the generate wheel file here
@${MKDIR} ${WRKDIR}/whl
# These files are from my tensorflow port
# if both make it into the port they can be shared
# copy the toolchain over
@${CP} -R ${PATCHDIR}/freebsd \
${WRKSRC}/
@${CP} ${PATCHDIR}/bazelrc \
${WRKSRC}/
#setup localbase
@${REINPLACE_CMD} "s#%%LOCALBASE%%#${LOCALBASE}#" \
${WRKSRC}/freebsd/cc_toolchain_config.bzl \
${WRKSRC}/.bazelrc \
${WRKSRC}/bazelrc
# setup our bazelrc
@${REINPLACE_CMD} "s#%%BAZEL_DIR%%#${WRKDIR}#" ${WRKSRC}/bazelrc
@${REINPLACE_CMD} "s#%%BAZEL_DIST%%#${WRKDIR}#" ${WRKSRC}/bazelrc
@${REINPLACE_CMD} "s#%%PATH%%#${PATH}#" ${WRKSRC}/bazelrc
@${REINPLACE_CMD} "s#%%PYTHON%%#${PYTHON_CMD}#" ${WRKSRC}/.bazelrc
# bazel is horrible, it will won't propagated enviroment variable throughout the build
# and will ignore variables set by us. This causing a lot of issues, especially with python
# auto generated files will sometimes ignore our py_runtime toolchain and our PYTHON_BIN_PATH
# causing it to still set the shebang line to bin/env python3. Even on the github page the solution
# has been to use a symlink to work around so do that here as a fix
@${MKDIR} ${WRKDIR}/.bin
${LN} -s ${PYTHON_CMD} ${WRKDIR}/.bin/python3
@${REINPLACE_CMD} "s#%%PYTHON%%#${PYTHON_CMD}#" \
${WRKSRC}/keras/tools/pip_package/build_pip_package.sh
do-build:
@cd ${WRKSRC} && ${SETENV} \
PYTHON_BIN_PATH=${PYTHON_CMD} \
PYTHON_LIB_PATH="${PYTHON_SITELIBDIR}" \
PYTHON_BINARY=${PYTHON_CMD} \
bazel --bazelrc="${WRKSRC}/bazelrc" \
build --config=freebsd \
//keras/tools/pip_package:build_pip_package
# @${REINPLACE_CMD} "s#python#${PYTHON_CMD}#" \
# ${WRKSRC}/bazel-bin/keras/tools/pip_package/build_pip_package
@cd ${WRKSRC} && \
bazel-bin/keras/tools/pip_package/build_pip_package \
${WRKDIR}/whl
do-install:
@${MKDIR} ${STAGEDIR}/${PYTHON_SITELIBDIR}
${UNZIP_NATIVE_CMD} -d ${STAGEDIR}/${PYTHON_SITELIBDIR} ${WRKDIR}/whl/${PORTNAME}-${PORTVERSION}-*.whl
.include <bsd.port.mk>
|