Skip to content

Commit 3c7a96f

Browse files
committed
improved icon launcher generators
1 parent b65973f commit 3c7a96f

File tree

4 files changed

+173
-89
lines changed

4 files changed

+173
-89
lines changed

make.py

Lines changed: 44 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ def updateExecutableIcon(executablePath, iconPath):
252252
win32api.EndUpdateResource(handle, False)
253253

254254

255-
def build_shimmy_launcher(launcher_name, command, icon_path, mkshim_program='mkshim240.py'):
256-
"""Build .exe launcher with mkshim.py and pywin32"""
255+
def build_shimmy_launcher(launcher_name, command, icon_path, mkshim_program='mkshim400.py'):
256+
"""Build .exe launcher with mkshim400.py and pywin32"""
257257

258258
# define where is mkshim
259259
mkshim_program = str(Path(__file__).resolve().parent / mkshim_program)
@@ -590,23 +590,25 @@ def create_launcher_shimmy(
590590
icon,
591591
command=None,
592592
args=None,
593-
workdir=r"$EXEDIR\scripts",
593+
workdir=r"", # not used, use $env:WINPYDIRICONS variable in command line
594+
mkshim_program="mkshim400.py", # to force another one
594595
):
595-
"""Create exe launcher with mkshim.py"""
596+
"""Create an exe launcher with mkshim.py"""
596597
assert name.endswith(".exe")
597598
portable_dir = str(Path(__file__).resolve().parent / "portable")
598599
icon_fname = str(Path(portable_dir) / "icons" / icon)
599600
assert Path(icon_fname).is_file()
600601

601602
# prepare mkshim.py script
603+
# $env:WINPYDIRICONS variable give the icons directory
602604
if command is None:
603605
if args is not None and ".pyw" in args:
604-
command = "${WINPYDIR}\pythonw.exe"
606+
command = "${WINPYDIR}\pythonw.exe" #not used
605607
else:
606-
command = "${WINPYDIR}\python.exe"
608+
command = "${WINPYDIR}\python.exe" #not used
607609
iconlauncherfullname= str(Path(self.winpydir) / name)
608610
true_command = command.replace(r"$SYSDIR\cmd.exe","cmd.exe")+ " " + args
609-
build_shimmy_launcher(iconlauncherfullname, true_command, icon_fname)
611+
build_shimmy_launcher(iconlauncherfullname, true_command, icon_fname, mkshim_program=mkshim_program)
610612

