switch format from rest to myst
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by denuoweb · committed by denuoweb · parent d1d3538 · Browse files · 1 file·+41 added−40 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+41 added−40 removed
- other:+41 added−40 removed
Provenance
- Commit
8677596- Tree
9d13c23- Author
denuoweb <jaron@rosenau.info>- Committer
denuoweb <jaron@rosenau.info>- Parent
d1d3538
1 file changed+41 added−40 removed
modified:docs/entry-points.md+41 added-40 removed
12123456789105 unmodified lines161718192021181920222324242526272829303132332627282930313234353637363839404142434445464746484950515253545556574849505152535455585960575861626364656061626366676869707172707172737475767777787980818279808182838485868785868788Packaging Entry Points======================# Packaging Entry Points
```{eval-rst}.. currentmodule:: click```
It's recommended to write command line utilities as installable packages withentry points instead of telling users to run ``python hello.py``.
A distribution package is a ``.whl`` file you install with pip or another Python5 unmodified linesfunction. These are known as "entry points". The installer knows how to createan executable regardless of the operating system, so it will work on Linux,Windows, MacOS, etc.
## Project Files
Project Files-------------
To install your app with an entry point, all you need is the script and a``pyproject.toml`` file. Here's an example project directory:
.. code-block:: text```texthello-project/ src/ hello/ __init__.py hello.py pyproject.toml```
hello-project/ src/ hello/ __init__.py hello.py pyproject.toml
Contents of ``hello.py``:
```{eval-rst}.. click:example::
import click
@click.command() def cli(): """Prints a greeting.""" click.echo("Hello, World!")```
Contents of ``pyproject.toml``:
.. code-block:: toml```toml[project]name = "hello"version = "1.0.0"description = "Hello CLI"requires-python = ">=3.11"dependencies = [ "click>=8.1",]
[project] name = "hello" version = "1.0.0" description = "Hello CLI" requires-python = ">=3.11" dependencies = [ "click>=8.1", ][project.scripts]hello = "hello.hello:cli"
[project.scripts] hello = "hello.hello:cli"[build-system]requires = ["flit_core<4"]build-backend = "flit_core.buildapi"```
[build-system] requires = ["flit_core<4"] build-backend = "flit_core.buildapi"
The magic is in the ``project.scripts`` section. Each line identifies one executablescript. The first part before the equals sign (``=``) is the name of the script thatshould be generated, the second part is the import path followed by a colon(``:``) with the function to call (the Click command).
## Installation
Installation------------
When your package is installed, the installer will create an executable scriptbased on the configuration. During development, you can install in editablemode using the ``-e`` option. Remember to use a virtual environment!
.. code-block:: console```console$ python -m venv .venv$ . .venv/bin/activate$ pip install -e .```
$ python -m venv .venv $ . .venv/bin/activate $ pip install -e .
Afterwards, your command should be available:
.. click:run::
invoke(cli, prog_name="hello")```console$ helloHello, World!```No newline at end of file