1#!/usr/bin/env python
2#
3# SPDX-FileCopyrightText: 2014-2022 Fredrik Ahlberg, Angus Gratton,
4# Espressif Systems (Shanghai) CO LTD, other contributors as noted.
5#
6# SPDX-License-Identifier: GPL-2.0-or-later
7
8# This executable script is a thin wrapper around the main functionality
9# in the espefuse Python package
10
11# When updating this script, please also update esptool.py and espsecure.py
12
13import contextlib
14import os
15import sys
16
17if os.name != "nt":
18    # Linux/macOS: remove current script directory to avoid importing this file
19    # as a module; we want to import the installed espefuse module instead
20    with contextlib.suppress(ValueError):
21        if sys.path[0].endswith("/bin"):
22            sys.path.pop(0)
23        sys.path.remove(os.path.dirname(sys.executable))
24
25    # Linux/macOS: delete imported module entry to force Python to load
26    # the module from scratch; this enables importing espefuse module in
27    # other Python scripts
28    with contextlib.suppress(KeyError):
29        del sys.modules["espefuse"]
30
31import espefuse
32
33if __name__ == "__main__":
34    espefuse._main()
35