How to pass parameters to a Python script from platformio.ini?

I can divide my question into two completely separate parts:

  1. What I would like to do in this question is to pass parameters to a Python script called with extra_scripts.

  2. But in the end, what I’m trying to do is to be able to test very quickly in PIO examples intended to be used basically in the Arduino IDE. The idea is to make as few modifications as possible to the examples. My current DIY solution works as follows:

  • Create a PIO project.
  • Copy the directory containing the examples into the include directory.
  • In platformio.ini, create an example environment that I want to test.
  • Correct the ino file if necessary.
  • Each environment calls a Python script which creates a src/main.cpp file containing two #include:
#include <Arduino.h>
#include “../include/M5Atom/examples/Basics/Button/Button.ino”

It works, but adding the extra_includes option generates one warning per environment (so that’s a lot).

Note that this is related to my other question here: