diff options
author | Dwight Lidman <dwight.lidman@arm.com> | 2021-05-12 18:58:05 +0200 |
---|---|---|
committer | Dwight Lidman <dwight.lidman@arm.com> | 2021-05-17 15:37:25 +0200 |
commit | e917cdcc659a7195987dbdb83e86597953c9aacd (patch) | |
tree | 2b9a2a38f83ebd2567aeef1b7359c78ff9d7392e /setup.py | |
parent | 93d5c35feaae8f2fe8e0361ffc19e31d463ca099 (diff) | |
download | ethos-u-vela-e917cdcc659a7195987dbdb83e86597953c9aacd.tar.gz |
MLBEDSW-4585: Resolve NumPy setup requirement
This commit fixes a potential end user problem where
the user needs NumPy installed in order to run setup.py.
This creates a situation where if the user needs to
manually install NumPy in order to install Vela.
This solution moves the NumPy dependent code into the
setup process and allows it to be installed as a
dependency first.
Signed-off-by: Dwight Lidman <dwight.lidman@arm.com>
Change-Id: I5d7d3d30c3755e8f7c369df8d34738f5c53877dd
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -18,10 +18,24 @@ import os import re -import numpy as np from setuptools import Extension from setuptools import find_namespace_packages from setuptools import setup +from setuptools.command.build_ext import build_ext + + +class BuildExtension(build_ext): + def finalize_options(self): + build_ext.finalize_options(self) + import builtins + + # tell numpy it's not in setup anymore + builtins.__NUMPY_SETUP__ = False + import numpy as np + + # add the numpy headers to the mlw_codec extension + self.include_dirs.append(np.get_include()) + # Read the contents of README.md file this_directory = os.path.abspath(os.path.dirname(__file__)) @@ -43,7 +57,6 @@ with open(os.path.join(this_directory, "README.md"), encoding="utf-8") as f: mlw_module = Extension( "ethosu.mlw_codec", ["ethosu/mlw_codec/mlw_encode.c", "ethosu/mlw_codec/mlw_decode.c", "ethosu/mlw_codec/mlw_codecmodule.c"], - include_dirs=[np.get_include()], define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_9_API_VERSION")], ) @@ -81,5 +94,6 @@ setup( ], entry_points={"console_scripts": ["vela = ethosu.vela.vela:main"]}, ext_modules=[mlw_module], - setup_requires=["setuptools_scm"], + cmdclass={"build_ext": BuildExtension}, + setup_requires=["numpy>=1.16.6", "setuptools_scm"], ) |