This patch allows fabric to be invoked as a Python module. This is particularly convenient when the Python environment is known but its location (and scripts) are not (such as on Windows when using pylauncher).
Add __main__ so that fabric can be invoked with 'python -m fabric'
I use this change every day. Now that I use Python 3 for my main environment, but because fabric doesn't yet support Python 3, I need an easy way to invoke fabric from Python 2. What I've been doing is this:
py -2 -m fabric [commands]
On Windows with pylancher, that invokes fabric under Python 2 (where fabric is installed with this patch). I don't have to have any entry points or worry about execution paths or Python 3 'fab' executable taking precedence.
The same advantages would apply on a Unix environment:
python2.7 -m fabric [commands]
That would invoke fabric under python2.7 even if 'fab' resolves to another Python version.
This change leverages well-defined Python standard defined in PEP 338, and as far as I know has no disadvantages.
Looks like this only functions correctly under Python 2.7 and up; 2.5 behaves like it's a no-op and 2.6 complains because fabric is a package instead of a module. A bit confusing since that PEP implies this was added in Python 2.5.
Still, it can hardly hurt anything for the older Pythons, so I think I may just note this in the changelog for CYA (COA?) purposes.
Changelog re #975 (file moved, also reworded)
Add note that #975 only seems to work on 2.7