ajib6ept
1/24/2020 - 4:37 PM

about poetry

poetry #mynotes


poetry config virtualenvs.in-project true
poetry config --list

# Basic usage

# let's create our new project
$ poetry new poetry-demo

# add dependencies
$ poetry add pendulum

# Installing dependencies
$ poetry install

# as development dependencies with poetry add --dev
$ poetry add --dev requests

# Creates a basic pyproject.toml file in the current directory.
$ poetry init

# Shows information about packages
$ poetry show --tree



my_package
├── my_package
│   ├── __init__.py
│   └── log_revision.py
└── pyproject.toml

# pyproject.toml
[tool.poetry]
name = "my_package"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]

[tool.poetry.dependencies]
python = "^3.8"

[tool.poetry.scripts]
my-script = "my_package.log_revision:start"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

# log_revision.py
def start():
    print("Hello")
    
$ poetry run my-script  
Hello