Last active
March 23, 2017 07:31
-
-
Save VishalTaj/03913a6617ab6ec87341 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
__author__ = 'Vishal Taj PM' | |
import subprocess | |
import os | |
import shutil | |
def create_virtualenv(envName): | |
subprocess.call(['virtualenv', envName]) | |
def install(packageName): | |
subprocess.call('pip','install',packageName) | |
def workon(envName): | |
shutil.copy2('script.py', envName+'/script.py') | |
os.chdir(envName+'/') | |
os.system('/bin/bash --rcfile '+activate) | |
subprocess.Popen([python_bin, script_file]) | |
def deactivate(): | |
subprocess.call('source', 'bin/deactivate') | |
path = os.getcwd() | |
envName = raw_input("Virtual Environment Name : ") | |
python_bin = path+'/'+envName+"/bin/python" | |
activate = path+'/'+envName+'/bin/activate' | |
# path to the script that must run under the virtualenv | |
script_file = path+"/script.py" | |
if not os.path.isdir(envName): | |
create_virtualenv(envName) | |
workon(envName) | |
else: | |
workon(envName) | |
print """A Directory with the same name already exist please specify | |
other name or remove it manually""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment