PlatformIO Community

Sharing function when using muliple pre: extra_scripts

If I have multiple pre scripts defined in the extra_scripts property, are the python files all merged before they are executed? or are they started independently?

The reason im asking, is because i have defined a python function that I need in more than one pre-script, and I’m not really happy with copying the function into multiple py files

Pre- and post scripts are executed as separate SConscripts in series

However, Python imports still work as normal (see e.g. a Marlin example). As in:

def my_shared_func1(some_arg): 

def my_shared_func2(some_arg): 

import shared_funcs
# or direct import into namespace
# from shared_funcs import *
# selective import
# from shared_funcs import my_shared_func1


#.. depending on the import style
ret = shared_funcs.my_shared_func1(123)
#ret = my_shared_func1(123)

etc with more other Python scripts importing functions.