File tree Expand file tree Collapse file tree 1 file changed +62
-0
lines changed Expand file tree Collapse file tree 1 file changed +62
-0
lines changed Original file line number Diff line number Diff line change
1
+ @ echo off
2
+
3
+ if not defined PYTHON (set PYTHON=python)
4
+ if not defined VENV_DIR (set VENV_DIR=venv)
5
+
6
+ set ERROR_REPORTING = FALSE
7
+
8
+ mkdir tmp 2 > NUL
9
+
10
+ %PYTHON% -c " " > tmp/stdout.txt 2 > tmp/stderr.txt
11
+ if %ERRORLEVEL% == 0 goto :start_venv
12
+ echo Couldn't launch python
13
+ goto :show_stdout_stderr
14
+
15
+ :start_venv
16
+ if [%VENV_DIR% ] == [-] goto :skip_venv
17
+
18
+ dir %VENV_DIR% \Scripts\Python.exe > tmp/stdout.txt 2 > tmp/stderr.txt
19
+ if %ERRORLEVEL% == 0 goto :activate_venv
20
+
21
+ for /f " delims=" %%i in ('CALL %PYTHON% -c " import sys; print(sys.executable)" ') do set PYTHON_FULLNAME = " %%i "
22
+ echo Creating venv in directory %VENV_DIR% using python %PYTHON_FULLNAME%
23
+ %PYTHON_FULLNAME% -m venv %VENV_DIR% > tmp/stdout.txt 2 > tmp/stderr.txt
24
+ if %ERRORLEVEL% == 0 goto :activate_venv
25
+ echo Unable to create venv in directory %VENV_DIR%
26
+ goto :show_stdout_stderr
27
+
28
+ :activate_venv
29
+ set PYTHON = " %~dp0 %VENV_DIR% \Scripts\Python.exe"
30
+ echo venv %PYTHON%
31
+ goto :launch
32
+
33
+ :skip_venv
34
+
35
+ :launch
36
+ %PYTHON% launch.py %*
37
+ pause
38
+ exit /b
39
+
40
+ :show_stdout_stderr
41
+
42
+ echo .
43
+ echo exit code: %errorlevel%
44
+
45
+ for /f %%i in (" tmp\stdout.txt" ) do set size = %%~zi
46
+ if %size% equ 0 goto :show_stderr
47
+ echo .
48
+ echo stdout:
49
+ type tmp\stdout.txt
50
+
51
+ :show_stderr
52
+ for /f %%i in (" tmp\stderr.txt" ) do set size = %%~zi
53
+ if %size% equ 0 goto :show_stderr
54
+ echo .
55
+ echo stderr:
56
+ type tmp\stderr.txt
57
+
58
+ :endofscript
59
+
60
+ echo .
61
+ echo Launch unsuccessful. Exiting.
62
+ pause
You can’t perform that action at this time.
0 commit comments