Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 3 additions & 27 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,6 @@ def architecture_bits(self) -> int:
return self.distribution.architecture
return 64

@property
def pre_path_entries(self) -> list[str]:
"""Returns a list of PATH entries to prepend to the environment."""
return [
r"Lib\site-packages\PyQt5",
"", # Python root directory
"DLLs",
"Scripts",
r"..\t",
rf"..\{self.NODEJS_RELATIVE_PATH}",
]

def create_installer_7zip(self, installer_type: str = ".exe"):
"""Creates a WinPython installer using 7-Zip: ".exe", ".7z", ".zip")"""
self._print_action(f"Creating WinPython installer ({installer_type})")
Expand Down Expand Up @@ -324,24 +312,12 @@ def _create_initial_batch_scripts(self):
"""Creates initial batch scripts, including environment setup."""
self._print_action("Creating initial batch scripts")

path_entries_string = ";".join([rf"%WINPYDIR%\{path}" for path in self.pre_path_entries])
full_path_environment_variable = f"{path_entries_string};%PATH%"

path_entries_powershell_string = ";".join([rf"$env:WINPYDIR\\{path}" for path in self.pre_path_entries])
full_path_powershell_environment_variable = f"{path_entries_powershell_string};$env:path"

# Replacements for batch scripts (PyPy compatibility)
executable_name = self.distribution.short_exe if self.distribution else "python.exe" # default to python.exe if distribution is not yet set

destination = self.winpython_directory / "scripts"
for script_name in ('env.bat', 'WinPython_PS_Prompt.ps1'):
destination_script_path = str(destination / script_name)
print('destination_script_path:', destination_script_path)
utils.patch_sourcefile(destination_script_path, 'python.exe', executable_name)
utils.patch_sourcefile(destination_script_path, '{self.python_dir_name}', self.python_directory_name)
utils.patch_sourcefile(destination_script_path, '{self.winpython_version_name}', self.winpython_version_name)
utils.patch_sourcefile(destination_script_path, '{full_path_env_var}', full_path_environment_variable)
utils.patch_sourcefile(destination_script_path, '{full_path_ps_env_var}', full_path_powershell_environment_variable)
init_variables = [('WINPYthon_exe', executable_name), ('WINPYthon_subdirectory_name', self.python_directory_name), ('WINPYVER', self.winpython_version_name)]
with open(self.winpython_directory / "scripts" / "env.ini", "w") as f:
f.writelines([f'{a}={b}\n' for a , b in init_variables])

def build(self, rebuild: bool = True, requirements_files_list=None, winpy_dirname: str = None):
"""Make or finalise WinPython distribution in the target directory"""
Expand Down
21 changes: 17 additions & 4 deletions portable/scripts/WinPython_PS_Prompt.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
### WinPython_PS_Prompt.ps1 ###
$0 = $myInvocation.MyCommand.Definition
$dp0 = [System.IO.Path]::GetDirectoryName($0)

# default if env.cfg fails
$env:WINPYthon_subdirectory_name = "python"
$env:WINPYthon_exe = "python.exe"
# Define the path to the config file
Get-Content (${PSScriptRoot} +"\env.ini") | ForEach-Object {
$parts = $_ -split '=', 2
if ($parts.Count -eq 2) {
Set-Variable -Name ($parts[0]).Trim() -Value $parts[1].Trim() -Scope Global
}
}

# $env:PYTHONUTF8 = 1 would create issues in "movable" patching
$env:WINPYDIRBASE = "$dp0\.."
# get a normalize path
Expand All @@ -9,12 +21,12 @@ $env:WINPYDIRBASE = [System.IO.Path]::GetFullPath( $env:WINPYDIRBASE )

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

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

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


#rem force default pyqt5 kit for Spyder if PyQt5 module is there
if (Test-Path "$env:WINPYDIR\Lib\site-packages\PyQt5\__init__.py") { $env:QT_API = "pyqt5" }
Expand Down
15 changes: 11 additions & 4 deletions portable/scripts/env.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
@echo off

rem default if init fails
set WINPYthon_subdirectory_name=python
set WINPYthon_exe=python.exe
rem read init variables
FOR /F "usebackq tokens=1,2 delims==" %%G IN ("%~dp0env.ini") DO (set %%G=%%H)

set WINPYDIRBASE=%~dp0..

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

set WINPYDIR=%WINPYDIRBASE%\{self.python_dir_name}
set WINPYDIR=%WINPYDIRBASE%\%WINpython_subdirectory_name%
rem 2019-08-25 pyjulia needs absolutely a variable PYTHON=%WINPYDIR%\python.exe
set PYTHON=%WINPYDIR%\python.exe
set PYTHON=%WINPYDIR%\%WINpython_exe%
set PYTHONPATHz=%WINPYDIR%;%WINPYDIR%\Lib;%WINPYDIR%\DLLs
set WINPYVER={self.winpython_version_name}
set WINPYVER=%WINPYVER%

rem 2023-02-12 utf-8 on console to avoid pip crash
rem see https://github.com/pypa/pip/issues/11798#issuecomment-1427069681
Expand All @@ -32,7 +39,7 @@ rem Remove all double quotes
set PATH_CLEANED=%PATH:"=%
echo ";%PATH_CLEANED%;" | %FINDDIR%\find.exe /C /I ";%WINPYDIR%\;" >nul
if %ERRORLEVEL% NEQ 0 (
set "PATH={full_path_env_var}"
set "PATH=%WINPYDIR%\Lib\site-packages\PyQt5;%WINPYDIR%\;%WINPYDIR%\DLLs;%WINPYDIR%\Scripts;%WINPYDIR%\..\t;%WINPYDIR%\..\n;%PATH%"
cd .
)
set PATH_CLEANED=
Expand Down
4 changes: 2 additions & 2 deletions winpython/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-----------------------------------------

Copyright (c) 2012-2013 Pierre Raybaut
Copyright (c) 2014-2024+ The Winpython development team https://github.com/winpython/
Copyright (c) 2014-2025+ The Winpython development team https://github.com/winpython/

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
Expand All @@ -28,6 +28,6 @@
OTHER DEALINGS IN THE SOFTWARE.
"""

__version__ = '14.0.20250321'
__version__ = '15.0.20250330'
__license__ = __doc__
__project_url__ = 'http://winpython.github.io/'