-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
mkbuildoptglobals.py: assert python version #8886
Conversation
Hello, I was thinking if is it possible to make Arduino ESP8266 able to detect the required Python3 executable name; for example, in my system by executing: compgen -c python | grep -P '^python(\d(.\d+)?)?$' | sort | uniq I got: python The problem of course, it does not mean that python3 is actually a symbolic link to python3.11 because in my case python3 is the default Python3 used by the system (and it is not python3.11). Anyway, it is just an idea because I am not sure how difficult it is to implement the detection in Arduino. Thank you! |
Depends on whether we want to do this magic auto-detection of latest version vs. having user simply replace the PATH temporarily to give a specific one. From venv, custom script launcher, different shell environment, etc. Current approach is packaging this launcher
#!/usr/bin/env python3
import os
import sys
args = ["env", "python3"] + sys.argv[1:];
os.execv("/usr/bin/env", args) We can't (?) modify menu of IDE dynamically based on available python versions, so I'd rather leave the |
Hmmm, yes I think you are correct. There seems to be no method to modify menu of IDE dynamically based on available python versions and because the python executable names can be anything we also cannot list all the possible combinations in the menu. Perhaps, using a special environment variable can also help. Lets say if ARDUINO_PYTHON is defined, the launcher can use that as the entry point name instead of python3, but I am not sure if this approach can simply be used with this ESP8266 core or should actually be specified further as a more generic Arduino IDE feature. |
So before replacing any scripts / adding our env we have either
python executable is our private thing here, so maybe ESP8266_ARDUINO_PYTHON_PATH if environment tweak is more coherent solution to document |
Finally because the env var Yes I know in Windows, the package also carries its own copy of python3 executable and DLL. I tested them and I found that they do not run on Win7 without SP1. I also remembered that I somehow manage to download python3 >= 3.7 that will work on plain Win7 (surprisingly Arduino IDE 2.0.x can be made to run in plain Win7). I am pretty sure that plain Win7 is no longer used widely, but using env var still may provide better flexibility for users with custom python installation path (it should still work in Win10 and 11, right?) |
Another funny way to override is to make a custom tool directory. It even overrides the local git installation tools/ > arduino-cli compile -b esp8266com:esp8266:generic --show-properties | grep tools.python3.path=
runtime.tools.python3.path={runtime.platform.path}/tools/python3
> mkdir -p ~/.arduino15/packages/esp8266com/tools/python3/9.9.9
> touch ~/.arduino15/packages/esp8266com/tools/python3/9.9.9/python3
> arduino-cli compile -b esp8266com:esp8266:generic --show-properties | grep tools.python3.path=
runtime.tools.python3.path=/home/runner/.arduino15/packages/esp8266com/tools/python3/9.9.9 Not sure if IDE / CLI would care some time later when updating things, since this package version would not be referenced by any platform. https://github.com/earlephilhower/esp-quick-toolchain has to be updated for env var change |
Well, so it seems the IDE and CLI do have some feature to detect (compare?) version by directory name. Of course, we can not be sure that this feature (bug?) will be consistent for future releases. The python launcher is only a small file. Is it necesarry to make a full new release after modifications to |
Spoke too soon, above is no longer the case for latest -cli versions No need to re-release everything, just a tag for the commit that updates python archive which then can be fetched with a permanent link. Replacing existing assets breaks old versions. |
That is good news. Thank you for your help and attention! |
I have tested the env var using manually installed https://github.com/earlephilhower/esp-quick-toolchain/releases/download/3.2.0-gcc10.3/python3-via-env.tar.gz. It is working properly in my machine. Thank you again for your help and attention. |
Fix unused var causing warnings Assert minimal supported version of python3 Python 3.7 in documentation
resolve #8877
also fix spurious warning when getdefaultencoding() is used with versions ≥3.11