LinuxCommandLibrary

poetry-init

Initialize a new pyproject.toml file

TLDR

Initialize interactively

$ poetry init
copy
Non-interactive with defaults
$ poetry init -n
copy
Specify name and description
$ poetry init --name [myproject] --description "[A cool project]"
copy
With dependencies
$ poetry init --dependency [requests] --dev-dependency [pytest]
copy

SYNOPSIS

poetry init [options]

DESCRIPTION

poetry init creates a new pyproject.toml file in the current directory. It can run interactively to gather project details or accept command-line arguments.

PARAMETERS

-n, --no-interaction

Non-interactive mode.
--name name
Package name.
--description desc
Package description.
--author author
Author name.
--python version
Python version constraint.
--dependency dep
Add dependency.
--dev-dependency dep
Add dev dependency.

EXAMPLES

$ # Interactive initialization
poetry init

# Non-interactive with values
poetry init -n --name myproject --author "Name <email>"

# With dependencies
poetry init --dependency requests --dependency click

# Specify Python version
poetry init --python "^3.9"

# Full non-interactive
poetry init -n \
  --name myproject \
  --description "My project" \
  --author "Me <me@example.com>" \
  --python "^3.10"
copy

OUTPUT (pyproject.toml)

$ [tool.poetry]
name = "myproject"
version = "0.1.0"
description = ""
authors = ["Name <email>"]

[tool.poetry.dependencies]
python = "^3.10"
copy

CAVEATS

Creates pyproject.toml only. Run poetry install to create environment.

HISTORY

poetry init is part of Poetry by Sébastien Eustace for initializing Python projects with modern packaging.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community