#!/usr/bin/env python
# Support for python2
from __future__ import print_function
import os
import sys
import shutil


# Setting some variables
IN_VIRTUALENV = hasattr(sys, 'real_prefix')
IS_ROOT = (os.getuid() == 0)
ROOT_DIR = os.getcwd()

if IS_ROOT or IN_VIRTUALENV:
  os.system('python setup.py install')

  # Cleaning up after installation.
  shutil.rmtree(os.path.join(ROOT_DIR,'dist'), ignore_errors = True)
  shutil.rmtree(os.path.join(ROOT_DIR,'build'), ignore_errors = True)
  manifest_path = os.path.join(ROOT_DIR,'MANIFEST')
  if os.path.isfile(manifest_path):
    os.remove(manifest_path)

else:
  print("Please run as root or in a virtualenv")


