From 5165df03fe2c0c74df7faf1cb8c18cf86d003835 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Tue, 18 Feb 2020 10:23:07 -0800 Subject: [PATCH] utils: Support global python environment settings. * Move Python environment values into `utils/environment.python.sh` * Source the `utils/environment.python.sh` before running Python scripts. * Add `DeprecationWarning` suppression for `distutils` Now the output of `make test-py` returns `30 passed in N.NNs` instead of the previous `30 passed, 1 warnings in N.NNs` Signed-off-by: Tim 'mithro' Ansell --- Makefile | 2 +- utils/environment.python.sh | 6 ++++++ utils/environment.sh | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 utils/environment.python.sh diff --git a/Makefile b/Makefile index aaa05a0c..9b5c0bab 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ ifeq ($(shell id -u),0) endif # Tools + Environment -IN_ENV = if [ -e env/bin/activate ]; then . env/bin/activate; fi; +IN_ENV = if [ -e env/bin/activate ]; then . env/bin/activate; fi; source utils/environment.python.sh; env: virtualenv --python=python3 env # Install prjxray diff --git a/utils/environment.python.sh b/utils/environment.python.sh new file mode 100644 index 00000000..43a4706e --- /dev/null +++ b/utils/environment.python.sh @@ -0,0 +1,6 @@ +# FIXME: fasm should be installed into the running Python environment. +export PYTHONPATH="${XRAY_DIR}:${XRAY_DIR}/third_party/fasm:$PYTHONPATH" + +# Suppress the following warnings; +# - env/lib/python3.7/distutils/__init__.py:4: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses +export PYTHONWARNINGS=ignore::DeprecationWarning:distutils diff --git a/utils/environment.sh b/utils/environment.sh index ac888429..f9dcbdfe 100644 --- a/utils/environment.sh +++ b/utils/environment.sh @@ -18,7 +18,7 @@ fi # misc export XRAY_PART_YAML="${XRAY_DATABASE_DIR}/${XRAY_DATABASE}/${XRAY_PART}/part.yaml" -export PYTHONPATH="${XRAY_DIR}:${XRAY_DIR}/third_party/fasm:$PYTHONPATH" +source $XRAY_UTILS_DIR/environment.python.sh # tools export XRAY_GENHEADER="${XRAY_UTILS_DIR}/genheader.sh"