Hope this is the correct category for my question. I’m trying to import platformio
and use it in my Python project to build firmware.
I am doing something like:
from platformio.package.manager.platform import PlatformPackageManager
from platformio.platform.factory import PlatformFactory
from platformio.project.config import ProjectConfig
package_manager = PlatformPackageManager()
project_config = ProjectConfig(os.path.join("myproject", "platformio.ini")
project_config.items(env=self.env, as_dict=True)
package_manager.install(spec=platform)
platform = self.project_config.items(env="my_env", as_dict=True)["platform"]
factory = PlatformFactory.new(platform)
factory.run({"pioenv": "my_env", "project_config": "myproject"}, [], True, False, 1)
But I run into Error: BoardConfig: Board is not defined
. If I run the same code in the project folder (making sure it is the current directory) it works.
I’m wondering if I am missing something or if there is a much better way of importing the project to use it as a library? I noticed PlatformFactory.run()
only gives 0 or 1 for result but would be nice to capture errors as well.
Thank you for your time in advance!