Let named_python work for pythonw or any other executable name.

This commit is contained in:
voussoir 2021-10-12 21:38:58 -07:00
parent e98cae6566
commit 39ac3b7ae6
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -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