Repository navigation
Expand file tree
/
Copy pathstart_osgeo_py3-env_keep-path.bat
More file actions
54 lines (51 loc) · 2.02 KB
/
Copy pathstart_osgeo_py3-env_keep-path.bat
File metadata and controls
54 lines (51 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
@ECHO OFF
setlocal EnableDelayedExpansion
rem ---------------------
rem Configure these paths
if exist "C:\OSGeo4W64\" (
set target_path="C:\OSGeo4W64\bin\o4w_env.bat"
set "try_py3_env=true"
) else if exist "C:\OSGeo4W32\" (
set target_path="C:\OSGeo4W32\bin\o4w_env.bat"
set "try_py3_env=true"
) else (
set target_path="C:\OSGeo4W\bin\o4w_env.bat"
set "try_py3_env=false"
)
rem ---------------------
if "%~1" == "" (
set run_mode=shell
) else (
set run_mode=pyscript
set pyscript=%~1
echo !pyscript! | findstr /r "^.*\\CLIP\\[^\\]*.*\.py" > nul
if "!errorlevel!" == "0" (
set SHELL_UTILS_START_PYSCRIPT_KEEP_OPEN=false
)
)
if not exist %target_path% (
title ERROR
cmd /k "echo Target does not exist: %target_path%&echo.&echo Configure paths in this script: %0"
) else if "%try_py3_env%" == "true" (
title OSGeo4W Shell [py3_env]
if "%run_mode%" == "shell" (
call %target_path% & cmd /k "@ECHO OFF&set PATH=%%PATH%%;%PATH%;&py3_env&@ECHO ON&echo 'py3_env' has been loaded. 'python' and 'python3' commands should now use the Python3 environment.&echo run o-help for a list of available commands"
) else if "%run_mode%" == "pyscript" (
if "%SHELL_UTILS_START_PYSCRIPT_KEEP_OPEN%" == "true" (
call %target_path% & cmd /k "@ECHO OFF&set PATH=%%PATH%%;%PATH%;&py3_env&@ECHO ON&python %*"
) else (
call %target_path% & cmd /c "@ECHO OFF&set PATH=%%PATH%%;%PATH%;&py3_env&@ECHO ON&python %*"
)
)
) else (
title OSGeo4W Shell [o4w_env]
if "%run_mode%" == "shell" (
call %target_path% & cmd /k "@ECHO OFF&set PATH=%%PATH%%;%PATH%;&@ECHO ON&echo run o-help for a list of available commands"
) else if "%run_mode%" == "pyscript" (
if "%SHELL_UTILS_START_PYSCRIPT_KEEP_OPEN%" == "true" (
call %target_path% & cmd /k "@ECHO OFF&set PATH=%%PATH%%;%PATH%;&@ECHO ON&python %*"
) else (
call %target_path% & cmd /c "@ECHO OFF&set PATH=%%PATH%%;%PATH%;&@ECHO ON&python %*"
)
)
)