diff options
author | Raul Farkas <raul.farkas@arm.com> | 2023-01-16 16:52:18 +0000 |
---|---|---|
committer | Raul Farkas <raul.farkas@arm.com> | 2023-02-09 15:38:02 +0000 |
commit | 428a8d54f574a73804274e53e61f711aebc25a0a (patch) | |
tree | 251bb0a54234fb9a62b8a22a9ba9f82e2b5f3ca5 /ethosu/mlw_codec | |
parent | 59b9ab9121d17793b5a240f7c51028b6b37a7a6e (diff) | |
download | ethos-u-vela-428a8d54f574a73804274e53e61f711aebc25a0a.tar.gz |
MLBEDSW-6982: Move to setup.cfg and pyproject.toml3.7.0.rc1
- Move all static information from setup.py to newly added
pyproject.toml
- Add setup.cfg used for static information that cannot be added to
pyproject.toml due to it still being in beta.
- Modify mlw_codec to to throw a real python exception when importing
NumPy arrays instead of just printing them to stdout.
- Surround mlw_codec import with try catch statement to catch NumPy C
API mismatch errors and throw them again with a more detailed message.
- Update README.md with documentation about known issue with changing
used NumPy version after installing ethos-u-vela.
Change-Id: I1eeee5536be7c1744e30d6088f7069fbb1403e06
Signed-off-by: Raul Farkas <raul.farkas@arm.com>
Diffstat (limited to 'ethosu/mlw_codec')
-rw-r--r-- | ethosu/mlw_codec/mlw_codecmodule.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/ethosu/mlw_codec/mlw_codecmodule.c b/ethosu/mlw_codec/mlw_codecmodule.c index 61ae6a47..8c540d61 100644 --- a/ethosu/mlw_codec/mlw_codecmodule.c +++ b/ethosu/mlw_codec/mlw_codecmodule.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2020-2021 Arm Limited and/or its affiliates <open-source-office@arm.com> + * SPDX-FileCopyrightText: Copyright 2020-2021, 2023 Arm Limited and/or its affiliates <open-source-office@arm.com> * * SPDX-License-Identifier: Apache-2.0 * @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #define PY_SSIZE_T_CLEAN #include <Python.h> #include <numpy/ndarrayobject.h> @@ -307,7 +306,19 @@ static struct PyModuleDef mlw_codecmodule = { PyMODINIT_FUNC PyInit_mlw_codec(void) { + PyObject *ptype, *pvalue, *ptraceback; PyObject* ret = PyModule_Create(&mlw_codecmodule); - import_array(); + if (_import_array() < 0) + { + // Fetch currently set error + PyErr_Fetch(&ptype, &pvalue, &ptraceback); + // Extract the error message + const char *pStrErrorMessage = PyUnicode_AsUTF8(pvalue); + // Re-format error message to start with "mlw_codec Error: " so it is + // clearer it comes from mlw_codec. + PyErr_Format(PyExc_RuntimeError, "mlw_codec error: %s", pStrErrorMessage); + return NULL; + } + return ret; } |