#!/usr/bin/python3 -s

import envoy

def main():

    # Capture the output of `$ pip freeze`.
    freeze = envoy.run('pip freeze').std_out
    installed = freeze.split()

    # Alert the user.
    print('Found {} dirty packages intalled, purging...'.format(len(installed)))

    command = 'pip uninstall {} -y'.format(' '.join(installed))
    print(envoy.run(command).std_out)
    print('Purged!')

if __name__ == '__main__':
    main()