Herramientas de usuario

Herramientas del sitio


wiki2:poetry

¡Esta es una revisión vieja del documento!


Poetry

Basic

Create a project

poetry new project

Initializing an existent project

poetry init

Install dependences

poetry install

Or

poetry install --no-root

Add package

poetry add package

From git repository

poetry add git+repo_url

Execute a command

poetry run command

List where the environment is

poetry env list --full-path

On a docker container

We do not need a virtual env docker. It is already isolated. So, we use

poetry config virtualenvs.create false 

setting to turn it off.

Install from existing requirements

cat requirements.txt|xargs poetry add

Use

Versioning

For starting a new project we use:

poetry new --src <path>

It generates this structure:

.
├── pyproject.toml
├── README.rst
├── src
│   └── project_name
│       └── __init__.py
└── tests
    ├── __init__.py
    └── test_project_name.py

Other tips

Show the dependences tree

poetry show --tree

Add latest package

poetry add pymysql@latest

Add from requirements.txt

cat requirements.txt|xargs poetry add

Add private repo

This creates the repo gf accessed with credentials.

poetry config repositories.gf https://pip.getfinancing.us/simple/
poetry config http-basic.gf $PYPI_USER $PYPI_PSW

Use poetry with a concrete Python version

poetry env use python3.9
wiki2/poetry.1640168664.txt.gz · Última modificación: 2021/12/22 11:24 (editor externo)