X Tutup
Skip to content

Commit 1811311

Browse files
committed
move pieces of initialisation from env.bat to winpython.ini
1 parent 9feb7c6 commit 1811311

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

winpython/portable/launchers_final/scripts/WinPythonIni.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
winpython_inidefault=r'''
88
[debug]
99
state = disabled
10+
[env.bat]
11+
#PYTHONPATHz = %WINPYDIR%;%WINPYDIR%\Lib;%WINPYDIR%\DLLs
12+
#see https://github.com/winpython/winpython/issues/839
13+
#USERPROFILE = %HOME%
14+
#PYTHONUTF8=1 creates issues in "movable" patching
15+
SPYDER_CONFDIR = %HOME%\settings\.spyder-py3
16+
JUPYTER_DATA_DIR = %HOME%
17+
JUPYTER_CONFIG_DIR = %WINPYDIR%\etc\jupyter
18+
JUPYTER_CONFIG_PATH = %WINPYDIR%\etc\jupyter
1019
[inactive_environment_per_user]
1120
## <?> changing this segment to [active_environment_per_user] makes this segment of lines active or not
1221
HOME = %HOMEDRIVE%%HOMEPATH%\Documents\WinPython%WINPYVER%\settings
@@ -39,7 +48,7 @@ def get_file(file_name):
3948
with open(file_name, 'r') as file:
4049
return file.read()
4150
except FileNotFoundError:
42-
if file_name[-3:] == 'ini':
51+
if file_name.endswith("winpython.ini"):
4352
os.makedirs(Path(file_name).parent, exist_ok=True)
4453
with open(file_name, 'w') as file:
4554
file.write(winpython_inidefault)
@@ -77,19 +86,20 @@ def main():
7786
if not (p / 'qt.conf').is_file():
7887
with open(p / 'qt.conf', 'w') as file:
7988
file.write(qt_conf)
80-
89+
prefix , postfix = "set ", "&& "
90+
#prefix , postfix = "set ", "\n"
8191
for l in my_lines:
8292
if l.startswith("["):
8393
segment = l[1:].split("]")[0]
8494
elif not l.startswith("#") and "=" in l:
8595
data = l.split("=", 1)
8696
if segment == "debug" and data[0].strip() == "state":
8797
data[0] = "WINPYDEBUG"
88-
if segment in ["environment", "debug", "active_environment_per_user", "active_environment_common"]:
89-
txt += f"set {data[0].strip()}={translate(data[1].strip(), env)}&& "
98+
if segment in ["env.bat", "environment", "debug", "active_environment_per_user", "active_environment_common"]:
99+
txt += f"{prefix}{data[0].strip()}={translate(data[1].strip(), env)}{postfix}"
90100
env[data[0].strip()] = translate(data[1].strip(), env)
91101
if segment == "debug" and data[0].strip() == "state":
92-
txt += f"set WINPYDEBUG={data[1].strip()}&&"
102+
txt += f"{prefix}WINPYDEBUG={data[1].strip()}{postfix}"
93103

94104
print(txt)
95105

winpython/portable/launchers_final/scripts/env.bat

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,19 @@ if "%WINPYDIRBASE:~-1%"=="\" set WINPYDIRBASE=%WINPYDIRBASE:~0,-1%
1616
set WINPYDIRBASETMP=
1717
popd
1818

19-
set WINPYDIR=%WINPYDIRBASE%\%WINpython_subdirectory_name%
19+
set WINPYDIR=%WINPYDIRBASE%\%WINPYthon_subdirectory_name%
2020
rem 2019-08-25 pyjulia needs absolutely a variable PYTHON=%WINPYDIR%\python.exe
2121
set PYTHON=%WINPYDIR%\%WINpython_exe%
22-
set PYTHONPATHz=%WINPYDIR%;%WINPYDIR%\Lib;%WINPYDIR%\DLLs
23-
set WINPYVER=%WINPYVER%
2422

2523
rem 2023-02-12 utf-8 on console to avoid pip crash
2624
rem see https://github.com/pypa/pip/issues/11798#issuecomment-1427069681
2725
set PYTHONIOENCODING=utf-8
28-
rem set PYTHONUTF8=1 creates issues in "movable" patching
2926

3027
set HOME=%WINPYDIRBASE%\settings
31-
rem see https://github.com/winpython/winpython/issues/839
32-
rem set USERPROFILE=%HOME%
33-
set SPYDER_CONFDIR=%HOME%\settings\.spyder-py3
34-
set JUPYTER_DATA_DIR=%HOME%
35-
set JUPYTER_CONFIG_DIR=%WINPYDIR%\etc\jupyter
36-
set JUPYTER_CONFIG_PATH=%WINPYDIR%\etc\jupyter
37-
set FINDDIR=%WINDIR%\system32
3828

3929
rem Remove all double quotes
4030
set PATH_CLEANED=%PATH:"=%
41-
echo ";%PATH_CLEANED%;" | %FINDDIR%\find.exe /C /I ";%WINPYDIR%\;" >nul
31+
echo ";%PATH_CLEANED%;" | %WINDIR%\system32\find.exe /C /I ";%WINPYDIR%\;" >nul
4232
if %ERRORLEVEL% NEQ 0 (
4333
set "PATH=%WINPYDIR%\Lib\site-packages\PyQt5;%WINPYDIR%\;%WINPYDIR%\DLLs;%WINPYDIR%\Scripts;%WINPYDIR%\..\t;%WINPYDIR%\..\n;%PATH%"
4434
cd .

0 commit comments

Comments
 (0)
X Tutup