espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.78k stars 7.44k forks source link

The esp32-arduino core should bundle pyserial, so esptool works #9689

Open egnor opened 6 months ago

egnor commented 6 months ago

Related area

platform support for esptool

Hardware specification

(relevant to all)

Is your feature request related to a problem?

If pyserial is not installed on the base system, esptool can't run, and because of https://github.com/espressif/esptool/issues/981 you just get a stack trace and "No module named 'serial'" which isn't the most helpful, particularly for people using the Arduino IDE not conversant with Python.

This also makes the install-on-Linux instructions a lot more complicated than they have to be. Should just be a matter of adding the board manager URL.

Describe the solution you'd like

Somehow, when installing the arduino-esp32 platform, pyserial should get installed alongside other things.

Describe alternatives you've considered

No response

Additional context

No response

I have checked existing list of Feature requests and the Contribution Guide

Jason2866 commented 6 months ago

That needs major changes. You can't install just py serial. You need a Pyenv for Arduino to have all rights to install and don't disturb the system installed python. So a check for pyenv is needed and when not there it needs to be installed. To do so python for all systems needs to be provided.

egnor commented 6 months ago

(I assume you mean venv, not pyenv?)

You don't actually need a venv to add a bundled module, you can just edit $PYTHONPATH to point to the bundled pyserial directory (or its .whl). Even if you are using a venv, you can still use the system Python, though not relying on that would be preferred!

For making portable self contained Python based executables (that bundle Python itself and any needed modules), I hear good things about PyOxidizer; I don't know if it would be compatible with pyserial.

Jason2866 commented 6 months ago

Been there. Believe me only way that will work is to have a extra venv when requirements needs to be installed. Every other try will not work on a platform. Arduino esp8266 is doing that and Platformio (for every framework) too. If going back to "compiled" apps than using esptool as compiled binary. For example this ones. This was the way in the past and there where reasons to switch to esptool.py ;-)

egnor commented 6 months ago

Just seems like there should be some better way. We do bundle a full Python installation for Windows?

Jason2866 commented 6 months ago

What's wrong to provide a small python package. It is around 7MB.

egnor commented 6 months ago

You mean the Python binary itself (along with whatever libraries are needed)? Sounds good to me!