summaryrefslogtreecommitdiff
path: root/docs/userguide/entry_point.rst
diff options
context:
space:
mode:
authorSaniya Maheshwari <saniya.mah@gmail.com>2022-06-09 10:20:14 +0530
committerSaniya Maheshwari <saniya.mah@gmail.com>2022-06-09 17:36:16 +0530
commit82bea11ebf5736b425b1a422c711d71d1a87a7d0 (patch)
treebbc29931552f31a0cd9b9a03866ac8b7c16082d4 /docs/userguide/entry_point.rst
parent51041e1b63058ba73163c380bad8f094c78898c8 (diff)
downloadpython-setuptools-git-82bea11ebf5736b425b1a422c711d71d1a87a7d0.tar.gz
Modified Console scripts example
Changed the wording of the console scripts example, so that it is more clear why `__main__.py` is required and why console scripts are a better alternative.
Diffstat (limited to 'docs/userguide/entry_point.rst')
-rw-r--r--docs/userguide/entry_point.rst14
1 files changed, 9 insertions, 5 deletions
diff --git a/docs/userguide/entry_point.rst b/docs/userguide/entry_point.rst
index 9c17f035..f30326ac 100644
--- a/docs/userguide/entry_point.rst
+++ b/docs/userguide/entry_point.rst
@@ -21,7 +21,6 @@ defined thus::
└── src
└── timmins
├── __init__.py
- ├── __main__.py
└── ...
with ``__init__.py`` as:
@@ -31,7 +30,10 @@ with ``__init__.py`` as:
def hello_world():
print("Hello world")
-and ``__main__.py`` providing a hook:
+Now, suppose that we would like to provide some way of executing the
+function ``hello_world()`` from the command-line. One way to do this
+is to create a file ``src/timmins/__main__.py`` providing a hook as
+follows:
.. code-block:: python
@@ -40,15 +42,17 @@ and ``__main__.py`` providing a hook:
if __name__ == '__main__':
hello_world()
-After installing the package, the function may be invoked through the
-`runpy <https://docs.python.org/3/library/runpy.html>`_ module:
+Then, after installing the package ``timmins``, we may invoke the ``hello_world()``
+function as follows, through the `runpy <https://docs.python.org/3/library/runpy.html>`_
+module:
.. code-block:: bash
$ python -m timmins
Hello world
-Adding a console script entry point allows the package to define a
+Instead of this approach using ``__main__.py``, a better way is to add
+a console script entry point, which allows the package to define a
user-friendly name for installers of the package to execute.
In the above example, to create a command ``hello-world`` that invokes
``timmins.hello_world``, add a console script entry point to your