From 1c81db1a573b930f80df176ef3012b6159e0598a Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sun, 27 May 2018 04:43:00 +0200 Subject: menuconfig: Prepare for packaging setuptools' 'entry_points' gives nice behavior on Windows. It requires that the module has an entry point function. Create one and move the command line argument handling to it. --- menuconfig.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/menuconfig.py b/menuconfig.py index 5332b08..15a8539 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -278,6 +278,16 @@ _expr_str_orig = kconfiglib.expr_str kconfiglib.expr_str = _expr_str_val _expr_str = _expr_str_val +# Entry point when run as an executable, split out so that setuptools' +# 'entry_points' can be used. It produces a handy menuconfig.exe launcher on +# Windows. +def _main(): + if len(sys.argv) > 2: + print("usage: {} [Kconfig]".format(sys.argv[0]), file=sys.stderr) + sys.exit(1) + + menuconfig(Kconfig("Kconfig" if len(sys.argv) < 2 else sys.argv[1])) + def menuconfig(kconf): """ Launches the configuration interface, returning after the user exits. @@ -2414,8 +2424,4 @@ def _convert_c_lc_ctype_to_utf8(): _IS_WINDOWS = (platform.system() == "Windows") if __name__ == "__main__": - if len(sys.argv) > 2: - print("usage: {} [Kconfig]".format(sys.argv[0]), file=sys.stderr) - sys.exit(1) - - menuconfig(Kconfig("Kconfig" if len(sys.argv) < 2 else sys.argv[1])) + _main() -- cgit v1.2.3