Skip to main content
  1. Notes/

Poetry

·1 min·

Install poetry
#

pip install poetry

Create a new project
#

# in work directory
poetry new name_of_project

Manage dependencies
#

1. modify pyproject.toml
#

[tool.poetry.dependencies]
scikit-learn = "*"

2. CLI
#

poetry add pytest

best practice for testing dependencies
#

[tool.poetry.group.dev.dependencies]
pytest = "^7.2.1"
pytest-mock = "*"

Activate environment in terminal
#

# activate
poetry shell
# deactivate
exit

Install dependencies specified in pyproject.toml file, or .lock file
#

poetry install

Run with Poetry-configured Env via CLI
#

poetry run python xxx.py

Building a library
#

poetry build

Publish to PyPI
#

poetry publish –r private-repository-location