Syntax highlighting of ddf58e9 ~( python/poetry)
= Poetry = Poetry — это инструмент для управления зависимостями и упаковки в Python. Он позволяет вам объявить библиотеки, от которых зависит ваш проект, и он будет управлять (устанавливать/обновлять) их для вас. Poetry предлагает файл блокировки для обеспечения повторных установок и может создать ваш проект для распространения. {{{#!highlight bash # --- установка curl -sSL https://install.python-poetry.org | python3 - # --- обновление poetry self update # --- обновление до конкретной версии poetry self update 1.2.0 # --- полностью удалить poetry из системы curl -sSL https://install.python-poetry.org | python3 - --uninstall # --- или curl -sSL https://install.python-poetry.org | POETRY_UNINSTALL=1 python3 - }}} == Новый проект == {{{#!highlight bash # --- новая директория poetry new test_project poetry-demo ├── pyproject.toml ├── README.md ├── poetry_demo │ └── __init__.py └── tests └── __init__.py # --- существующая директория cd test_project poetry init }}} == Зависимости == {{{#!highlight toml # pyproject.toml [tool.poetry.dependencies] pendulum = "^2.1" }}} или {{{#!highlight bash poetry add pendulum@^2.1 }}} Управление зависимостями {{{#!highlight bash # --- установка poetry install # --- обновление poetry update # --- обновление заданных пакетов poetry update icecream pygame # --- удалить пакет из проекта poetry remove pygame # --- отобразить зависимости пакета poetry show requests }}} Посмотреть все установленные библиотеки и зависимости {{{#!highlight bash poetry show --tree rettytable 3.9.0 A simple Python library for easily displaying tabular data in a visually appealing ASCII table format └── wcwidth * pymongo 4.5.0 Python driver for MongoDB <http://www.mongodb.org> └── dnspython >=1.16.0,<3.0.0 pytest 7.4.2 pytest: simple powerful testing with Python ├── colorama * ├── iniconfig * ├── packaging * └── pluggy >=0.12,<2.0 }}} Посмотреть текущие версии библиотек и сравнить версии с новыми {{{#!highlight bash poetry show --latest asttokens 2.4.0 2.4.1 Annotate AST trees with source code positions backcall 0.2.0 0.2.0 Specifications for callback functions passed in to an API click 8.1.7 8.1.7 Composable command line interface toolkit decorator 5.1.1 5.1.1 Decorators for Humans dnspython 2.4.2 2.4.2 DNS toolkit }}} == Виртуальное окружение == {{{#!highlight bash # --- активация poetry shell # --- запустить скрипт в окружении poetry run python your_script.py # --- отключить автоматическое создание виртуального окружения poetry config virtualenvs.create false }}}
