mirrexagon / nixpkgs-esp-dev

Nix flake and overlay for ESP8266 and ESP32 development.
Creative Commons Zero v1.0 Universal
143 stars 71 forks source link

esp_rfc2217_server.py not working because of a syntax error in python3.11-esptool-4.6.2/bin/esptool.py #51

Closed mksafavi closed 3 months ago

mksafavi commented 6 months ago

I noticed that esp_rfc2217_server.py doesn't work. I'm not sure if this is the only command that has this issue. Let me know if there's any other info that I should share.

command to run:

esp_rfc2217_server.py -p 4400 /dev/ttyACM0

error:

Traceback (most recent call last):
  File "/nix/store/wn78z9b8lijylzy8znzmdj021z54iz6f-python3.11-esptool-4.6.2/bin/.esp_rfc2217_server.py-wrapped", line 40, in <module>
    from esptool.config import load_config_file
  File "/nix/store/wn78z9b8lijylzy8znzmdj021z54iz6f-python3.11-esptool-4.6.2/bin/esptool.py", line 2
    PATH=${PATH:+':'$PATH':'}
         ^
SyntaxError: invalid syntax

expected output:

INFO:root:RFC 2217 TCP/IP to Serial redirector - type Ctrl-C / BREAK to quit
INFO:root:Serving serial port: /dev/ttyACM0
INFO:root:TCP/IP port: 4400

/nix/store/wn78z9b8lijylzy8znzmdj021z54iz6f-python3.11-esptool-4.6.2/bin/esptool.py is different from the esptool.py (/nix/store/95iahqmhrwm519324ibp703i7n21d3xp-python3-3.11.9-env/bin/esptool.py) that's used for flashing,...

inside the file that has syntax errors:

cat /nix/store/wn78z9b8lijylzy8znzmdj021z54iz6f-python3.11-esptool-4.6.2/bin/esptool.py
#! /nix/store/h3bhzvz9ipglcybbcvkxvm4vg9lwvqg4-bash-5.2p26/bin/bash -e
PATH=${PATH:+':'$PATH':'}
PATH=${PATH/':''/nix/store/gdc6wgbdgb23f9cxa4f0lddfc4xg4g4n-python3.11-pyserial-3.5/bin'':'/':'}
PATH='/nix/store/gdc6wgbdgb23f9cxa4f0lddfc4xg4g4n-python3.11-pyserial-3.5/bin'$PATH
PATH=${PATH#':'}
PATH=${PATH%':'}
export PATH
PATH=${PATH:+':'$PATH':'}
PATH=${PATH/':''/nix/store/wn78z9b8lijylzy8znzmdj021z54iz6f-python3.11-esptool-4.6.2/bin'':'/':'}
PATH='/nix/store/wn78z9b8lijylzy8znzmdj021z54iz6f-python3.11-esptool-4.6.2/bin'$PATH
PATH=${PATH#':'}
PATH=${PATH%':'}
export PATH
PATH=${PATH:+':'$PATH':'}
PATH=${PATH/':''/nix/store/k3701zl6gmx3la7y4dnflcvf3xfy88kh-python3-3.11.9/bin'':'/':'}
PATH='/nix/store/k3701zl6gmx3la7y4dnflcvf3xfy88kh-python3-3.11.9/bin'$PATH
PATH=${PATH#':'}
PATH=${PATH%':'}
export PATH
export PYTHONNOUSERSITE='true'
exec -a "$0" "/nix/store/wn78z9b8lijylzy8znzmdj021z54iz6f-python3.11-esptool-4.6.2/bin/.esptool.py-wrapped"  "$@" 
danielemery commented 5 months ago

Just chiming in to say I am having the same issue

mksafavi commented 4 months ago

I think I found the problem. when you run esp_rfc2217_server.py it starts /nix/store/h5kainwxnc8slhhmd9kp2h82srjy0hyr-python3-3.11.9-env/bin/esp_rfc2217_server.py which is a wrapper around the python source that's here: /nix/store/h5kainwxnc8slhhmd9kp2h82srjy0hyr-python3-3.11.9-env/bin/.esp_rfc2217_server.py-wrapped.

in line 40 of .esp_rfc2217_server.py-wrapped it tries to import esptool.py:

from esptool.config import load_config_file
from esptool.reset import ClassicReset, CustomReset, DEFAULT_RESET_DELAY, UnixTightReset

but esptool.py is also a wrapper. the actual module is here .esptool.py-wrapped

I'm not sure if this is a byproduct of building esptool with buildPythonPackage instead of buildPythonApplication. But I'll try patching the .esp_rfc2217_server.py-wrapped imports to see if it works.