Skip to content

Commit

Permalink
bugfix: Adjust wrapper scripts to not import themselves
Browse files Browse the repository at this point in the history
  • Loading branch information
radimkarnis committed May 22, 2023
1 parent 54bbf62 commit a7df5d3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
9 changes: 6 additions & 3 deletions espefuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
# Linux/macOS: remove current script directory to avoid importing this file
# as a module; we want to import the installed espefuse module instead
with contextlib.suppress(ValueError):
if sys.path[0].endswith("/bin"):
sys.path.pop(0)
sys.path.remove(os.path.dirname(sys.executable))
executable_dir = os.path.dirname(sys.executable)
sys.path = [
path
for path in sys.path
if not path.endswith(("/bin", "/sbin")) and path != executable_dir
]

# Linux/macOS: delete imported module entry to force Python to load
# the module from scratch; this enables importing espefuse module in
Expand Down
9 changes: 6 additions & 3 deletions espsecure.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
# Linux/macOS: remove current script directory to avoid importing this file
# as a module; we want to import the installed espsecure module instead
with contextlib.suppress(ValueError):
if sys.path[0].endswith("/bin"):
sys.path.pop(0)
sys.path.remove(os.path.dirname(sys.executable))
executable_dir = os.path.dirname(sys.executable)
sys.path = [
path
for path in sys.path
if not path.endswith(("/bin", "/sbin")) and path != executable_dir
]

# Linux/macOS: delete imported module entry to force Python to load
# the module from scratch; this enables importing espsecure module in
Expand Down
9 changes: 6 additions & 3 deletions esptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
# Linux/macOS: remove current script directory to avoid importing this file
# as a module; we want to import the installed esptool module instead
with contextlib.suppress(ValueError):
if sys.path[0].endswith("/bin"):
sys.path.pop(0)
sys.path.remove(os.path.dirname(sys.executable))
executable_dir = os.path.dirname(sys.executable)
sys.path = [
path
for path in sys.path
if not path.endswith(("/bin", "/sbin")) and path != executable_dir
]

# Linux/macOS: delete imported module entry to force Python to load
# the module from scratch; this enables importing esptool module in
Expand Down

0 comments on commit a7df5d3

Please sign in to comment.