# Intro

Guide from PyPA: <https://packaging.python.org/en/latest>

Пакеты — согласно гайду выше — все, что может быть собрано для дистрибуции, как правило — это то, что в корне содержит `pyproject.toml`, `setup.py` или `setup.cfg` (последние два использует `setuptools`).

Дистрибуция (библиотеки и инструменты):

* Исходным кодом (подходит, если среда, в которой будет запускать код соответствует вашей)
  * Называется **Source distribution** package или `sdist` (собирает в архив `.tar.gz`)
  * Можно собрать через обычные инструменты: `python -m build --sdist`
* Собранным пакетом
  * Называется **Built distribution** package (или `wheels`)
  * Wheel-формат (использует `pip`, пришел на замену Egg-формату)
  * Egg-формат (использует `setuptools`)

Сборщики состоят из двух частей:

* **Build Frontend** — это инструменты, которые собирают из исходного кода пакет для дистрибуции. Примеры build frontend — `pip` и `build`, `poetry`, `hatch` и др. Используют Build Backend's.
  * Сборка:

```
~ python -m pip install --upgrade build
~ cat pyproject.toml
~ python -m build
~ ls -al
dist/
├── example_package_YOUR_USERNAME_HERE-0.0.1-py3-none-any.whl
└── example_package_YOUR_USERNAME_HERE-0.0.1.tar.gz
```

* **Build Backend** — это библиотеки, которые умеют собирать из исходного кода пакет для дистрибуции для разных платформ, окружений и тп. Примеры: `hatchling`, `setuptools`, `meson`, `flit`, `poetry-core` и тд

Про [загрузку в PyPI](https://packaging.python.org/en/latest/tutorials/packaging-projects/#uploading-the-distribution-archives) через twine.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://appsecurity.gitbook.io/devops/ppc/ppc-langs/backend/python/packaging/intro.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
