install_requirements_windows.bat 1.98 KB
rem @echo off

SET PYTHON=python
SET VENV_NAME=venv_py35_pyros

REM String variables

SET PRIVATE_DIR_CREATE=-Created 'private' directory
SET PYTHON_NOT_INSTALLED=-Cannot find $PYTHON, please install it or configure PYTHON variable in this script
SET PYTHON_FOUND=-Found %PYTHON% at
SET VENV_CREATE=-Creating virtualenv $VENV_NAME... 
SET VENV_ACTIVATE=-Activating virtual environment... 
SET DONE=done.
SET UPGRADE_PIP=-Upgrading pip:
SET UPGRADE_WHEEL=-Upgrading wheel:
SET INSTALL_PACKAGES=-Installing required packages from install/REQUIREMENTS.txt
SET CREATE_DATABASE=-Creating database tables :
SET CREATE_SUPERUSER=-Creating database superuser :
SET INSTALLATION_FINISHED=-Installation finished
SET BAD_SQL_CONFIGURATION=-Migration cannot be applied to the database : check your database configuration, or use sqlite instead

REM Getting python location
where %PYTHON% > tmp.txt

IF %ERRORLEVEL% NEQ 0 (
	ECHO %PYTHON_NOT_INSTALLED%
	del tmp.txt
	PAUSE
	EXIT
)

SET /p PYTHON_DIR=<tmp.txt
del tmp.txt


ECHO %PYTHON_FOUND% %PYTHON_DIR%

REM Move into the .bat file directory (should be install/)

cd %~dp0%

REM Create a virtual env for Python3
cd ..

if not exist private mkdir private

echo %PRIVATE_DIR_CREATE%

cd private/

REM create a venv_py35_pyros/ folder inside PYROS/private/
echo %VENV_CREATE%
virtualenv %VENV_NAME% -p %PYTHON_DIR%


REM Activate the virtual env
echo %VENV_ACTIVATE%
CALL venv_py35_pyros/Scripts/activate

echo Python location :
where python

REM Upgrade pip
echo %UPGRADE_PIP%
pip install --upgrade pip

REM Upgrade wheel
echo %UPGRADE_WHEEL%
pip install --upgrade wheel

REM Install the needed python packages
echo %INSTALL_PACKAGES%
pip install -r ../install/REQUIREMENTS.txt

REM Create the database and a superuser pyros
cd ../src/
echo %CREATE_DATABASE%
python manage.py makemigrations
python manage.py migrate

IF %ERRORLEVEL% NEQ 0 (
    echo %BAD_SQL_CONFIGURATION%
	pause
    exit
)

echo %CREATE_SUPERUSER%
python manage.py createsuperuser

echo %INSTALLATION_FINISHED%

PAUSE
EXIT