|
8 | 8 | msgstr ""
|
9 | 9 | "Project-Id-Version: Python Packaging User Guide \n"
|
10 | 10 | "Report-Msgid-Bugs-To: \n"
|
11 |
| -"POT-Creation-Date: 2025-09-16 02:08+0000\n" |
| 11 | +"POT-Creation-Date: 2025-09-16 02:15+0000\n" |
12 | 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
13 | 13 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14 | 14 | "Language-Team: LANGUAGE < [email protected]>\n"
|
@@ -3085,79 +3085,79 @@ msgstr ""
|
3085 | 3085 | msgid "The actual code responsible for the tool's functionality will be stored in the file :file:`greet.py`, named after the main module:"
|
3086 | 3086 | msgstr ""
|
3087 | 3087 |
|
3088 |
| -#: ../source/guides/creating-command-line-tools.rst:73 |
| 3088 | +#: ../source/guides/creating-command-line-tools.rst:62 |
3089 | 3089 | msgid "The above function receives several keyword arguments that determine how the greeting to output is constructed. Now, construct the command-line interface to provision it with the same, which is done in :file:`cli.py`:"
|
3090 | 3090 | msgstr ""
|
3091 | 3091 |
|
3092 |
| -#: ../source/guides/creating-command-line-tools.rst:91 |
| 3092 | +#: ../source/guides/creating-command-line-tools.rst:80 |
3093 | 3093 | msgid "The command-line interface is built with typer_, an easy-to-use CLI parser based on Python type hints. It provides auto-completion and nicely styled command-line help out of the box. Another option would be :py:mod:`argparse`, a command-line parser which is included in Python's standard library. It is sufficient for most needs, but requires a lot of code, usually in ``cli.py``, to function properly. Alternatively, docopt_ makes it possible to create CLI interfaces based solely on docstrings; advanced users are encouraged to make use of click_ (on which ``typer`` is based)."
|
3094 | 3094 | msgstr ""
|
3095 | 3095 |
|
3096 |
| -#: ../source/guides/creating-command-line-tools.rst:97 |
| 3096 | +#: ../source/guides/creating-command-line-tools.rst:86 |
3097 | 3097 | msgid "Now, add an empty :file:`__init__.py` file, to define the project as a regular :term:`import package <Import Package>`."
|
3098 | 3098 | msgstr ""
|
3099 | 3099 |
|
3100 |
| -#: ../source/guides/creating-command-line-tools.rst:99 |
| 3100 | +#: ../source/guides/creating-command-line-tools.rst:88 |
3101 | 3101 | msgid "The file :file:`__main__.py` marks the main entry point for the application when running it via :mod:`runpy` (i.e. ``python -m greetings``, which works immediately with flat layout, but requires installation of the package with src layout), so initialize the command-line interface here:"
|
3102 | 3102 | msgstr ""
|
3103 | 3103 |
|
3104 |
| -#: ../source/guides/creating-command-line-tools.rst:111 |
| 3104 | +#: ../source/guides/creating-command-line-tools.rst:100 |
3105 | 3105 | msgid "In order to enable calling the command-line interface directly from the :term:`source tree <Project Source Tree>`, i.e. as ``python src/greetings``, a certain hack could be placed in this file; read more at :ref:`running-cli-from-source-src-layout`."
|
3106 | 3106 | msgstr ""
|
3107 | 3107 |
|
3108 |
| -#: ../source/guides/creating-command-line-tools.rst:117 |
| 3108 | +#: ../source/guides/creating-command-line-tools.rst:106 |
3109 | 3109 | msgid "``pyproject.toml``"
|
3110 | 3110 | msgstr ""
|
3111 | 3111 |
|
3112 |
| -#: ../source/guides/creating-command-line-tools.rst:119 |
| 3112 | +#: ../source/guides/creating-command-line-tools.rst:108 |
3113 | 3113 | msgid "The project's :term:`metadata <Pyproject Metadata>` is placed in :term:`pyproject.toml`. The :term:`pyproject metadata keys <Pyproject Metadata Key>` and the ``[build-system]`` table may be filled in as described in :ref:`writing-pyproject-toml`, adding a dependency on ``typer`` (this tutorial uses version *0.12.3*)."
|
3114 | 3114 | msgstr ""
|
3115 | 3115 |
|
3116 |
| -#: ../source/guides/creating-command-line-tools.rst:122 |
| 3116 | +#: ../source/guides/creating-command-line-tools.rst:111 |
3117 | 3117 | msgid "For the project to be recognised as a command-line tool, additionally a ``console_scripts`` :ref:`entry point <entry-points>` (see :ref:`console_scripts`) needs to be added as a :term:`subkey <Pyproject Metadata Subkey>`:"
|
3118 | 3118 | msgstr ""
|
3119 | 3119 |
|
3120 |
| -#: ../source/guides/creating-command-line-tools.rst:129 |
| 3120 | +#: ../source/guides/creating-command-line-tools.rst:118 |
3121 | 3121 | msgid "Now, the project's source tree is ready to be transformed into a :term:`distribution package <Distribution Package>`, which makes it installable."
|
3122 | 3122 | msgstr ""
|
3123 | 3123 |
|
3124 |
| -#: ../source/guides/creating-command-line-tools.rst:134 |
| 3124 | +#: ../source/guides/creating-command-line-tools.rst:123 |
3125 | 3125 | msgid "Installing the package with ``pipx``"
|
3126 | 3126 | msgstr ""
|
3127 | 3127 |
|
3128 |
| -#: ../source/guides/creating-command-line-tools.rst:136 |
| 3128 | +#: ../source/guides/creating-command-line-tools.rst:125 |
3129 | 3129 | msgid "After installing ``pipx`` as described in :ref:`installing-stand-alone-command-line-tools`, install your project:"
|
3130 | 3130 | msgstr ""
|
3131 | 3131 |
|
3132 |
| -#: ../source/guides/creating-command-line-tools.rst:143 |
| 3132 | +#: ../source/guides/creating-command-line-tools.rst:132 |
3133 | 3133 | msgid "This will expose the executable script we defined as an entry point and make the command ``greet`` available. Let's test it:"
|
3134 | 3134 | msgstr ""
|
3135 | 3135 |
|
3136 |
| -#: ../source/guides/creating-command-line-tools.rst:155 |
| 3136 | +#: ../source/guides/creating-command-line-tools.rst:146 |
3137 | 3137 | msgid "Since this example uses ``typer``, you could now also get an overview of the program's usage by calling it with the ``--help`` option, or configure completions via the ``--install-completion`` option."
|
3138 | 3138 | msgstr ""
|
3139 | 3139 |
|
3140 |
| -#: ../source/guides/creating-command-line-tools.rst:158 |
| 3140 | +#: ../source/guides/creating-command-line-tools.rst:149 |
3141 | 3141 | msgid "To just run the program without installing it permanently, use ``pipx run``, which will create a temporary (but cached) virtual environment for it:"
|
3142 | 3142 | msgstr ""
|
3143 | 3143 |
|
3144 |
| -#: ../source/guides/creating-command-line-tools.rst:165 |
| 3144 | +#: ../source/guides/creating-command-line-tools.rst:156 |
3145 | 3145 | msgid "This syntax is a bit impractical, however; as the name of the entry point we defined above does not match the package name, we need to state explicitly which executable script to run (even though there is only on in existence)."
|
3146 | 3146 | msgstr ""
|
3147 | 3147 |
|
3148 |
| -#: ../source/guides/creating-command-line-tools.rst:168 |
| 3148 | +#: ../source/guides/creating-command-line-tools.rst:159 |
3149 | 3149 | msgid "There is, however, a more practical solution to this problem, in the form of an entry point specific to ``pipx run``. The same can be defined as follows in :file:`pyproject.toml`:"
|
3150 | 3150 | msgstr ""
|
3151 | 3151 |
|
3152 |
| -#: ../source/guides/creating-command-line-tools.rst:177 |
| 3152 | +#: ../source/guides/creating-command-line-tools.rst:168 |
3153 | 3153 | msgid "Thanks to this entry point (which *must* match the package name), ``pipx`` will pick up the executable script as the default one and run it, which makes this command possible:"
|
3154 | 3154 | msgstr ""
|
3155 | 3155 |
|
3156 |
| -#: ../source/guides/creating-command-line-tools.rst:185 |
| 3156 | +#: ../source/guides/creating-command-line-tools.rst:176 |
3157 | 3157 | msgid "Conclusion"
|
3158 | 3158 | msgstr ""
|
3159 | 3159 |
|
3160 |
| -#: ../source/guides/creating-command-line-tools.rst:187 |
| 3160 | +#: ../source/guides/creating-command-line-tools.rst:178 |
3161 | 3161 | msgid "You know by now how to package a command-line application written in Python. A further step could be to distribute your package, meaning uploading it to a :term:`package index <Package Index>`, most commonly :term:`PyPI <Python Package Index (PyPI)>`. To do that, follow the instructions at :ref:`Packaging your project`. And once you're done, don't forget to :ref:`do some research <analyzing-pypi-package-downloads>` on how your package is received!"
|
3162 | 3162 | msgstr ""
|
3163 | 3163 |
|
|
0 commit comments