Skip to content

Commit 3251404

Browse files
committed
AC: install command update platform specific
1 parent b79ea42 commit 3251404

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

tools/accuracy_checker/setup.py

+24-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
import re
1919
import sys
2020
import warnings
21+
import platform
22+
import subprocess
23+
from distutils.version import LooseVersion
2124
from setuptools import find_packages, setup
2225
from setuptools.command.test import test as test_command
2326
from setuptools.command.install import install as install_command
@@ -45,6 +48,19 @@ def read(*path):
4548
with version_file.open() as file:
4649
return file.read()
4750

51+
def check_and_update_numpy(min_acceptable='1.15'):
52+
try:
53+
import numpy as np
54+
update_required = LooseVersion(np.__version__) < LooseVersion(min_acceptable)
55+
except ImportError:
56+
update_required = True
57+
if update_required:
58+
subprocess.call(['pip3', 'install', 'numpy>={}'.format(min_acceptable)])
59+
60+
61+
class CoreInstall(install_command):
62+
pass
63+
4864

4965
class CoreInstall(install_command):
5066
pass
@@ -67,10 +83,14 @@ def find_version(*path):
6783
try:
6884
importlib.import_module('cv2')
6985
except ImportError as opencv_import_error:
70-
warnings.warn(
71-
"Problem with cv2 import: \n{}\n opencv-python will be added to requirements".format(opencv_import_error)
72-
)
73-
requirements.append('opencv-python')
86+
if platform.processor() != 'aarch64':
87+
warnings.warn(
88+
"Problem with cv2 import: \n{}\n opencv-python will be added to requirements".format(opencv_import_error)
89+
)
90+
requirements.append('opencv-python')
91+
else:
92+
warnings.warn("Problem with cv2 import: \n{}.\n Probably due to unsuitable numpy version, will be updated".format(opencv_import_error))
93+
check_and_update_numpy()
7494

7595
setup(
7696
name="accuracy_checker",

0 commit comments

Comments
 (0)