forked from Azure/batch-shipyard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.cmd
82 lines (75 loc) · 2.34 KB
/
install.cmd
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
@echo off
REM check for argument
IF [%1] EQU [] (
echo Usage: install.cmd [virtual env name] [optional: path to python.exe]
exit /b 1
)
IF %~1 == shipyard.cmd (
echo "shipyard.cmd" cannot be specified as the virtual environment name.
exit /b 1
)
SET VENVNAME=%~1
REM set python to use
IF [%2] NEQ [] (
SET PYTHON=%~2
) ELSE (
FOR /f %%i in ('where python.exe') do SET PYTHON="%%i"
)
IF NOT DEFINED PYTHON (
echo Python not found. Please ensure python.exe is in your PATH.
exit /b 1
)
echo Using python from %PYTHON%
REM check that shipyard.py is in cwd
SET SHIPYARDFILE="%cd%\shipyard.py"
IF NOT EXIST %SHIPYARDFILE% (
echo shipyard.py does not exist in current working directory. Please run installer from Batch Shipyard root.
exit /b 1
)
REM check for anaconda
%PYTHON% -c "from __future__ import print_function; import sys; print(sys.version)" > .pyver.txt
SET /P PYTHONVER=<.pyver.txt
del .pyver.txt
SET ANACONDA=0
IF NOT "%PYTHONVER%"=="%PYTHONVER:anaconda=%" (
echo Anaconda detected.
SET ANACONDA=1
)
IF NOT "%PYTHONVER%"=="%PYTHONVER:continuum=%" (
echo Anaconda detected.
SET ANACONDA=1
)
IF NOT "%PYTHONVER%"=="%PYTHONVER:conda-forge=%" (
echo Anaconda detected.
SET ANACONDA=1
)
REM install env and requirements
IF %ANACONDA% EQU 1 (
echo Performing install for Anaconda.
conda create --yes --name %VENVNAME%
cmd.exe /c "activate %VENVNAME% & conda install --yes pip & pip install --upgrade -r requirements.txt & deactivate %VENVNAME%"
) ELSE (
echo Performing install for Python.
pip install --upgrade virtualenv
IF ERRORLEVEL 1 (
echo "pip install virtualenv failed"
exit /b 1
)
virtualenv -p %PYTHON% %VENVNAME%
call "%VENVNAME%\Scripts\activate.bat"
pip uninstall -y azure-storage
pip install --upgrade -r requirements.txt
pip install --upgrade --no-deps -r req_nodeps.txt
call "%VENVNAME%\Scripts\deactivate.bat"
)
REM create launcher cmd
SET CMDFILE=shipyard.cmd
(echo @echo off) > %CMDFILE%
IF %ANACONDA% EQU 1 (
(echo activate %VENVNAME% ^& python %SHIPYARDFILE% %%* ^& deactivate %VENVNAME%) >> %CMDFILE%
) ELSE (
echo call "%cd%\%VENVNAME%\Scripts\activate.bat" >> %CMDFILE%
echo python %SHIPYARDFILE% %%* >> %CMDFILE%
echo deactivate >> %CMDFILE%
)
echo Installation complete. Run Batch Shipyard as: %cd%\shipyard.cmd