Replace named_python.bat with named_python.py.
This commit is contained in:
parent
af7fae6c44
commit
f245ca5eae
2 changed files with 30 additions and 12 deletions
|
@ -1,12 +0,0 @@
|
||||||
@echo off
|
|
||||||
|
|
||||||
rem Because Python is interpreted, when you look at the task manager process
|
|
||||||
rem list you'll see that every running python instance has the same name,
|
|
||||||
rem python.exe. This scripts helps you name the executables so they stand out.
|
|
||||||
rem For the time being this script doesn't automatically call your new exe,
|
|
||||||
rem you have to write a second command to actually run it. Batch doesn't have a
|
|
||||||
rem good way to pass "all arguments after %1" to the new program.
|
|
||||||
|
|
||||||
set real=C:\Python\__latest\python.exe
|
|
||||||
set named=C:\Python\__latest\python-%1.exe
|
|
||||||
if not exist %named% (mklink /h %named% %real%) else (echo %named%)
|
|
30
named_python.py
Normal file
30
named_python.py
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
'''
|
||||||
|
Because Python is interpreted, when you look at the task manager process list
|
||||||
|
you'll see that every running python instance has the same name, python.exe.
|
||||||
|
This scripts helps you name the executables so they stand out.
|
||||||
|
|
||||||
|
For the time being this script doesn't automatically call your new exe, you
|
||||||
|
have to write a second command to actually run it. I tried using
|
||||||
|
subprocess.Popen to spawn the new python with the rest of argv but the behavior
|
||||||
|
was different on Linux and Windows and neither was really clean.
|
||||||
|
'''
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from voussoirkit import pathclass
|
||||||
|
from voussoirkit import winwhich
|
||||||
|
|
||||||
|
def main(argv):
|
||||||
|
python = pathclass.Path(winwhich.which('python'))
|
||||||
|
|
||||||
|
name = argv[0].strip()
|
||||||
|
|
||||||
|
named_python = python.parent.with_child(f'python-{name}{python.extension.with_dot}')
|
||||||
|
if named_python.exists:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
os.link(python.absolute_path, named_python.absolute_path)
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
raise SystemExit(main(sys.argv[1:]))
|
Loading…
Reference in a new issue