-
Notifications
You must be signed in to change notification settings - Fork 9
Project Maintenance with Poetry
One of the main features of poetry
is that it makes dependency-management really convenient.
Poetry works on the basis of the pyproject.toml
file of this project, resolves the listed dependencies and creates a poetry.lock
file (to guarantee that all people working on the project use the same dependency versions).
-
Poetry (Official Website)
-
Poetry Documentation
- Poetry Installation
- Basic Usage
- Managing Dependencies (and dependency groups)
- (CLI) Commands
- Poetry Blog: Announcements of new releases
-
Poetry Documentation
- pipx: install and run Python applications in isolated environments
-
pyenv: simple Python version management
- (use this tool to switch between different Python versions without accidentally overwriting your system's global python version)
Please make sure that you followed the Poetry Installation Guide first and that your Poetry is up to date.
Typing poetry --version
into your console / terminal should produce a similar output:
$ poetry --version
Poetry (version 1.8.3)
If you are using pyCharm and want to have an easier experience while handling virtual environments (.venv/
),
you might want to set up poetry to create virtualenvs within the project's root directory.
(oeh-search-etl
is set up to .gitignore
any .venv
directories.)
After making sure that you have installed Poetry, you can use the following commands within your terminal to save some time in the future:
-
poetry check
: checks if thepyproject.toml
-structure is still valid -
poetry install
:- reads the
pyproject.toml
-file - installs dependencies
- and updates the
poetry.lock
-file
- reads the
-
poetry show --tree
: displays the dependencies in a tree-view -
poetry show --outdated
: shows outdated dependencies- you can adjust the
pyproject.toml
file manually to version-pin specific dependencies - or use the
poetry add
command with a version constraint,- e.g.
poetry add playwright==1.46.0
version-pins theplaywright
-package to v1.46.0
- e.g.
- now update the dependencies according to your
pyproject.toml
specifications:- to update all dependencies, use
poetry update
- or update individual packages only by using
poetry update <package_name>
- (reminder:
poetry update
respects the version constraints of yourpyproject.toml
and will not update a version-pinned package above your defined version constraints!)- If you want to update a package to a higher version than specified in your
pyproject.toml
file, use the above-mentionedpoetry add
command!
- If you want to update a package to a higher version than specified in your
- to update all dependencies, use
- you can adjust the
- optional: save the
requirements_dependencies_tree.txt
-file for an (easier) visual overviewpoetry show --tree > requirements_dependencies_tree.txt