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 <me@mith.ro>
This commit is contained in:
Tim 'mithro' Ansell 2020-02-18 10:23:07 -08:00
parent f4368e62e5
commit 5165df03fe
3 changed files with 8 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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"