Skip to content
Snippets Groups Projects
Commit f9f54ff2 authored by Boris Basic's avatar Boris Basic
Browse files

Remove the batch files and use a newer version of the Python Launcher

parent b47ff796
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ set aed2=libaed2-1.2.0
set gotm=gotm-2019-06-14-opentelemac
set python_version=3.11.8
set python_launcher_version=3.11.8
set python=python-%python_version%
set python_requirements=python_requirements.txt
set geo_wheels_version=v2024.1.1
......@@ -213,27 +214,6 @@ call :write_pysource_bat gnu.static.debug
call :write_pysource_bat gnu.dynamic.debug
popd
rem Create a .bat for each .py file in the scripts\python3 directory
for %%f in (scripts\python3\*.py) do (
echo @echo off > scripts\%%~nf.py.bat
echo python %%~dp0\python3\%%~nf.py %%* >> scripts\%%~nf.py.bat
)
rem Patch stbtel_refine.py and stbtel_converter.py to ensure that the batch file
rem wrapping sbtel.py is called instead of the script itself
set temp_path=%path%
for %%a in ("%git_path%\..\..") do set "path=%%~fa\usr\bin;%path%"
if not %version% == main (
echo Patching stbtel_refine.py and stbtel_converter.py...
pushd scripts\python3\pretel
sed -i 's/stbtel_args\ =\ \[path_stbtel/stbtel_args\ =\ \["stbtel.py"/g' stbtel_refine.py
popd
pushd scripts\python3\data_manip\conversion
sed -i 's/stbtel_args\ =\ \[path_stbtel/stbtel_args\ =\ \["stbtel.py"/g' stbtel_converter.py
popd
)
set path=%temp_path%
rem Build TELEMAC for gnu.static
call configs\pysource.gnu.static.bat
call compile_telemac.py
......@@ -417,8 +397,16 @@ curl -L https://www.python.org/ftp/python/%python_version%/%python%-embed-amd64.
mkdir %python% 2>nul
tar -xvf python.zip -C %python% || goto install_python_error
del python.zip
rem Remove the _pth file
del %python%\python3*._pth
rem Download the Python launcher and install it in the current user's programs. Any launcher
rem installed in %LOCALAPPDATA%\Programs\Python\Launcher has priority over the launcher
rem installed in C:\Windows.
rem What's more, the launcher will not update an already installed and more recent version.
curl -OJL https://www.python.org/ftp/python/%python_launcher_version%/win32/launcher.msi
msiexec /i launcher.msi /quiet
del launcher.msi
rem Ensure .py files are properly opened with the Python Launcher
call :restore_py_launcher
rem Download Python dev.msi package to get Python include folder, required by F2PY
curl -OJL https://www.python.org/ftp/python/%python_version%/amd64/dev.msi
......@@ -428,6 +416,13 @@ cd %python%
rd /s/q libs
del dev.msi
rem Remove the _pth file
del python3*._pth
rem Copy python.exe to python3.exe to ensure the proper execution of TELEMAC
rem scripts having the shebang form #!/usr/bin/env python3
copy /y python.exe python3.exe
rem Create the import library for the Python dll, required by F2PY
mkdir libs 2>nul
for /f "tokens=1,2 delims=." %%a in ("%python_version%") do set python_lib=python%%a%%b
......@@ -615,8 +610,8 @@ echo set PATH=%mingw_path%;%%PATH%%>> %file_name%
echo:>> %file_name%
echo rem Add TELEMAC binaries directory to PATH>> %file_name%
echo set PATH=%%HOMETEL%%\builds\%%USETELCFG%%\lib;%%PATH%%>> %file_name%
echo rem Add TELEMAC scripts folder to PATH>> %file_name%
echo set PATH=%%HOMETEL%%\scripts;%%PATH%%>> %file_name%
echo rem Add TELEMAC Python scripts folder to PATH>> %file_name%
echo set PATH=%%HOMETEL%%\scripts\python3;%%PATH%%>> %file_name%
echo rem Add TELEMAC Python scripts to PYTHONPATH>> %file_name%
echo set PYTHONPATH=%%HOMETEL%%\scripts\python3;%%PYTHONPATH%%>> %file_name%
echo set PYTHONPATH=%%HOMETEL%%\builds\%%USETELCFG%%\wrap_api\lib;%%PYTHONPATH%%>> %file_name%
......@@ -642,4 +637,50 @@ echo rem AED>> %file_name%
echo set AEDHOME=%%EXTERNAL%%\%aed2%>> %file_name%
echo rem GOTM>> %file_name%
echo set GOTMHOME=%%EXTERNAL%%\%gotm%>> %file_name%
echo set PATH=%%GOTMHOME%%\bin;%%PATH%%>> %file_name%
\ No newline at end of file
echo set PATH=%%GOTMHOME%%\bin;%%PATH%%>> %file_name%
rem *******************************************************************************
rem Generate a .reg file to reset Python files association with the Python Launcher
rem *******************************************************************************
:restore_py_launcher
set file_name=reset_py.reg
echo Windows Registry Editor Version 5.00> %file_name%
echo:>> %file_name%
echo [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py]>> %file_name%
echo:>> %file_name%
echo [-HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py\OpenWithList]>> %file_name%
echo [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py\OpenWithList]>> %file_name%
echo:>> %file_name%
echo [-HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py\OpenWithProgids]>> %file_name%
echo [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py\OpenWithProgids]>> %file_name%
echo "Python.File"=hex(0):>> %file_name%
echo:>> %file_name%
echo [-HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py\UserChoice]>> %file_name%
echo:>> %file_name%
echo [-HKEY_CURRENT_USER\SOFTWARE\Classes\.py]>> %file_name%
echo [HKEY_CURRENT_USER\SOFTWARE\Classes\.py]>> %file_name%
echo @="Python.File">> %file_name%
echo "Content Type"="text/x-python">> %file_name%
echo:>> %file_name%
echo [-HKEY_CURRENT_USER\SOFTWARE\Classes\py_auto_file]>> %file_name%
echo:>> %file_name%
echo [-HKEY_CURRENT_USER\SOFTWARE\Classes\Python.File]>> %file_name%
echo [HKEY_CURRENT_USER\SOFTWARE\Classes\Python.File]>> %file_name%
echo @="Python File">> %file_name%
echo:>> %file_name%
echo [HKEY_CURRENT_USER\SOFTWARE\Classes\Python.File\DefaultIcon]>> %file_name%
echo @="\"C:\\Users\\%username%\\AppData\\Local\\Programs\\Python\\Launcher\\py.exe\",1">> %file_name%
echo:>> %file_name%
echo [HKEY_CURRENT_USER\SOFTWARE\Classes\Python.File\shell]>> %file_name%
echo:>> %file_name%
echo [HKEY_CURRENT_USER\SOFTWARE\Classes\Python.File\shell\open]>> %file_name%
echo:>> %file_name%
echo [HKEY_CURRENT_USER\SOFTWARE\Classes\Python.File\shell\open\command]>> %file_name%
echo @="\"C:\\Users\\%username%\\AppData\\Local\\Programs\\Python\\Launcher\\py.exe\" \"%%L\" %%*">> %file_name%
echo:>> %file_name%
echo [HKEY_CURRENT_USER\SOFTWARE\Classes\Python.File\shellex]>> %file_name%
echo:>> %file_name%
echo [HKEY_CURRENT_USER\SOFTWARE\Classes\Python.File\shellex\DropHandler]>> %file_name%
echo @="{BEA218D2-6950-497B-9434-61683EC065FE}">> %file_name%
reg import reset_py.reg
del reset_py.reg
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment