-
Notifications
You must be signed in to change notification settings - Fork 15
/
setup.bat
140 lines (116 loc) · 2.8 KB
/
setup.bat
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
@echo off
title Initial LTS Setup
echo Initial LTS Setup
echo -------------------
echo.
::
:: Confirmation
::
if exist "runtime\bin\python\python.exe" (
call :areyousurepython
) else (
call :areyousure
)
goto :end
::
:: Methods
::
rem Ask user confirmation.
:areyousure
echo ^> Are you sure you want to run the setup? [y/N]?
set /p answer=": "
if /I "%answer%" EQU "Y" goto :start
exit /b
:areyousurepython
echo ^> Input 's' if you want to only copy the .bat files.
echo ^> Input 'c' if you want to use a custom python command.
echo ^> Input 'i' if you want to use a custom python command and only copy the .bat files.
echo ^> Are you sure you want to run the setup? [y/N/s/c/i]?
set /p answer=": "
if /I "%answer%" EQU "Y" call :start
if /I "%answer%" EQU "S" call :scriptsonly
if /I "%answer%" EQU "C" call :setpython
if /I "%answer%" EQU "I" call :setpythonscriptsonly
exit /b
rem Download function
rem Arguments:
rem URL, Output file
rem URL: a http(s) link
rem Output file: A path that will be output for the downloaded file
:download
runtime\bin\wget.exe -q -O %2 %1
exit /b
rem Unzip function
rem Arguments:
rem archive path, output path
rem archive path: Path to the archive
rem output path: Output folder
:unzip
runtime\bin\7z.exe x -y -o%2 %1 >>nul
exit /b
:scriptsonly
echo.
echo ^> Setting up LTS workspace...
if "%~1" == "" (
runtime\bin\python\python runtime\setuplts.py scriptsonly
} else (
echo ! Running custom python command! Some things may not work correctly!
"%~1" runtime\setuplts.py scriptsonly "%~1"
)
exit /b
:start
::
:: Download runtimes
::
echo.
echo ^> Downloading runtimes...
:: Python 3.6.1
if "%~1" == "" (
echo ^> Python 3.6.1 embeddable zip.
if exist "runtime\bin\python\python.exe" (
echo ^> Skipping Python. Already exists.
) else (
call :download https://www.python.org/ftp/python/3.6.1/python-3.6.1-embed-win32.zip runtime\bin\python.zip
)
)
::
:: Unzipping natives
::
echo.
echo ^> Unzipping runtimes...
:: Python 3.6.1
if "%~1" == "" (
echo ^> python.zip
if exist "runtime\bin\python\python.exe" (
echo ^> Skipping Python. Already exists.
) else (
call :unzip runtime\bin\python.zip runtime\bin\python
del runtime\bin\python.zip
)
)
::
:: Setup LTS workspace
::
echo.
echo ^> Setting up LTS workspace...
if "%~1" == "" (
runtime\bin\python\python runtime\setuplts.py
) else (
echo ! Running custom python command! Some things may not work correctly!
"%~1" runtime\setuplts.py "%~1"
)
exit /b
:setpython
echo Enter the path to your desired python install.
set /p answer=": "
call :start "%answer%"
exit /b
:setpythonscriptsonly
echo Enter the path to your desired python install.
set /p answer=": "
call :scriptsonly "%answer%"
exit /b
:end
echo.
echo Finished!
pause