2017-04-01 07:57:41 +03:00
|
|
|
@echo off
|
|
|
|
|
|
|
|
REM check for argument
|
|
|
|
IF [%1] EQU [] (
|
2018-10-29 18:58:55 +03:00
|
|
|
echo Usage: install.cmd [virtual env name] [optional: path to python.exe]
|
|
|
|
exit /b 1
|
2017-04-01 07:57:41 +03:00
|
|
|
)
|
|
|
|
IF %~1 == shipyard.cmd (
|
2018-10-29 18:58:55 +03:00
|
|
|
echo "shipyard.cmd" cannot be specified as the virtual environment name.
|
|
|
|
exit /b 1
|
2017-04-01 07:57:41 +03:00
|
|
|
)
|
|
|
|
SET VENVNAME=%~1
|
|
|
|
|
2017-11-10 19:27:48 +03:00
|
|
|
REM set python to use
|
|
|
|
IF [%2] NEQ [] (
|
2018-10-29 18:58:55 +03:00
|
|
|
SET PYTHON=%~2
|
2017-11-10 19:27:48 +03:00
|
|
|
) ELSE (
|
2018-10-29 18:58:55 +03:00
|
|
|
FOR /f %%i in ('where python.exe') do SET PYTHON="%%i"
|
2017-04-01 07:57:41 +03:00
|
|
|
)
|
|
|
|
IF NOT DEFINED PYTHON (
|
2018-10-29 18:58:55 +03:00
|
|
|
echo Python not found. Please ensure python.exe is in your PATH.
|
|
|
|
exit /b 1
|
2017-04-01 07:57:41 +03:00
|
|
|
)
|
|
|
|
echo Using python from %PYTHON%
|
|
|
|
|
2017-11-10 19:27:48 +03:00
|
|
|
REM check that shipyard.py is in cwd
|
|
|
|
SET SHIPYARDFILE="%cd%\shipyard.py"
|
|
|
|
IF NOT EXIST %SHIPYARDFILE% (
|
2018-10-29 18:58:55 +03:00
|
|
|
echo shipyard.py does not exist in current working directory. Please run installer from Batch Shipyard root.
|
|
|
|
exit /b 1
|
2017-11-10 19:27:48 +03:00
|
|
|
)
|
|
|
|
|
2017-04-01 07:57:41 +03:00
|
|
|
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=%" (
|
2018-10-29 18:58:55 +03:00
|
|
|
echo Anaconda detected.
|
|
|
|
SET ANACONDA=1
|
2017-04-01 07:57:41 +03:00
|
|
|
)
|
|
|
|
IF NOT "%PYTHONVER%"=="%PYTHONVER:continuum=%" (
|
2018-10-29 18:58:55 +03:00
|
|
|
echo Anaconda detected.
|
|
|
|
SET ANACONDA=1
|
2017-04-01 07:57:41 +03:00
|
|
|
)
|
2017-06-26 17:58:28 +03:00
|
|
|
IF NOT "%PYTHONVER%"=="%PYTHONVER:conda-forge=%" (
|
2018-10-29 18:58:55 +03:00
|
|
|
echo Anaconda detected.
|
|
|
|
SET ANACONDA=1
|
2017-06-26 17:58:28 +03:00
|
|
|
)
|
2017-04-01 07:57:41 +03:00
|
|
|
|
|
|
|
REM install env and requirements
|
|
|
|
IF %ANACONDA% EQU 1 (
|
2018-10-29 18:58:55 +03:00
|
|
|
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%"
|
2017-04-01 07:57:41 +03:00
|
|
|
) ELSE (
|
2018-10-29 18:58:55 +03:00
|
|
|
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"
|
2017-04-01 07:57:41 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
REM create launcher cmd
|
|
|
|
SET CMDFILE=shipyard.cmd
|
|
|
|
(echo @echo off) > %CMDFILE%
|
|
|
|
IF %ANACONDA% EQU 1 (
|
2018-10-29 18:58:55 +03:00
|
|
|
(echo activate %VENVNAME% ^& python %SHIPYARDFILE% %%* ^& deactivate %VENVNAME%) >> %CMDFILE%
|
2017-04-01 07:57:41 +03:00
|
|
|
) ELSE (
|
2018-10-29 18:58:55 +03:00
|
|
|
echo call "%cd%\%VENVNAME%\Scripts\activate.bat" >> %CMDFILE%
|
|
|
|
echo python %SHIPYARDFILE% %%* >> %CMDFILE%
|
|
|
|
echo deactivate >> %CMDFILE%
|
2017-04-01 07:57:41 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
echo Installation complete. Run Batch Shipyard as: %cd%\shipyard.cmd
|