Is Poetry install the package when we do poetry add?

Viewed 833

I'm new to Poetry, and somehow, reading the doc on the web does not really help me to understand about this tool. So, i have existing project without using Poetry and i want to write pyproject.toml and poetry.lock files using requirements.txt from pip, to make other people easier to produce my result. For this, i use command:

poetry add 'cat requirements.txt'

But when the command is running, it seems like Poetry is installing the package again. Can anyone explain to me about this? Thank you

Here is the command result:

$ poetry add `cat requirements.txt`
Using version ^1.21.2 for numpy
Using version ^0.46 for olefile
Using version ^8.3.2 for Pillow
Using version ^3.10.0 for typing-extensions

Updating dependencies
Resolving dependencies...

Writing lock file

Package operations: 35 installs, 0 updates, 0 removals

  • Installing colorama (0.4.4)
  • Installing catalogue (2.0.6)
  • Installing click (8.0.3)
  • Installing cymem (2.0.5)
  • Installing numpy (1.21.2)
  • Installing typing-extensions (3.10.0.2)
  • Installing blis (0.7.4)
  • Installing certifi (2021.10.8)
  • Installing charset-normalizer (2.0.7)
  • Installing idna (3.2)
  • Installing preshed (3.0.5)
  • Installing smart-open (5.2.1)
  • Installing srsly (2.4.1)
  • Installing pyparsing (2.4.7)
  • Installing pydantic (1.8.2)
  • Installing urllib3 (1.26.7)
  • Installing typer (0.4.0)
  • Installing wasabi (0.8.2)
  • Installing markupsafe (2.0.1)
  • Installing fastrlock (0.6)
  • Installing packaging (21.0)
  • Installing pathy (0.6.0)
  • Installing jinja2 (3.0.2)
  • Installing spacy-legacy (3.0.8)
  • Installing torch (1.8.0)
  • Installing thinc (8.0.10)
  • Installing tqdm (4.62.3)
  • Installing pillow (8.3.2)
  • Installing requests (2.26.0)
  • Installing cupy-cuda111 (9.5.0)
  • Installing olefile (0.46)
  • Installing torchtext (0.9.0)
  • Installing spacy (3.1.3)
  • Installing torchvision (0.9.0)
  • Installing torchaudio (0.8.0)
1 Answers

Yes !! , poetry add pckg It will automatically find a suitable version constraint and install the package and subdependencies.

if your question about how to use requirements.txt with poetry :

Create a requirements.txt file form Poetry config

poetry export -f requirements.txt --output requirements.txt

or

poetry export -f requirements.txt > requirements.txt

or

poetry export --output requirements.txt

Import FROM requirements.txt TO poetry

 poetry add `cat requirements.txt`

or

 poetry add $( cat requirements.txt )
Related