Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring python packages into the mbed-os source #192

Merged
merged 14 commits into from
Oct 10, 2023

Conversation

multiplemonomials
Copy link
Collaborator

@multiplemonomials multiplemonomials commented Oct 8, 2023

Summary of changes

One python package root to rule them all, one root to find them, one root to bring them all, and in the repository bind them

Up until now, Mbed CE has relied on the user installing the mbed_tools python package to their python interpreter before using the build system. This python package is responsible for scanning the source tree and processing all the json files, and then computing a list of target labels and compile definitions for CMake to use. Originally it was also a wrapper around CMake, but that isn't used by Mbed CE. So, this package is needed in order to configure projects, but unlike mainline Mbed it isn't used to wrap the entire build process, and there's no actual requirement that it be installed globally, and it's a bit awkward that we depend on this package that we can't modify or control.

Meanwhile, new Linux distro releases such as Ubuntu 22.04 have almost completely blocked the use of Pip to install packages to the global python interpreter (even if you install them to your user directory!). You have to install the packages via apt-get, or you have to use a venv. There are basically no other options. Normally we could just switch to installing the dependencies via apt-get, except that mbed_tools (and the other python package, mbed_os_tools) is not in the apt-get package index. So, if we continue to depend on these system python packages, we would have to require users to create and use venvs, which seems like a pain.

To resolve this, and to lay a path for Mbed CE to make our own changes to these python packages (since they can't be modified without ARM approval), this PR brings the mbed_tools and mbed_os_tools packages into the Mbed CE source tree. I have hooked up their respective test suites, so that all the tests get run and checked when CI builds are made.

Additionally, I set up new requirements files (requirements.apt.txt) so that apt-get can use them. This should make it so that people using Mbed on recent Ubuntu can just install everything with a single command without worrying about venvs or changing pip/python config settings.

Impact of changes

  • All python packages and python scripts used in the build are now collected under tools/python
  • mbed-tools python package no longer needs to be installed, this package is now included with mbed
  • Linux setup instructions change: instead of installing tools/requirements.txt, Debian users should run xargs sudo apt-get install < tools/requirements.apt.txt
  • Scancode checking bug fixed, license check works again

Migration actions required

None

Documentation

I have updated the project setup guides to mention the new apt-get method


Pull request type

[] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[X] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[] Covered by existing mbed-os tests (Greentea or Unittest)
[X] Tests / results supplied as part of this PR

Reviewers


@multiplemonomials multiplemonomials changed the title [draft] Bring python packages into the mbed-os source Bring python packages into the mbed-os source Oct 8, 2023
@multiplemonomials multiplemonomials merged commit 3af1c75 into master Oct 10, 2023
9 checks passed
@multiplemonomials multiplemonomials deleted the dev/bring-in-python-packages branch October 10, 2023 16:54
@JohnK1987
Copy link
Member

JohnK1987 commented Oct 10, 2023

@multiplemonomials step 5 of New Project Setup Guide is still right?

Make sure you have the needed Python requirements: python3 -m pip install -r mbed-os/tools/requirements.txt (use python instead of python3 on Windows)

BTW this is funny

One python package root to rule them all, one root to find them, one root to bring them all, and in the repository bind them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants