X Tutup
Skip to content

Commit b1c23bc

Browse files
committed
move further pieces from env.bat to WinpythonIni.py
1 parent 1811311 commit b1c23bc

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

winpython/portable/launchers_final/scripts/WinPythonIni.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,31 @@ def translate(line, env):
6363

6464
def main():
6565
import sys
66-
args = sys.argv[1:]
67-
file_name = args[0] if args else "..\\settings\\winpython.ini"
66+
args = sys.argv[:]
67+
env = os.environ.copy() # later_version: env = os.environ
68+
my_lines = []
69+
# before env.ini
70+
# env.bat things transfered to WinpythonIni.py
71+
env["WINPYDIRBASE"] = WINPYDIRBASE = Path(env.get('WINPYDIRBASE', Path(__file__).parent.parent))
72+
my_lines += [f"WINPYDIRBASE={WINPYDIRBASE}"]
73+
env["WINPYDIR"] = WINPYDIR = Path(env.get('WINPYDIR', WINPYDIRBASE / env.get('WINPYthon_subdirectory_name', 'python')))
74+
my_lines += [f"WINPYDIR={WINPYDIR}"]
75+
if (WINPYDIR / "Lib" / "site-package" / "PyQt5" / "__init__.py").is_file():
76+
my_lines += ["QT_API=pyqt5"]
77+
if (PYPANDOC_PANDOC := WINPYDIRBASE / "t" / "pandoc.exe").is_file():
78+
my_lines += [f"PYPANDOC_PANDOC={PYPANDOC_PANDOC}"]
79+
80+
# theorical option: a "winpython.ini" file as an initial parameter
81+
if len(args) >=2 and args[1].endswith("winpython.ini"):
82+
file_name = args[1]
83+
args = args[1:]
84+
else:
85+
file_name = "..\\settings\\winpython.ini"
86+
# classic WinpythonIni.py actions: digesting winpython.ini file
87+
my_lines += get_file(file_name).splitlines()
6888

69-
my_lines = get_file(file_name).splitlines()
7089
segment = "environment"
7190
txt = ""
72-
env = os.environ.copy() # later_version: env = os.environ
7391

7492
# default directories (from .bat)
7593
os.makedirs(Path(env['WINPYDIRBASE']) / 'settings' / 'Appdata' / 'Roaming', exist_ok=True)

winpython/portable/launchers_final/scripts/env.bat

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,3 @@ if %ERRORLEVEL% NEQ 0 (
3434
cd .
3535
)
3636
set PATH_CLEANED=
37-
38-
rem force default pyqt5 kit for Spyder if PyQt5 module is there
39-
if exist "%WINPYDIR%\Lib\site-packages\PyQt5\__init__.py" set QT_API=pyqt5
40-
41-
rem modern Pandoc wheel need this
42-
if exist "%WINPYDIRBASE%\t\pandoc.exe" set PYPANDOC_PANDOC=%WINPYDIRBASE%\t\pandoc.exe
43-

0 commit comments

Comments
 (0)
X Tutup