mxnet: Fix dependency and add new version. (#16714)

* mxnet: Fix dependency and add new version.

1. Fix opencv and numpy dependency.
2. Add version 1.6.0.

* typo in patch is fixed.
fixed spec access.
This commit is contained in:
Toyohisa Kameyama 2020-05-21 12:33:31 +09:00 committed by GitHub
parent bcd5dd6e3e
commit 51ff18ef8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 59 additions and 7 deletions

View file

@ -0,0 +1,35 @@
commit 638527ffaa35ffb0bf88a32910b809df09432406
Author: Toyohisa Kameyama <kameyama@riken.jp>
Date: Mon May 18 11:58:00 2020 +0900
Makefile bug fix for opencv4.
diff --git a/Makefile b/Makefile
index 51930c782..7f5d4da39 100644
--- a/Makefile
+++ b/Makefile
@@ -165,7 +165,23 @@ endif
ifeq ($(USE_OPENCV), 1)
CFLAGS += -DMXNET_USE_OPENCV=1
ifneq ($(filter-out NONE, $(USE_OPENCV_INC_PATH)),)
- CFLAGS += -I$(USE_OPENCV_INC_PATH)/include
+ ifneq ($(wildcard $(USE_OPENCV_INC_PATH)/include/opencv4/opencv2/opencv*),)
+ opencv_inc = -I$(USE_OPENCV_INC_PATH)/include/opencv4
+ endif
+ ifneq ($(wildcard $(USE_OPENCV_INC_PATH)/include/opencv2/opencv*),)
+ opencv_inc = -I$(USE_OPENCV_INC_PATH)/include
+ endif
+ ifneq ($(wildcard $(USE_OPENCV_INC_PATH)/opencv4/opencv2/opencv*),)
+ opencv_inc = -I$(USE_OPENCV_INC_PATH)/opencv4
+ endif
+ ifneq ($(wildcard $(USE_OPENCV_INC_PATH)/opencv2/opencv*),)
+ opencv_inc = -I$(USE_OPENCV_INC_PATH)
+ endif
+ ifneq ($(filter-out NONE, $(opencv_inc)),)
+ CFLAGS += $(opencv_inc)
+ else
+$(error Cannot determine OpenCV include path)
+ endif
ifeq ($(filter-out NONE, $(USE_OPENCV_LIB_PATH)),)
$(error Please add the path of OpenCV shared library path into `USE_OPENCV_LIB_PATH`, when `USE_OPENCV_INC_PATH` is not NONE)
endif

View file

@ -15,6 +15,7 @@ class Mxnet(MakefilePackage):
maintainers = ['adamjstewart'] maintainers = ['adamjstewart']
version('1.6.0', sha256='01eb06069c90f33469c7354946261b0a94824bbaf819fd5d5a7318e8ee596def')
version('1.3.0', sha256='c00d6fbb2947144ce36c835308e603f002c1eb90a9f4c5a62f4d398154eed4d2') version('1.3.0', sha256='c00d6fbb2947144ce36c835308e603f002c1eb90a9f4c5a62f4d398154eed4d2')
variant('cuda', default=False, description='Enable CUDA support') variant('cuda', default=False, description='Enable CUDA support')
@ -33,14 +34,18 @@ class Mxnet(MakefilePackage):
depends_on('cudnn', when='+cuda') depends_on('cudnn', when='+cuda')
depends_on('cudnn', when='+cuda') depends_on('cudnn', when='+cuda')
depends_on('cub', when='+cuda') depends_on('cub', when='+cuda')
depends_on('opencv+core+imgproc+highgui+jpeg+png+tiff~eigen~ipp@3.0:3.4.99', when='@1.3.0 +opencv')
depends_on('opencv+core+imgproc+highgui+jpeg+png+tiff~eigen~ipp@3.0:', when='+opencv') depends_on('opencv+core+imgproc+highgui+jpeg+png+tiff~eigen~ipp@3.0:', when='+opencv')
# python extensions # python extensions
depends_on('python@2.7:', type=('build', 'run'), when='+python') depends_on('python@2.7:', type=('build', 'run'), when='+python')
depends_on('py-setuptools', type='build', when='+python') depends_on('py-setuptools', type='build', when='+python')
depends_on('py-numpy@:1.15.0', type=('build', 'run'), when='@1.3.0 +python')
depends_on('py-numpy@1.16:', type=('build', 'run'), when='@1.6.0 +python')
extends('python', when='+python') extends('python', when='+python')
patch('makefile.patch', when='@0.10:0.11') patch('makefile.patch', when='@0.10:0.11')
patch('makefile.opencv.patch', when='@1.6.0')
def build(self, spec, prefix): def build(self, spec, prefix):
# copy template configuration file # copy template configuration file
@ -73,13 +78,25 @@ def build(self, spec, prefix):
] ]
if '+opencv' in spec: if '+opencv' in spec:
filter_file('$(shell pkg-config --cflags opencv)', if spec.satisfies('@1.3.0'):
'-I%s' % spec['opencv'].prefix.include, filter_file(
'Makefile', string=True) '$(shell pkg-config --cflags opencv)',
filter_file('$(filter-out -lopencv_ts, ' spec['opencv'].headers.include_flags,
'Makefile', string=True
)
filter_file(
'$(filter-out -lopencv_ts, '
'$(shell pkg-config --libs opencv))', '$(shell pkg-config --libs opencv))',
'-lopencv_core -lopencv_imgproc -lopencv_imgcodecs', spec['opencv'].libs.link_flags,
'Makefile', string=True) 'Makefile', string=True
)
else:
args.extend(
['USE_OPENCV_INC_PATH=' +
spec['opencv'].headers.directories[0],
'USE_OPENCV_LIB_PATH=' +
spec['opencv'].libs.directories[0]]
)
if 'openblas' in spec: if 'openblas' in spec:
args.extend(['USE_BLAS=openblas']) args.extend(['USE_BLAS=openblas'])