liveBook · Manning

Poetry

As explained in Python Workout: 50 ten-minute exercises

Poetry is a Python dependency-management and packaging tool that creates, builds, and publishes Python projects.

Poetry streamlines the awkward job of turning a Python project into a distributable package. It separates the distribution package directory from the Python package inside it, then provides commands for building and publishing. section 8.10

A typical workflow is:

  • Create a project with poetry new mypackage. section 8.10
  • Place the package code inside the generated project structure. section 8.10
  • Build an archive with poetry build, then upload it with poetry publish. section 8.10

Build and publish a package

From a Unix shell: poetry new mypackage; cd mypackage; copy the existing code into mypackage; poetry build; poetry publish. Publishing to PyPI requires an account, and a unique project name. section 8.10

$ poetry new mypackage                  #1
$ cd mypackage                          #2
$ cp -R ~/mypackage-code/* mypackage    #3
$ poetry build                          #4
$ poetry publish                        #5

Browse the complete command sequence from project creation through publication. section 8.10

How Python Workout: 50 ten-minute exercises covers it

How deep it goes
Demonstrates the command workflow and mentions pyproject.toml metadata without detailing configuration syntax.
Examples
Uses mypackage directories and a Unix sequence of poetry new, build, and publish commands.
What it assumes
Assumes an existing Python package and a PyPI account for publication.
What you can do after
Operate/configure Poetry to create a project, build a distribution, and publish it to PyPI.
How it connects
Connects distribution packages with Python packages, setup.py, pyproject.toml, dependencies, and PyPI.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Python Workout: 50 ten-minute exercises. The section links point to the parts of the book it draws on.