Advertisement
Guest User

venv automation

a guest
May 23rd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. set root=%cd%
  3. set scripts=%root%\venv\scripts
  4. set python=python.exe
  5.  
  6. IF NOT EXIST "%root%\venv\scripts\activate" (
  7.   echo Could not find a virtual environment
  8.   choice /m "Would you like to create one?"
  9.   if errorlevel 2 goto exit  
  10.   if errorlevel 1 goto install
  11.  
  12.   :exit
  13.   echo 
  14.   exit
  15.  
  16.   :install  
  17.   echo installing a virtual environment.
  18.   %python% -m venv venv
  19.   echo updating pip
  20.   %scripts%\python.exe -m pip install --upgrade pip > nul
  21.   IF EXIST %root%\requirements.txt (
  22.     echo restoring requirements
  23.     %scripts%\pip install -r %root%\requirements.txt > nul
  24.   )
  25. )
  26. echo 
  27. echo ===== Some usefull commands ======================================
  28. echo  freeze:  save all installed packages to a requirements.txt files
  29. echo  restore: restore all packages listed in requirements.txt
  30. echo  pip install ^<package^>: install a package from pypi.
  31. echo  idle: start idle.
  32. echo ==================================================================
  33. echo 
  34.  
  35. doskey freeze=pip freeze $g %root%\requirements.txt
  36. doskey install=pip install -r %root%\requirements.txt
  37. doskey idle=python -m idlelib
  38.  
  39. cmd /k %scripts%\activate
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement