Language: Python
CLI/Utils
Poetry was created by Sébastien Eustace in 2018 to provide a modern alternative to pip and setuptools for Python projects. It emphasizes simplicity, reproducibility, and a standardized approach to dependency management, making Python project setups more predictable and reliable.
Poetry is a Python dependency management and packaging tool that simplifies the process of managing project dependencies, building packages, and publishing them. It ensures deterministic installs and isolated environments.
pip install poetryhttps://python-poetry.org/docs/#installationPoetry provides commands to create new projects, add or remove dependencies, build and publish packages, and manage virtual environments automatically. It uses a `pyproject.toml` file to track project metadata and dependencies.
poetry new my-projectCreates a new Python project named 'my-project' with a standard directory structure and a `pyproject.toml` file.
poetry add requestsAdds the `requests` library to the project and updates the `pyproject.toml` and `poetry.lock` files.
poetry installInstalls all dependencies listed in `pyproject.toml` into a virtual environment managed by Poetry.
poetry remove requestsRemoves the `requests` dependency from the project and updates the lock file.
poetry run python script.pyExecutes a Python script using the virtual environment managed by Poetry.
poetry publish --buildBuilds the project package and publishes it to PyPI.
poetry show --treeDisplays a tree of all project dependencies and their versions.
Use `poetry.lock` to ensure deterministic installs across different environments.
Keep development dependencies separate from production dependencies using `--dev` flag.
Regularly update dependencies using `poetry update` to maintain security and compatibility.
Use `poetry check` to verify the integrity of your `pyproject.toml` file.
Leverage virtual environments managed by Poetry instead of system-wide installations.