From 39ac3b7ae653004d7071692e3355664a1131752a Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Tue, 12 Oct 2021 21:38:58 -0700 Subject: [PATCH] Let named_python work for pythonw or any other executable name. --- named_python.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/named_python.py b/named_python.py index f537e99..d3d01e2 100644 --- a/named_python.py +++ b/named_python.py @@ -26,15 +26,16 @@ from voussoirkit import pathclass from voussoirkit import winwhich def namedpython_argparse(args): - python = pathclass.Path(sys.executable) + this_python = pathclass.Path(sys.executable) + base = this_python.replace_extension('').basename.split('-', 1)[0] name = args.name.strip() - - named_python = python.parent.with_child(f'python-{name}{python.extension.with_dot}') + extension = this_python.extension.with_dot + named_python = this_python.parent.with_child(f'{base}-{name}{extension}') if named_python.exists: return 0 - os.link(python.absolute_path, named_python.absolute_path) + os.link(this_python.absolute_path, named_python.absolute_path) print(named_python.absolute_path) return 0