Repository: audreyr/cookiecutter (python)

Issue:
Provide a __main__.py for the package
By providing a `__main__.py` file in the `cookiecutter` package it allows for `python.exe -m cookiecutter` to work (and the entry point can then simply point at the `__main__` module). I would be happy to provide a PR for this if you're amenable to the addition.

Pull request:
Add support for executing cookiecutter using -m or from a checkout/zip file
With this change you gain at least three ways to execute cookiecutter:

1. `python -m cookiecutter`
2. From a checkout: `python .`
3. From a zip file (that includes all necessary dependencies): `python cookiecutter.zip`

Closes #787

Patch:
diff --git a/__main__.py b/__main__.py
new file mode 100644
index 0000000..b1c06ff
--- /dev/null
+++ b/__main__.py
@@ -0,0 +1,6 @@
+"""Allow cookiecutter to be executable from a checkout or zip file."""
+import runpy
+
+
+if __name__ == "__main__":
+    runpy.run_module("cookiecutter", run_name="__main__")
diff --git a/cookiecutter/__main__.py b/cookiecutter/__main__.py
new file mode 100644
index 0000000..0d8fccb
--- /dev/null
+++ b/cookiecutter/__main__.py
@@ -0,0 +1,8 @@
+"""Allow cookiecutter to be executable through `python -m cookiecutter`."""
+from __future__ import absolute_import
+
+from .cli import main
+
+
+if __name__ == "__main__":  # pragma: no cover
+    main(prog_name="cookiecutter")
diff --git a/setup.py b/setup.py
index 9625511..35b04ea 100644
--- a/setup.py
+++ b/setup.py
@@ -57,7 +57,7 @@ setup(
     package_dir={'cookiecutter': 'cookiecutter'},
     entry_points={
         'console_scripts': [
-            'cookiecutter = cookiecutter.cli:main',
+            'cookiecutter = cookiecutter.__main__:main',
         ]
     },
     include_package_data=True,


Test patch:
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 2c4dd6d..ca75e52 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -6,7 +6,7 @@ import pytest
 
 from click.testing import CliRunner
 
-from cookiecutter.cli import main
+from cookiecutter.__main__ import main
 from cookiecutter.main import cookiecutter
 from cookiecutter import utils, config