Skip to content

Commit cbd5539

Browse files
committed
make scripts\scripts programs no more dynamically created
1 parent 412e1df commit cbd5539

File tree

4 files changed

+33
-37
lines changed

4 files changed

+33
-37
lines changed

make.py

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -249,18 +249,6 @@ def architecture_bits(self) -> int:
249249
return self.distribution.architecture
250250
return 64
251251

252-
@property
253-
def pre_path_entries(self) -> list[str]:
254-
"""Returns a list of PATH entries to prepend to the environment."""
255-
return [
256-
r"Lib\site-packages\PyQt5",
257-
"", # Python root directory
258-
"DLLs",
259-
"Scripts",
260-
r"..\t",
261-
rf"..\{self.NODEJS_RELATIVE_PATH}",
262-
]
263-
264252
def create_installer_7zip(self, installer_type: str = ".exe"):
265253
"""Creates a WinPython installer using 7-Zip: ".exe", ".7z", ".zip")"""
266254
self._print_action(f"Creating WinPython installer ({installer_type})")
@@ -324,24 +312,12 @@ def _create_initial_batch_scripts(self):
324312
"""Creates initial batch scripts, including environment setup."""
325313
self._print_action("Creating initial batch scripts")
326314

327-
path_entries_string = ";".join([rf"%WINPYDIR%\{path}" for path in self.pre_path_entries])
328-
full_path_environment_variable = f"{path_entries_string};%PATH%"
329-
330-
path_entries_powershell_string = ";".join([rf"$env:WINPYDIR\\{path}" for path in self.pre_path_entries])
331-
full_path_powershell_environment_variable = f"{path_entries_powershell_string};$env:path"
332-
333315
# Replacements for batch scripts (PyPy compatibility)
334316
executable_name = self.distribution.short_exe if self.distribution else "python.exe" # default to python.exe if distribution is not yet set
335317

336-
destination = self.winpython_directory / "scripts"
337-
for script_name in ('env.bat', 'WinPython_PS_Prompt.ps1'):
338-
destination_script_path = str(destination / script_name)
339-
print('destination_script_path:', destination_script_path)
340-
utils.patch_sourcefile(destination_script_path, 'python.exe', executable_name)
341-
utils.patch_sourcefile(destination_script_path, '{self.python_dir_name}', self.python_directory_name)
342-
utils.patch_sourcefile(destination_script_path, '{self.winpython_version_name}', self.winpython_version_name)
343-
utils.patch_sourcefile(destination_script_path, '{full_path_env_var}', full_path_environment_variable)
344-
utils.patch_sourcefile(destination_script_path, '{full_path_ps_env_var}', full_path_powershell_environment_variable)
318+
init_variables = [('WINPYthon_exe', executable_name), ('WINPYthon_subdirectory_name', self.python_directory_name), ('WINPYVER', self.winpython_version_name)]
319+
with open(self.winpython_directory / "scripts" / "env.ini", "w") as f:
320+
f.writelines([f'{a}={b}\n' for a , b in init_variables])
345321

346322
def build(self, rebuild: bool = True, requirements_files_list=None, winpy_dirname: str = None):
347323
"""Make or finalise WinPython distribution in the target directory"""

portable/scripts/WinPython_PS_Prompt.ps1

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
### WinPython_PS_Prompt.ps1 ###
22
$0 = $myInvocation.MyCommand.Definition
33
$dp0 = [System.IO.Path]::GetDirectoryName($0)
4+
5+
# default if env.cfg fails
6+
$env:WINPYthon_subdirectory_name = "python"
7+
$env:WINPYthon_exe = "python.exe"
8+
# Define the path to the config file
9+
Get-Content (${PSScriptRoot} +"\env.ini") | ForEach-Object {
10+
$parts = $_ -split '=', 2
11+
if ($parts.Count -eq 2) {
12+
Set-Variable -Name ($parts[0]).Trim() -Value $parts[1].Trim() -Scope Global
13+
}
14+
}
15+
416
# $env:PYTHONUTF8 = 1 would create issues in "movable" patching
517
$env:WINPYDIRBASE = "$dp0\.."
618
# get a normalize path
@@ -9,12 +21,12 @@ $env:WINPYDIRBASE = [System.IO.Path]::GetFullPath( $env:WINPYDIRBASE )
921

1022
# avoid double_init (will only resize screen)
1123
if (-not ($env:WINPYDIR -eq [System.IO.Path]::GetFullPath( $env:WINPYDIRBASE+"\{self.python_dir_name}")) ) {
12-
$env:WINPYDIR = $env:WINPYDIRBASE+"\{self.python_dir_name}"
24+
$env:WINPYDIR = $env:WINPYDIRBASE+ "\" +$env:WINPYthon_subdirectory_name
1325
# 2019-08-25 pyjulia needs absolutely a variable PYTHON=%WINPYDIR%python.exe
14-
$env:PYTHON = "%WINPYDIR%\python.exe"
26+
$env:PYTHON = $env:WINPYthon_exe
1527
$env:PYTHONPATHz = "%WINPYDIR%;%WINPYDIR%\Lib;%WINPYDIR%\DLLs"
1628

17-
$env:WINPYVER = '{self.winpython_version_name}'
29+
$env:WINPYVER = $env:WINPYVER
1830
# rem 2023-02-12 try utf-8 on console
1931
# rem see https://github.com/pypa/pip/issues/11798#issuecomment-1427069681
2032
$env:PYTHONIOENCODING = "utf-8"
@@ -28,7 +40,8 @@ $env:WINPYDIRBASE = ""
2840
$env:JUPYTER_DATA_DIR = "$env:HOME"
2941

3042
if (-not $env:PATH.ToLower().Contains(";"+ $env:WINPYDIR.ToLower()+ ";")) {
31-
$env:PATH = "{full_path_ps_env_var}" }
43+
$env:PATH = "$env:WINPYDIR\\Lib\site-packages\PyQt5;$env:WINPYDIR\\;$env:WINPYDIR\\DLLs;$env:WINPYDIR\\Scripts;$env:WINPYDIR\\..\t;$env:WINPYDIR\\..\n;$env:path" }
44+
3245

3346
#rem force default pyqt5 kit for Spyder if PyQt5 module is there
3447
if (Test-Path "$env:WINPYDIR\Lib\site-packages\PyQt5\__init__.py") { $env:QT_API = "pyqt5" }

portable/scripts/env.bat

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
@echo off
2+
3+
rem default if init fails
4+
set WINPYthon_subdirectory_name=python
5+
set WINPYthon_exe=python.exe
6+
rem read init variables
7+
FOR /F "usebackq tokens=1,2 delims==" %%G IN ("%~dp0env.ini") DO (set %%G=%%H)
8+
29
set WINPYDIRBASE=%~dp0..
310

411
rem get a normalized path
@@ -9,11 +16,11 @@ if "%WINPYDIRBASE:~-1%"=="\" set WINPYDIRBASE=%WINPYDIRBASE:~0,-1%
916
set WINPYDIRBASETMP=
1017
popd
1118

12-
set WINPYDIR=%WINPYDIRBASE%\{self.python_dir_name}
19+
set WINPYDIR=%WINPYDIRBASE%\%WINpython_subdirectory_name%
1320
rem 2019-08-25 pyjulia needs absolutely a variable PYTHON=%WINPYDIR%\python.exe
14-
set PYTHON=%WINPYDIR%\python.exe
21+
set PYTHON=%WINPYDIR%\%WINpython_exe%
1522
set PYTHONPATHz=%WINPYDIR%;%WINPYDIR%\Lib;%WINPYDIR%\DLLs
16-
set WINPYVER={self.winpython_version_name}
23+
set WINPYVER=%WINPYVER%
1724

1825
rem 2023-02-12 utf-8 on console to avoid pip crash
1926
rem see https://github.com/pypa/pip/issues/11798#issuecomment-1427069681
@@ -32,7 +39,7 @@ rem Remove all double quotes
3239
set PATH_CLEANED=%PATH:"=%
3340
echo ";%PATH_CLEANED%;" | %FINDDIR%\find.exe /C /I ";%WINPYDIR%\;" >nul
3441
if %ERRORLEVEL% NEQ 0 (
35-
set "PATH={full_path_env_var}"
42+
set "PATH=%WINPYDIR%\Lib\site-packages\PyQt5;%WINPYDIR%\;%WINPYDIR%\DLLs;%WINPYDIR%\Scripts;%WINPYDIR%\..\t;%WINPYDIR%\..\n;%PATH%"
3643
cd .
3744
)
3845
set PATH_CLEANED=

winpython/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-----------------------------------------
55
66
Copyright (c) 2012-2013 Pierre Raybaut
7-
Copyright (c) 2014-2024+ The Winpython development team https://github.com/winpython/
7+
Copyright (c) 2014-2025+ The Winpython development team https://github.com/winpython/
88
99
Permission is hereby granted, free of charge, to any person
1010
obtaining a copy of this software and associated documentation
@@ -28,6 +28,6 @@
2828
OTHER DEALINGS IN THE SOFTWARE.
2929
"""
3030

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

0 commit comments

Comments
 (0)