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

Fix deprecation issues with older Python code #296

Merged
merged 2 commits into from
Jul 6, 2024

Conversation

multiplemonomials
Copy link
Collaborator

@multiplemonomials multiplemonomials commented Jul 4, 2024

Summary of changes

As @JohnK1987 discovered, the Mbed OS Python packages currently have some issues with newer python versions, in particular Python 3.12 and 3.13. 3.12 removed a number of legacy packages, such as imp, pkg_resources, and optparse. For the most part, the mbed_tools package (being developed only a few years ago), is free of these issues, but the older python packages (which are mainly used for running tests) had a fair amount of issues that needed to be fixed.

With the changes in this PR, I am now able to run all the Python tests successfully using Python 3.13!

As part of this, I also ended up removing the mbed-greentea package. It had several of its own deprecation issues, and it seems to be entirely composed of either legacy names for stuff in mbed_os_tools.test or exact duplicates of files & tests from that package.

Impact of changes

Python scripts no longer error our on Python >= 3.12

Migration actions required

Documentation


Pull request type

[X] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] 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)
[X] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

@JohnK1987
Copy link
Member

JohnK1987 commented Jul 5, 2024

@multiplemonomials any ideas?

[main] Building folder: MbedCE_H5_NEw
[build] Starting build
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/MbedCE/MbedCE_H5_NEw/build --config Debug --target flash-main --
[build] [1/1 100% :: 0.965] C:\Windows\system32\cmd.exe /C "cd /D C:\MbedCE\MbedCE_H5_NEw\mbed-os\tools\python && C:\MbedCE\MbedCE_H5_NEw\mbed-os\venv\Scripts\python.exe -m install_bin_file C:/MbedCE/MbedCE_H5_NEw/build/main.bin NUCLEO_H503RB 115200"
[build] FAILED: CMakeFiles/flash-main C:/MbedCE/MbedCE_H5_NEw/build/CMakeFiles/flash-main
[build] C:\Windows\system32\cmd.exe /C "cd /D C:\MbedCE\MbedCE_H5_NEw\mbed-os\tools\python && C:\MbedCE\MbedCE_H5_NEw\mbed-os\venv\Scripts\python.exe -m install_bin_file C:/MbedCE/MbedCE_H5_NEw/build/main.bin NUCLEO_H503RB 115200"
[build] [1720215923.59][mbedls.lstools_base]daplink entry: "0832" not found in platform database
[build] [install-bin-file] ERROR: The target board you compiled for is not connected to your system.
[build] Please reconnect it and retry the last command.
[build] (Searched for any NUCLEO_H503RB board.)
[build] ---
[build] ninja: build stopped: subcommand failed.
[proc] The command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/MbedCE/MbedCE_H5_NEw/build --config Debug --target flash-main -- exited with code: 1
[driver] Build completed: 00:00:01.010
[build] Build finished with exit code 1

@multiplemonomials
Copy link
Collaborator Author

Hmm, I think this is an issue with the "detect code" of the Nucleo H5 board not being known to Mbed, not anything to do with Python deprecation. Taking a look, you might need to update the DEFAULT_PLATFORM_DB dict in mbed-os/tools/python/mbed_os_tools/detect/platform_database.py

@JohnK1987
Copy link
Member

Aha, I did not know about this database. I fill the numbers and it is OK now.

@multiplemonomials multiplemonomials merged commit 71cb812 into master Jul 6, 2024
10 checks passed
@multiplemonomials multiplemonomials deleted the dev/fix-legacy-python branch July 6, 2024 08:19
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