Convert Figma logo to code with AI

python-poetry logopoetry

Python packaging and dependency management made easy

31,032
2,253
31,032
691

Top Related Projects

24,813

Python Development Workflow for Humans.

7,771

A modern Python package and dependency manager supporting the latest PEP standards

6,333

A system-level, binary package and environment manager running on all major operating systems and platforms.

6,725

The Fast Cross-Platform Package Manager

A set of tools to keep your pinned Python dependencies fresh.

5,868

Modern, extensible Python project management

Quick Overview

Poetry is a dependency management and packaging tool for Python. It aims to simplify the process of managing project dependencies, building, and publishing Python packages. Poetry provides a single tool for dependency resolution, virtual environment management, and package building.

Pros

  • Simplified dependency management with a single pyproject.toml file
  • Deterministic builds with lock files for reproducible environments
  • Built-in virtual environment management
  • Intuitive command-line interface for common tasks

Cons

  • Learning curve for developers used to traditional setup.py and requirements.txt workflows
  • Limited support for some advanced use cases compared to tools like pip
  • Occasional conflicts with other Python packaging tools in complex projects
  • Slower adoption in some parts of the Python ecosystem

Code Examples

  1. Initializing a new Poetry project:
poetry new my_project
cd my_project
  1. Adding dependencies:
poetry add requests
poetry add pytest --dev
  1. Running a script in the project's virtual environment:
poetry run python my_script.py
  1. Building and publishing a package:
poetry build
poetry publish

Getting Started

  1. Install Poetry:
curl -sSL https://install.python-poetry.org | python3 -
  1. Create a new project:
poetry new my_project
cd my_project
  1. Add dependencies:
poetry add requests
  1. Run your script:
poetry run python my_project/main.py

For more detailed information and advanced usage, refer to the official Poetry documentation at https://python-poetry.org/docs/.

Competitor Comparisons

24,813

Python Development Workflow for Humans.

Pros of pipenv

  • Combines pip and virtualenv into a single tool
  • Automatically creates and manages a virtualenv for projects
  • Generates a Pipfile.lock for deterministic builds

Cons of pipenv

  • Slower dependency resolution compared to Poetry
  • Less intuitive dependency management for complex projects
  • Limited support for monorepo structures

Code Comparison

pipenv:

pipenv install requests
pipenv run python script.py

Poetry:

poetry add requests
poetry run python script.py

Both tools aim to simplify Python package management and virtual environment creation. pipenv uses Pipfile and Pipfile.lock, while Poetry uses pyproject.toml and poetry.lock. Poetry offers more advanced features like build system integration and better handling of dev dependencies.

Poetry generally provides faster dependency resolution and more intuitive package management, especially for complex projects. It also has better support for monorepo structures and publishing packages to PyPI.

However, pipenv is more established and may be more familiar to developers coming from other ecosystems. It's also directly supported by the Python Packaging Authority (PyPA), which may give it an edge in terms of long-term support and integration with other PyPA tools.

7,771

A modern Python package and dependency manager supporting the latest PEP standards

Pros of PDM

  • Faster dependency resolution and installation
  • Native support for PEP 582 (local package installations)
  • More flexible project structure with support for src-layout and flat-layout

Cons of PDM

  • Smaller community and ecosystem compared to Poetry
  • Less mature with fewer features and integrations
  • Steeper learning curve for users familiar with Poetry or pip

Code Comparison

PDM:

[project]
name = "my-project"
version = "0.1.0"
dependencies = [
    "requests>=2.25.0",
]

Poetry:

[tool.poetry]
name = "my-project"
version = "0.1.0"
dependencies = [
    "requests>=2.25.0",
]

Both PDM and Poetry use similar TOML-based configuration files, but PDM follows the standard pyproject.toml structure more closely. PDM's dependency management is generally faster and more efficient, while Poetry offers a more comprehensive set of features and a larger ecosystem. PDM's support for PEP 582 allows for easier local package installations, but its smaller community may result in fewer resources and third-party integrations compared to Poetry.

6,333

A system-level, binary package and environment manager running on all major operating systems and platforms.

Pros of conda

  • Supports multiple programming languages, not just Python
  • Manages system-level dependencies and non-Python packages
  • Provides environment management with isolated installations

Cons of conda

  • Slower package resolution and installation compared to Poetry
  • Can be more complex to use, especially for Python-only projects
  • Larger footprint and more resource-intensive

Code comparison

conda:

name: myenv
channels:
  - conda-forge
dependencies:
  - python=3.9
  - numpy
  - pandas

Poetry:

[tool.poetry.dependencies]
python = "^3.9"
numpy = "^1.21"
pandas = "^1.3"

Both conda and Poetry are popular package and environment management tools, but they serve different purposes. conda is more versatile, handling multiple languages and system-level dependencies, while Poetry focuses on Python-specific projects with a simpler, faster approach. The choice between them depends on project requirements and personal preference.

6,725

The Fast Cross-Platform Package Manager

Pros of Mamba

  • Significantly faster package resolution and installation compared to Poetry
  • Better handling of large-scale environments and complex dependency trees
  • Supports conda packages, offering a wider range of scientific and data science libraries