611613
def create_launcher(
612614
self,
@@ -819,97 +821,65 @@ def _create_launchers(self):
819821
self.create_launcher_shimmy(
820822
"WinPython Command Prompt.exe",
821823
"cmd.ico",
822-
#command="$SYSDIR\cmd.exe",
823-
#args=r"/k cmd.bat",
824-
command="scripts\\cmd.bat",
824+
command=".\\cmd.bat",
825825
args=r"",
826+
mkshim_program="mkshim400s.py",
826827
)
827-
828-
#self.create_launcher(
829-
# "WinPython Powershell Prompt.exe",
830-
# "powershell.ico",
831-
# command="$SYSDIR\cmd.exe",
832-
# args=r"/k cmd_ps.bat",
833-
#)
834828

835829
self.create_launcher_shimmy(
836830
"WinPython Powershell Prompt.exe",
837831
"powershell.ico",
838-
#command="$SYSDIR\cmd.exe",
839-
#args=r"/k scripts\\cmd_ps.bat",
840-
command="scripts\\cmd_ps.bat",
841-
args=r"",
832+
command="Powershell.exe",
833+
args=r"start-process -WindowStyle Hidden -FilePath ([dollar]ENV:WINPYDIRICONS + '\scripts\cmd_ps.bat')",
834+
#command="%WINPYDIRICONS%\\scripts\\cmd_ps.bat",
835+
#args=r"",
842836
)
843837

844-
#self.create_launcher(
838+
#self.create_launcher_shimmy(
845839
# "WinPython Terminal.exe",
846840
# "terminal.ico",
847-
# command="wscript.exe",
848-
# args=r"Noshell.vbs WinPython_Terminal.bat",
841+
# command="Powershell.exe",
842+
# args=r"start-process -WindowStyle Hidden './scripts/WinPython_Terminal.bat",
849843
#)
850844

851845
self.create_launcher_shimmy(
852846
"WinPython Interpreter.exe",
853847
"python.ico",
854-
#command="$SYSDIR\cmd.exe",
855-
#args=r"/k scripts\\winpython.bat",
856-
command="scripts\\winpython.bat",
848+
command=".\\winpython.bat",
857849
args=r"",
850+
mkshim_program="mkshim400s.py",
858851
)
859852

860-
#self.create_launcher(
861-
# "IDLE (Python GUI).exe",
862-
# "python.ico",
863-
# command="wscript.exe",
864-
# args=r"Noshell.vbs winidle.bat",
865-
#)
866-
867-
#dos window behind, but that disappear
868-
869853
self.create_launcher_shimmy(
870854
"IDLE (Python GUI).exe",
871855
"python.ico",
872856
command="Powershell.exe",
873-
args=r"start-process -WindowStyle Hidden './scripts/winidle.bat'",
857+
args=r"start-process -WindowStyle Hidden -FilePath ([dollar]ENV:WINPYDIRICONS + '\scripts\winidle.bat')",
874858
#command="scripts\\Noshell.vbs scripts\\winidle.bat",
875859
#args=r"",
876860
)
877861

878-
#self.create_launcher(
879-
# "Spyder.exe",
880-
# "spyder.ico",
881-
# command="wscript.exe",
882-
# args=r"Noshell.vbs winspyder.bat",
883-
#)
884-
885862
self.create_launcher_shimmy(
886863
"Spyder.exe",
887864
"spyder.ico",
888865
command="Powershell.exe",
889-
args=r"start-process -WindowStyle Hidden './scripts/winspyder.bat'",
866+
args=r"start-process -WindowStyle Hidden -FilePath ([dollar]ENV:WINPYDIRICONS + '\scripts\winspyder.bat')",
890867
)
891868

892-
#self.create_launcher(
893-
# "Spyder reset.exe",
894-
# "spyder_reset.ico",
895-
# command="wscript.exe",
896-
# args=r"scripts\\Noshell.vbs scripts\\spyder_reset.bat",
897-
#)
898-
899869
self.create_launcher_shimmy(
900870
"Spyder reset.exe",
901871
"spyder_reset.ico",
902872
command="Powershell.exe",
903-
args=r"start-process -WindowStyle Hidden './scripts/spyder_reset.bat",
873+
args=r"start-process -WindowStyle Hidden -FilePath ([dollar]ENV:WINPYDIRICONS + '\scripts\spyder_reset.bat')",
874+
#args=r"start-process -WindowStyle Hidden './scripts/spyder_reset.bat",
904875
)
905876

906877
self.create_launcher_shimmy(
907878
"WinPython Control Panel.exe",
908879
"winpython.ico",
909-
#command="$SYSDIR\cmd.exe",
910-
#args=r"/k scripts\\wpcp.bat",
911-
command="scripts\\wpcp.bat",
880+
command=".\\wpcp.bat",
912881
args=r"",
882+
mkshim_program="mkshim400s.py",
913883
)
914884

915885
# Jupyter launchers
@@ -918,41 +888,27 @@ def _create_launchers(self):
918888
self.create_launcher_shimmy(
919889
"Jupyter Notebook.exe",
920890
"jupyter.ico",
921-
#command="$SYSDIR\cmd.exe",
922-
#args=r"/k winipython_notebook.bat", # like VSCode + Rise way
923-
command="scripts\\winipython_notebook.bat",
891+
command="winipython_notebook.bat",
924892
args=r"",
893+
mkshim_program="mkshim400s.py",
925894
)
926895

927-
#self.create_launcher(
928-
# "Jupyter Lab.exe",
929-
# "jupyter.ico",
930-
# command="$SYSDIR\cmd.exe",
931-
# args=r"/k winjupyter_lab.bat",
932-
#)
933-
934896
self.create_launcher_shimmy(
935897
"Jupyter Lab.exe",
936898
"jupyter.ico",
937899
#command="$SYSDIR\cmd.exe",
938900
#args=r"/k winjupyter_lab.bat",
939-
command="scripts\\winjupyter_lab.bat",
901+
command="winjupyter_lab.bat",
940902
args=r"",
903+
mkshim_program="mkshim400s.py",
941904
)
942-
943-
# VSCode launcher
944-
#self.create_launcher_shimmy(
945-
# "VS Code.exe",
946-
# "code.ico",
947-
# command="wscript.exe",
948-
# args=r"scripts\\Noshell.vbs scripts\\winvscode.bat",
949-
#)
950905

951906
self.create_launcher_shimmy(
952907
"VS Code.exe",
953908
"code.ico",
954-
command="scripts\\winvscode.bat",
909+
command="winvscode.bat",
955910
args=r"",
911+
mkshim_program="mkshim400s.py",
956912
)
957913

958914
self._print_done()
@@ -1568,15 +1524,15 @@ def _create_batch_scripts(self):
15681524
self.create_batch_script(
15691525
"cmd.bat",
15701526
r"""@echo off
1571-
call "%~dp0env_for_icons.bat" %*
1527+
call "%~dp0env_for_icons.bat"
15721528
if not "%WINPYWORKDIR%"=="%WINPYWORKDIR1%" cd %WINPYWORKDIR1%
15731529
cmd.exe /k""",
15741530
)
15751531

15761532
self.create_batch_script(
15771533
"WinPython_Terminal.bat",
15781534
r"""@echo off
1579-
rem call "%~dp0env_for_icons.bat" %*
1535+
rem call "%~dp0env_for_icons.bat"
15801536
rem if not "%WINPYWORKDIR%"=="%WINPYWORKDIR1%" cd %WINPYWORKDIR1%
15811537
rem "%USERPROFILE%\AppData\Local\Microsoft\WindowsApps\wt.exe"
15821538
Powershell.exe -Command "& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy RemoteSigned -noexit -File ""%~dp0WinPython_PS_Prompt.ps1""'}"
@@ -1587,7 +1543,7 @@ def _create_batch_scripts(self):
15871543
self.create_batch_script(
15881544
"python.bat",
15891545
r"""@echo off
1590-
call "%~dp0env_for_icons.bat" %*
1546+
call "%~dp0env_for_icons.bat"
15911547
rem backward compatibility for python command-line users
15921548
if not "%WINPYWORKDIR%"=="%WINPYWORKDIR1%" cd %WINPYWORKDIR1%
15931549
"%WINPYDIR%\python.exe" %*
@@ -1598,7 +1554,7 @@ def _create_batch_scripts(self):
15981554
self.create_batch_script(
15991555
"winpython.bat",
16001556
r"""@echo off
1601-
call "%~dp0env_for_icons.bat" %*
1557+
call "%~dp0env_for_icons.bat"
16021558
cd/D "%WINPYWORKDIR1%"
16031559
rem backward compatibility for non-ptpython users
16041560
if exist "%WINPYDIR%\scripts\ptpython.exe" (
@@ -1613,7 +1569,7 @@ def _create_batch_scripts(self):
16131569
self.create_batch_script(
16141570
"winidle.bat",
16151571
r"""@echo off
1616-
call "%~dp0env_for_icons.bat" %*
1572+
call "%~dp0env_for_icons.bat"
16171573
cd/D "%WINPYWORKDIR1%"
16181574
"%WINPYDIR%\python.exe" "%WINPYDIR%\Lib\idlelib\idle.pyw" %*
16191575
""",
@@ -1623,7 +1579,7 @@ def _create_batch_scripts(self):
16231579
self.create_batch_script(
16241580
"winspyder.bat",
16251581
r"""@echo off
1626-
call "%~dp0env_for_icons.bat" %*
1582+
call "%~dp0env_for_icons.bat"
16271583
rem cd/D "%WINPYWORKDIR%"
16281584
if exist "%WINPYDIR%\scripts\spyder3.exe" (
16291585
"%WINPYDIR%\scripts\spyder3.exe" %* -w "%WINPYWORKDIR1%"
@@ -1636,7 +1592,7 @@ def _create_batch_scripts(self):
16361592
self.create_batch_script(
16371593
"spyder_reset.bat",
16381594
r"""@echo off
1639-
call "%~dp0env_for_icons.bat" %*
1595+
call "%~dp0env_for_icons.bat"
16401596
cd/D "%WINPYWORKDIR1%"
16411597
if exist "%WINPYDIR%\scripts\spyder3.exe" (
16421598
"%WINPYDIR%\scripts\spyder3.exe" --reset %*
@@ -1649,7 +1605,7 @@ def _create_batch_scripts(self):
16491605
self.create_batch_script(
16501606
"winipython_notebook.bat",
16511607
r"""@echo off
1652-
call "%~dp0env_for_icons.bat" %*
1608+
call "%~dp0env_for_icons.bat"
16531609
cd/D "%WINPYWORKDIR1%"
16541610
"%WINPYDIR%\scripts\jupyter-notebook.exe" %*
16551611
""",
@@ -1658,7 +1614,7 @@ def _create_batch_scripts(self):
16581614
self.create_batch_script(
16591615
"winjupyter_lab.bat",
16601616
r"""@echo off
1661-
call "%~dp0env_for_icons.bat" %*
1617+
call "%~dp0env_for_icons.bat"
16621618
cd/D "%WINPYWORKDIR1%"
16631619
"%WINPYDIR%\scripts\jupyter-lab.exe" %*
16641620
""",
@@ -1667,7 +1623,7 @@ def _create_batch_scripts(self):
16671623
self.create_batch_script(
16681624
"winqtconsole.bat",
16691625
r"""@echo off
1670-
call "%~dp0env_for_icons.bat" %*
1626+
call "%~dp0env_for_icons.bat"
16711627
cd/D "%WINPYWORKDIR1%"
16721628
"%WINPYDIR%\scripts\jupyter-qtconsole.exe" %*
16731629
""",
@@ -1702,7 +1658,7 @@ def _create_batch_scripts(self):
17021658
self.create_batch_script(
17031659
"wpcp.bat",
17041660
r"""@echo off
1705-
call "%~dp0env_for_icons.bat" %*
1661+
call "%~dp0env_for_icons.bat"
17061662
rem cd/D "%WINPYWORKDIR1%"
17071663
rem "%WINPYDIR%\python.exe" -m winpython.controlpanel %*
17081664
if not "%WINPYWORKDIR%"=="%WINPYWORKDIR1%" cd/d %WINPYWORKDIR1%
@@ -1736,7 +1692,7 @@ def _create_batch_scripts(self):
17361692
"winvscode.bat",
17371693
r"""@echo off
17381694
rem launcher for VScode
1739-
call "%~dp0env_for_icons.bat" %*
1695+
call "%~dp0env_for_icons.bat"
17401696
rem cd/D "%WINPYWORKDIR1%"
17411697
if exist "%WINPYDIR%\..\t\vscode\code.exe" (
17421698
"%WINPYDIR%\..\t\vscode\code.exe" %*

mkshim400.py

Lines changed: 64 additions & 0 deletions
Large diffs are not rendered by default.

mkshim400s.py

Lines changed: 64 additions & 0 deletions
Large diffs are not rendered by default.

winpython/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
OTHER DEALINGS IN THE SOFTWARE.
2929
"""
3030

31-
__version__ = '10.2.20240825'
31+
__version__ = '10.3.20240901'
3232
__license__ = __doc__
3333
__project_url__ = 'http://winpython.github.io/'

0 commit comments

Comments
 (0)