rename extension from .rst to .md
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by denuoweb · committed by denuoweb · parent d9b37c7 · Browse files · 2 files·+87 added−87 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+87 added−87 removed
- other:+87 added−87 removed
Provenance
- Commit
d1d3538- Tree
087c96d- Author
denuoweb <jaron@rosenau.info>- Committer
denuoweb <jaron@rosenau.info>- Parent
d9b37c7
2 files changed+87 added−87 removed
added:docs/entry-points.md+87 added
1+Packaging Entry Points2+======================3+4+It's recommended to write command line utilities as installable packages with5+entry points instead of telling users to run ``python hello.py``.6+7+A distribution package is a ``.whl`` file you install with pip or another Python8+installer. You use a ``pyproject.toml`` file to describe the project and how it9+is built into a package. You might upload this package to PyPI, or distribute it10+to your users in another way.11+12+Python installers create executable scripts that will run a specified Python13+function. These are known as "entry points". The installer knows how to create14+an executable regardless of the operating system, so it will work on Linux,15+Windows, MacOS, etc.16+17+18+Project Files19+-------------20+21+To install your app with an entry point, all you need is the script and a22+``pyproject.toml`` file. Here's an example project directory:23+24+.. code-block:: text25+26+ hello-project/27+ src/28+ hello/29+ __init__.py30+ hello.py31+ pyproject.toml32+33+Contents of ``hello.py``:34+35+.. click:example::36+37+ import click38+39+ @click.command()40+ def cli():41+ """Prints a greeting."""42+ click.echo("Hello, World!")43+44+Contents of ``pyproject.toml``:45+46+.. code-block:: toml47+48+ [project]49+ name = "hello"50+ version = "1.0.0"51+ description = "Hello CLI"52+ requires-python = ">=3.11"53+ dependencies = [54+ "click>=8.1",55+ ]56+57+ [project.scripts]58+ hello = "hello.hello:cli"59+60+ [build-system]61+ requires = ["flit_core<4"]62+ build-backend = "flit_core.buildapi"63+64+The magic is in the ``project.scripts`` section. Each line identifies one executable65+script. The first part before the equals sign (``=``) is the name of the script that66+should be generated, the second part is the import path followed by a colon67+(``:``) with the function to call (the Click command).68+69+70+Installation71+------------72+73+When your package is installed, the installer will create an executable script74+based on the configuration. During development, you can install in editable75+mode using the ``-e`` option. Remember to use a virtual environment!76+77+.. code-block:: console78+79+ $ python -m venv .venv80+ $ . .venv/bin/activate81+ $ pip install -e .82+83+Afterwards, your command should be available:84+85+.. click:run::86+87+ invoke(cli, prog_name="hello")deleted:docs/entry-points.rst-87 removed
1-Packaging Entry Points2-======================3-4-It's recommended to write command line utilities as installable packages with5-entry points instead of telling users to run ``python hello.py``.6-7-A distribution package is a ``.whl`` file you install with pip or another Python8-installer. You use a ``pyproject.toml`` file to describe the project and how it9-is built into a package. You might upload this package to PyPI, or distribute it10-to your users in another way.11-12-Python installers create executable scripts that will run a specified Python13-function. These are known as "entry points". The installer knows how to create14-an executable regardless of the operating system, so it will work on Linux,15-Windows, MacOS, etc.16-17-18-Project Files19--------------20-21-To install your app with an entry point, all you need is the script and a22-``pyproject.toml`` file. Here's an example project directory:23-24-.. code-block:: text25-26- hello-project/27- src/28- hello/29- __init__.py30- hello.py31- pyproject.toml32-33-Contents of ``hello.py``:34-35-.. click:example::36-37- import click38-39- @click.command()40- def cli():41- """Prints a greeting."""42- click.echo("Hello, World!")43-44-Contents of ``pyproject.toml``:45-46-.. code-block:: toml47-48- [project]49- name = "hello"50- version = "1.0.0"51- description = "Hello CLI"52- requires-python = ">=3.11"53- dependencies = [54- "click>=8.1",55- ]56-57- [project.scripts]58- hello = "hello.hello:cli"59-60- [build-system]61- requires = ["flit_core<4"]62- build-backend = "flit_core.buildapi"63-64-The magic is in the ``project.scripts`` section. Each line identifies one executable65-script. The first part before the equals sign (``=``) is the name of the script that66-should be generated, the second part is the import path followed by a colon67-(``:``) with the function to call (the Click command).68-69-70-Installation71-------------72-73-When your package is installed, the installer will create an executable script74-based on the configuration. During development, you can install in editable75-mode using the ``-e`` option. Remember to use a virtual environment!76-77-.. code-block:: console78-79- $ python -m venv .venv80- $ . .venv/bin/activate81- $ pip install -e .82-83-Afterwards, your command should be available:84-85-.. click:run::86-87- invoke(cli, prog_name="hello")