From 36b5b13797bb2c87aa92bd3cfe255cb462fbdf5f Mon Sep 17 00:00:00 2001 From: Kshitij Sisodia Date: Fri, 9 Jun 2023 11:58:26 +0100 Subject: MLECO-4065: Revising scripts to use Python3.9 Revising documentation and scripts to use Python3.9 explicitly to remove the need for installing it system-wide that might break a distro's desktop and pacakge manager utilities. Change-Id: I683b55dd0243d0a726dc94eba2431005d4897c8c Signed-off-by: Kshitij Sisodia --- docs/sections/building.md | 16 +++++----- docs/sections/troubleshooting.md | 69 +++++++++++++++++----------------------- 2 files changed, 38 insertions(+), 47 deletions(-) (limited to 'docs') diff --git a/docs/sections/building.md b/docs/sections/building.md index c7d69c8..7af3fdb 100644 --- a/docs/sections/building.md +++ b/docs/sections/building.md @@ -103,7 +103,9 @@ Before proceeding, it is *essential* to ensure that the following prerequisites > **Note:** If you have an older version of Python installed (< 3.9) see the > [Troubleshooting](./troubleshooting.md#how-to-update-python3-package-to-newer-version) - > for instruction on how to update it. + > for instruction on how to install and use it. + > **Note:** This scenario might be true if you are using an Arm Virtual Hardware instance. + > See the troubleshooting link above on how to set up the environment in this case. - The build system creates a Python virtual environment during the build process. Please make sure that Python virtual environment module is installed by running: @@ -112,12 +114,6 @@ Before proceeding, it is *essential* to ensure that the following prerequisites python3 -m venv ``` - > **Note:** If you are using an Arm Virtual Hardware instance then Python virtual environment is not installed by default. - > You will need to install it yourself by running the following command: - > ```commandline - > sudo apt install python3.8-venv - > ``` - - The build system uses external Python libraries during the building process. Please make sure that the latest pip and libsndfile versions are installed. @@ -362,7 +358,11 @@ for the default 128 MACs configuration of the Arm® *Ethos™-U55* NPU and for t Arm® *Ethos™-U65* NPU. > **Note:** This script requires Python version 3.9 or higher. Please make sure all [build prerequisites](./building.md#build-prerequisites) -> are satisfied. +> are satisfied. If your environment points to system installed Python3 that is an older version than 3.9, choose the +> required version explicitly after installing it: +> ```sh +> python3.9 ./set_up_default_resources.py +> ``` > > **Note:** This script also installs required version of CMake into the virtual environment, which can be used by activating it. diff --git a/docs/sections/troubleshooting.md b/docs/sections/troubleshooting.md index c8bb7b3..e6b921b 100644 --- a/docs/sections/troubleshooting.md +++ b/docs/sections/troubleshooting.md @@ -164,45 +164,36 @@ python3 --version sudo apt-get install python3.9 python3.9-venv libpython3.9 libpython3.9-dev ``` -3. Update the `python3` alternatives (set as 1 your previous version displayed at step 1): - - ```commandline - sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 - sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2 - ``` - -4. At the prompt, update the configuration by selecting Python3.9 as the chosen default alternative: - - ```commandline - sudo update-alternatives --config python3 - ``` - -5. Python3.9 is now set as default, you can check it by running: - - ```commandline - python3 --version - ``` - - ```log - Python 3.9.0 - ``` - -> **Note:** After updating from Python3.6 to Python3.9 it may happen that the `gnome-terminal` or the relative -> shortcuts don't work anymore. -> If when opening it from XTerm with `gnome-terminal` the following error appear: +3. Explicitly specify this Python when executing the set-up Python scripts. For example: + + ```commandline + python3.9 ./set_up_default_resources.py + ``` +> **Note:**: We do not recommend updating the Python version system-wide as it might break +> various desktop utilities for your OS distribution. However, if you are using a container +> or any other sandboxed environment, you can choose to update it using the following steps. +> +> * Update the `python3` alternatives (set as 1 your previous version displayed at step 1): +> +> ```commandline +> sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 +> sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2 +> ``` +> +> * At the prompt, update the configuration by selecting Python3.9 as the chosen default alternative: +> +> ```commandline +> sudo update-alternatives --config python3 +> ``` +> * Python3.9 is now set as default, you can check it by running: > -> ```log -> Traceback (most recent call last): -> File "/usr/bin/gnome-terminal", line 9, in -> from gi.repository import GLib, Gio -> File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in -> from . import _gi -> ImportError: cannot import name '_gi' from partially initialized module 'gi' (most likely due to a circular import) -> (/usr/lib/python3/dist-packages/gi/> __init__.py) -> ``` +> ```commandline +> python3 --version +> ``` > -> Modify the `gnome-terminal` script located in `/usr/bin/` and changing the environment (first line of the script) -> from `#!/usr/bin/python3` to `#!/usr/bin/python3.6`. +> ```log +> Python 3.9.0 +> ``` Next section of the documentation: [Appendix](appendix.md). @@ -240,11 +231,11 @@ subprocess.CalledProcessError: Command 'python3 -m venv env' returned non-zero e You can fix this error by installing Python virtual environment and removing the corrupted resources_downloaded folder. ```commandline -sudo apt install python3.9-venv rm -r resources_downloaded ``` -You can then try rebuilding again e.g. +Follow the instructions to [update Python3 package to 3.9 version](./troubleshooting.md#how-to-update-python3-package-to-newer-version) +before attempting a rebuild with: ```commandline python3 ./build_default.py -- cgit v1.2.1