New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow fabric to be invoked as a Python module (with -m) #975

Merged
merged 2 commits into from Sep 3, 2014

Conversation

Projects
None yet
2 participants
@jaraco

jaraco commented Sep 5, 2013

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).

@jaraco

This comment has been minimized.

jaraco commented Aug 8, 2014

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.

@bitprophet bitprophet added the Feature label Aug 11, 2014

@bitprophet bitprophet added this to the 1.10 milestone Aug 11, 2014

@bitprophet

This comment has been minimized.

Member

bitprophet commented Sep 3, 2014

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.

@bitprophet bitprophet merged commit 83313d2 into fabric:master Sep 3, 2014

1 check passed

default The Travis CI build passed
Details

bitprophet added a commit that referenced this pull request Sep 3, 2014

bitprophet added a commit that referenced this pull request Sep 3, 2014

@jaraco

This comment has been minimized.

jaraco commented Sep 10, 2014

awesome. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment