Use a virtual environment for Python packages by default #261
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of changes
Using Mbed lately, and watching others use it, I have been feeling like the need to install Python packages, and to reinstall them if Mbed adds a new requirement, causes annoyance for people a lot of the time. Traditionally I've been a bit of a critic of venvs but as I have gotten more into Python development I have understood their value more. It's simply too common to have broken system packages, or a system with a too old version of a package, or a dependency conflict with something else you have installed.
While it's still nice to have the option to use system packages if needed, making the default to create a new venv with all the correct stuff seems like it will make Mbed more user friendly, and therefore, is worth doing. The venv uses about 60MB per instance on my machine, which is not nothing, but still pretty manageable, especially compared to the size of Mbed itself.
Impact of changes
By default, Mbed's CMake scripts will now create a virtual environment under the mbed-os source dir when run for the first time. The venv is located in the source dir to de-duplicate it, as it is not specific to a given build directory.
The option
-DMBED_CREATE_PYTHON_VENV=FALSEcan be passed to CMake in order to disable this and switch to the old behavior of using the system interpreter.Also, I fixed two other annoying issues in this PR:
Migration actions required
Documentation
Once this PR is approved I will update all of the wiki pages to remove instructions to install the Python packages. It should be a bit simpler!
Pull request type
Test results
Reviewers