Poetry
python
tool
CLI
package manager
virtual environments
Poetry is a package builder, dependency and virtual environment manager for python.
Installation
conda install -c conda-forge poetryAlternatvie installation instructions: python-poetry.org
Basic usage
Set-up project
poetry new "my_project_name"Installs poetry virtual environment and sets up the required files for poetry to work. pyproject.toml contains the configuration for poetry and the needed dependencies. The new folder is there for your source code.
- Adding / installing single dependencies
- ```bash poetry add package_name
Uses pip to install the new package to your virtual environment and adds it to your dependencies list.
Installing the dependencies from the .toml-file
: ```bash
poetry install
Running code with poetry
There are two options:
- Using poetry command
: bash poetry run python your_script.py
- Activating the poetry shell
: bash poetry shell
Using Jupyter-Notebooks in VS-Code
- List the directory of your python interpreter:
poetry env info --pathIn python-file,
on bottom right of VS-Code window click on python-version.
In new dialogue “Select Interpreter”, click “+ Enter interpreter path”
Paste the interpreter path into the text-box.
In jupyter-notebook,
Select kernel
Select Python environment
Select the python interpreter that you just listed before.
Build and publish your package
- Build package
- ```bash poetry build
This will package your file as sdist and wheel format.
Publish to PyPI
: ```bash
poetry publish