Cons of Mamba

  • Less focus on Python-specific project management and packaging
  • Steeper learning curve for users familiar with pip-based workflows
  • Limited integration with Python-specific tools and standards (e.g., pyproject.toml)

Code Comparison

Mamba:

mamba create -n myenv python=3.9 numpy pandas
mamba activate myenv
mamba install scipy

Poetry:

poetry init
poetry add numpy pandas
poetry run python script.py
poetry add scipy

While Mamba uses a conda-like syntax for environment and package management, Poetry provides a more Python-centric approach with its own command structure and project initialization. Mamba excels in speed and handling complex environments, especially for scientific computing, while Poetry offers tighter integration with Python packaging standards and project management features.

A set of tools to keep your pinned Python dependencies fresh.

Pros of pip-tools

  • Simpler and more lightweight, focusing primarily on dependency management
  • Generates pip-compatible requirements files, making it easier to integrate with existing pip-based workflows
  • Allows for more granular control over package versions and constraints

Cons of pip-tools

  • Lacks built-in virtual environment management
  • Does not provide a comprehensive project management solution like Poetry
  • Requires manual setup and configuration for some features that Poetry handles automatically

Code Comparison

pip-tools:

pip-compile requirements.in
pip-sync requirements.txt

Poetry:

poetry add package_name
poetry install
poetry update

pip-tools focuses on generating and syncing requirements files, while Poetry provides a more comprehensive set of commands for managing dependencies, environments, and project metadata. Poetry's commands are generally more intuitive and cover a wider range of project management tasks, whereas pip-tools requires combining its functionality with other tools for a complete workflow.

5,868

Modern, extensible Python project management

Pros of Hatch

  • Faster project initialization and environment creation
  • Built-in support for multiple Python versions and environments
  • More flexible configuration options, allowing for custom build and publish scripts

Cons of Hatch

  • Less mature ecosystem and community support
  • Steeper learning curve for users familiar with traditional Python packaging tools
  • Limited lock file functionality compared to Poetry's robust dependency resolution

Code Comparison

Hatch project configuration:

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "example"
version = "0.1.0"

Poetry project configuration:

[tool.poetry]
name = "example"
version = "0.1.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

Both Hatch and Poetry aim to simplify Python project management and packaging. While Hatch offers more flexibility and faster operations, Poetry provides a more established ecosystem and robust dependency management. The choice between the two depends on specific project requirements and personal preferences.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Poetry: Python packaging and dependency management made easy

Poetry Stable Version Pre-release Version Python Versions Download Stats Discord

Poetry helps you declare, manage and install dependencies of Python projects, ensuring you have the right stack everywhere.

Poetry Install

Poetry replaces setup.py, requirements.txt, setup.cfg, MANIFEST.in and Pipfile with a simple pyproject.toml based project format.

[tool.poetry]
name = "my-package"
version = "0.1.0"
description = "The description of the package"

license = "MIT"

authors = [
    "Sébastien Eustace <sebastien@eustace.io>"
]

repository = "https://github.com/python-poetry/poetry"
homepage = "https://python-poetry.org"

# README file(s) are used as the package description
readme = ["README.md", "LICENSE"]

# Keywords (translated to tags on the package index)
keywords = ["packaging", "poetry"]

[tool.poetry.dependencies]
# Compatible Python versions
python = ">=3.8"
# Standard dependency with semver constraints
aiohttp = "^3.8.1"
# Dependency with extras
requests = { version = "^2.28", extras = ["security"] }
# Version-specific dependencies with prereleases allowed
tomli = { version = "^2.0.1", python = "<3.11", allow-prereleases = true }
# Git dependencies
cleo = { git = "https://github.com/python-poetry/cleo.git", branch = "main" }
# Optional dependencies (installed by extras)
pendulum = { version = "^2.1.2", optional = true }

# Dependency groups are supported for organizing your dependencies
[tool.poetry.group.dev.dependencies]
pytest = "^7.1.2"
pytest-cov = "^3.0"

# ...and can be installed only when explicitly requested
[tool.poetry.group.docs]
optional = true
[tool.poetry.group.docs.dependencies]
Sphinx = "^5.1.1"

# Python-style entrypoints and scripts are easily expressed
[tool.poetry.scripts]
my-script = "my_package:main"

Installation

Poetry supports multiple installation methods, including a simple script found at install.python-poetry.org. For full installation instructions, including advanced usage of the script, alternate install methods, and CI best practices, see the full installation documentation.

Documentation

Documentation for the current version of Poetry (as well as the development branch and recently out of support versions) is available from the official website.

Contribute

Poetry is a large, complex project always in need of contributors. For those new to the project, a list of suggested issues to work on in Poetry and poetry-core is available. The full contributing documentation also provides helpful guidance.

Resources

Related Projects

  • poetry-core: PEP 517 build-system for Poetry projects, and dependency-free core functionality of the Poetry frontend
  • poetry-plugin-export: Export Poetry projects/lock files to foreign formats like requirements.txt
  • poetry-plugin-bundle: Install Poetry projects/lock files to external formats like virtual environments
  • install.python-poetry.org: The official Poetry installation script
  • website: The official Poetry website and blog