import sys
from fabric.main import main
if __name__ == '__main__':
    sys.argv[0] = re.sub('(-script\\.pyw|\\.exe)?$', '', sys.argv[0])
sys.exit(main())
How do you set up Pycharm to debug a Fabric fabfile on Windows?